Fork me on GitHub
#clojurescript
<
2019-02-22
>
chancerussell04:02:42

In case anyone was curious about the problem above…I don’t think that the dependency order of a :requires list actually has any kind of defined ordering

chancerussell04:02:04

Since the analyzer tosses the deps into a set

chancerussell04:02:44

A quick experiment with changing the names of namespaces does seem to show that the output order in cljs_deps.js is definitely not based on the order in the :requires list, so that explains my issue

mfikes12:02:39

@chancerussell The intent is that the compiler honor require dependency order. https://dev.clojure.org/jira/browse/CLJS-1453 If you've found a case where it doesn't, I'd recommend filing a JIRA.

kwladyka13:02:36

Do you know any way to optimise this code for webpack purpose to use in cljs? I would like to not repeat names 3 times. Some kind of macro for webpack? It makes a mess.

import {AppBar, Button, Checkbox, InputAdornment, FormControlLabel, Grid, Paper, SvgIcon, TextField, Toolbar, Typography, IconButton} from '@material-ui/core';
window.MaterialUiCore = {
    AppBar: AppBar,
    Button: Button,
    Checkbox: Checkbox,
    Grid: Grid,
    FormControlLabel: FormControlLabel,
    Paper: Paper,
    SvgIcon: SvgIcon,
    TextField: TextField,
    Toolbar: Toolbar,
    Typography: Typography,
    IconButton: IconButton,
    InputAdornment: InputAdornment
}

Roman Liutikov13:02:42

window.whatever = require("whatever")

Roman Liutikov13:02:30

or if you still want es6

import * as whatever from "whatever"
window.whatever = whatever

kwladyka13:02:46

AppBar: require("@material-ui/core/AppBar").default, produce more kb, than

import {AppBar} from '@material-ui/core';
window.MaterialUiCore = {
    AppBar: AppBar
}

kwladyka13:02:57

so it is not really the same

Roman Liutikov13:02:03

that’s how webpack does DCE

Roman Liutikov13:02:16

also you don’t have to repeat names in object literal

kwladyka13:02:24

and still I have to repeat names x2

kwladyka13:02:22

Any other idea, which will let me use names x1 and not increase kb?

kwladyka13:02:49

I saw somewhere webpack can have macro, but I didn’t try it

Roman Liutikov13:02:23

no, unless you want to write your own webpack plugin to do codegen

kwladyka13:02:04

who knows… maybe. Do you know good example of such plugin?

kwladyka13:02:17

or macro, or whatever

Roman Liutikov13:02:00

I think you can find something at https://webpack.js.org/ they have pretty good docs

kwladyka13:02:12

thx, ok so it will consume more time, than I wanted 😉

Roman Liutikov13:02:55

I’d just copy paste import object, not so hard to do 🙂

kwladyka13:02:01

yeah, but in long term condition when adding / removing objects it start to be frustrating and make a mess. alphabetic order etc.

kwladyka13:02:23

a small thing anyway

victorb15:02:07

Hello everyone! Trying to figure out why a dependency defined in :npm-deps is not require'able (or why :npm-deps true doesn't make all existing node_modules available). What's the first steps for debugging this?

kwladyka15:02:04

hmm…. check if you have them in node_modules folder?

victorb15:02:47

@kwladyka yeah, everything is there properly (installed externally) but won't show up in the clojurescript context (eg (require 'my-lib))

kwladyka15:02:15

Hmm I don’t have more hints, sorry.

chancerussell16:02:27

@mfikes Yep. I am going to spend some time this weekend nailing down the bug and seeing how hard it’d be to patch

victorb16:02:06

in the end, managed to get it to work by compiling a sort of compat lib (just import and expose on window.my-lib) with webpack, then manually writing the foreign-lib entry

chancerussell16:02:07

I think the order is preserved in most spots, it just gets flaky on the output to cljs_deps

👍 5
chancerussell16:02:20

Will at least get a simple reproduction worked up

craftybones17:02:24

I was running something today and it looks like a (filter even? (fibo)) didn’t filter past a certain point. even? doesn’t work on bignum in cljs?

thheller17:02:46

there are no bignums in JS

chancerussell18:02:45

Another way to put it is that you’re hitting the limits of Number precision

kwladyka23:02:12

maybe there is something in cljs, not sure

john23:02:42

And the new js/BigInts