Fork me on GitHub

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 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?


Yeah, env.js appears waaay below in the network requests log. Hmm...


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