This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-22
Channels
- # beginners (55)
- # cider (22)
- # cljs-dev (123)
- # cljsrn (75)
- # clojars (1)
- # clojure (92)
- # clojure-europe (2)
- # clojure-italy (16)
- # clojure-nl (6)
- # clojure-spec (17)
- # clojure-uk (77)
- # clojured (2)
- # clojurescript (39)
- # core-async (8)
- # cursive (4)
- # data-science (1)
- # datomic (22)
- # duct (4)
- # editors (21)
- # emacs (10)
- # events (4)
- # fulcro (116)
- # graphql (8)
- # immutant (3)
- # jackdaw (1)
- # juxt (3)
- # kaocha (4)
- # luminus (1)
- # mount (1)
- # nrepl (32)
- # off-topic (34)
- # other-languages (5)
- # pedestal (32)
- # reagent (1)
- # ring (6)
- # ring-swagger (7)
- # shadow-cljs (5)
- # spacemacs (3)
- # specter (1)
- # sql (1)
- # vim (21)
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
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L4307
Since the analyzer tosses the deps into a set
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
@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.
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
}
window.whatever = require("whatever")
or if you still want es6
import * as whatever from "whatever"
window.whatever = whatever
AppBar: require("@material-ui/core/AppBar").default,
produce more kb, than
import {AppBar} from '@material-ui/core';
window.MaterialUiCore = {
AppBar: AppBar
}
that’s how webpack does DCE
also you don’t have to repeat names in object literal
no, unless you want to write your own webpack plugin to do codegen
I think you can find something at https://webpack.js.org/ they have pretty good docs
I’d just copy paste import object, not so hard to do 🙂
yeah, but in long term condition when adding / removing objects it start to be frustrating and make a mess. alphabetic order etc.
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?
@kwladyka yeah, everything is there properly (installed externally) but won't show up in the clojurescript context (eg (require 'my-lib)
)
@mfikes Yep. I am going to spend some time this weekend nailing down the bug and seeing how hard it’d be to patch
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
I think the order is preserved in most spots, it just gets flaky on the output to cljs_deps
Will at least get a simple reproduction worked up
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?
Another way to put it is that you’re hitting the limits of Number precision
@srijayanth https://github.com/MikeMcl/bignumber.js can be useful if you really ned bignum