This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-16
Channels
- # atlanta-clojurians (1)
- # aws (1)
- # beginners (65)
- # boot (4)
- # cider (81)
- # cljs-dev (25)
- # cljsrn (27)
- # clojure (129)
- # clojure-dusseldorf (12)
- # clojure-italy (68)
- # clojure-norway (5)
- # clojure-poland (4)
- # clojure-spec (14)
- # clojure-uk (72)
- # clojurescript (144)
- # code-reviews (19)
- # copenhagen-clojurians (5)
- # cursive (16)
- # datomic (21)
- # editors (1)
- # emacs (15)
- # events (1)
- # figwheel (6)
- # fulcro (54)
- # graphql (1)
- # hoplon (24)
- # jobs (6)
- # jobs-discuss (2)
- # keechma (4)
- # leiningen (6)
- # luminus (17)
- # lumo (2)
- # off-topic (43)
- # onyx (6)
- # pedestal (2)
- # perun (2)
- # portkey (3)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (5)
- # shadow-cljs (46)
- # specter (8)
- # test-check (2)
- # testing (3)
- # vim (16)
- # yada (1)
If you are using re-natal
by default there should be no need to have the ClojureScript compiler index the (gigantic) node_modules
directory (because the React Native packager takes care of pulling code out of there as needed). By setting the ClojureScript compiler option :npm-deps false
my (start-figwheel "ios")
is nearly instantaneous (whereas previously it would spend a significant chunk of time indexing node_modules
). If you want to try this to see if it also works for you, you will need to patch Figwheel so that it allows false
as a valid value for :npm-deps
.
^ Figwheel patch is available in this PR https://github.com/bhauman/lein-figwheel/pull/678
Is npm-deps
on by default in recent versions of the cljs compiler?
It seems to me that indexing node_modules
is not a good default behavior, given that JS based tools don't do any indexing as far as I know (they just open the directory you require)
@pesterhazy Yes. I don’t know if this is a recent change, but it is definitely the case now. See case 4 in https://dev.clojure.org/jira/browse/CLJS-2494
This has to do with the compiler indexing things in node_modules
, presumably so that the compiler can itself directly make use of code in there. So, the right thing to do appears to be to turn it off, unless you are doing something that actually makes use of that feature.
For my project, disabling it seems to have no ill effects, and I’m getting back, say 20 to 40 seconds (I haven’t actually measured it)
I'd love to use :npm-deps
for managing things, rather than package.json
. It just hasn't proved reliable yet.
An interesting case, I suppose, is when you actually want to use :npm-deps
to consume some library and have it go through Closure (per https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules), but if you aren’t doing that, then all of the other stuff in node_modules
is really there for the packager to dredge through, right?
Having all the used deps go through Closure is a good thing, isn't it? I'd think, in the near future, we should all be doing it.
Aside from managing the deps in your project.clj
(or whatever) and having easy require
access to the packages, that's the next biggest sell. More optimization.
If we can get everything to go through Closure, yes, that would definitely be great. I suspect that is essentially the “don’t embrace the packager” approach.
I timed it on my system (an older 2012 Mac Pro), and disabling :npm-deps
saves me 45 seconds when doing (start-figwheel "ios")
Oh, the PR for Figwheel is one that needs to happen anyway. But, I do think we need a re-natal
PR to ultimately change the default project.clj
that gets set up to include this config.
Thanks for doing this @mfikes.
Just tried it on the project I’m working on for android and it took ~25 seconds without and with your patch.
But maybe I’m running it wrong: I’ve started the emulator and Metro bundler and then I fired up the REPL via CIDER while in the project dir.
Once it came up, I ran (start-figwheel "android")
.
Originally I had lein-figwheel “0.5.14” installed.
My project’s node_modules directory has 687 modules installed:
$ ls -1 node_modules/ | wc -l