This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-31
Channels
- # aws-lambda (4)
- # beginners (152)
- # boot (19)
- # cider (45)
- # cljs-dev (14)
- # clojure (54)
- # clojure-dev (33)
- # clojure-greece (11)
- # clojure-italy (4)
- # clojure-nl (8)
- # clojure-norway (2)
- # clojure-russia (6)
- # clojure-sg (1)
- # clojure-spec (1)
- # clojure-uk (40)
- # clojure-ukraine (5)
- # clojurescript (40)
- # community-development (13)
- # component (8)
- # core-async (3)
- # cursive (25)
- # data-science (11)
- # datomic (13)
- # duct (1)
- # emacs (2)
- # events (16)
- # figwheel (3)
- # fulcro (53)
- # graphql (2)
- # jobs (5)
- # jobs-rus (1)
- # juxt (10)
- # leiningen (4)
- # off-topic (82)
- # other-languages (5)
- # portkey (3)
- # protorepl (13)
- # re-frame (22)
- # reagent (15)
- # ring-swagger (4)
- # shadow-cljs (69)
- # spacemacs (7)
- # specter (16)
- # sql (13)
- # vim (5)
- # yada (2)
https://gist.github.com/minikomi/a761e8eaf2f15bf0b1caf89cde19ecd8 Quick drop-in lazy-loading image.
Could someone please shed some light on how to use :npm-deps
with Reagent 0.8 with packages that require React?
If I don't add react
, react-dom
and create-react-class
to :npm-deps
, the build process fails with Error: Can't resolve 'react' in '%project_dir%/node_modules/react-measure/lib'
. Apparently, I need to explicitly add React to :npm-deps
?
If I add all those, the build process goes just fine, but then I see Uncaught ReferenceError: process is not defined
in the browser's console.
According to https://github.com/reagent-project/reagent/blob/master/docs/0.8-upgrade.md I can use :shim-process
(apparently was renamed to :process-shim
) option to tackle that. But adding :process-shim true
does nothing in my case.
Huh, but after all messages, if I test for process.env
in the browser's conole - it's there. Maybe it's the matter of dependency order of some sort?
Might be easier to just install deps with npm install
(and save to package.json) than to use :npm-deps
Node 8 / npm 5 had some strange issues with npm install removing all packages except those in install command, but maybe they were solved already
Not sure about process.env, works for me with React at least, and I think React uses it
Fixed the option name in upgrade guide
@juhoteperi I asked in the #clojurescript channel - apparently preloads (including the one that's supposed to introduce process.env
) are loaded only after all dependencies have been loaded.
React does use process.env
, and during loading as well. How exactly do you load React?
"Normally", try Reagent by starting figwheel from test-environments/browser-node-react-16
, that should use process shim
hmmh, starting figwheel for that env requires some lein profile
Ah no, process-shim is enabled in the default build
Interesting - in the generated cljs_deps.js
the entry goog.addDependency("../process/env.js", ['process.env'], ['cljs.core']);
does go right after cljs.core
, just as the documentation on CLJS compiler states.
But for my code that's not the case. I'll keep digging.
I think the issue is that process.env
is added as the last preload. Hence, if any previous preload has any dependencies (like my preload that calls re-frisk.core/enable-re-frisk!
), they will be included before process.env
.
That sounds plausible, you can workaround this for now by enabing re-frisk from app code instead of preload