Is there some special way I should be setting :optimizations :advanced? All I have is this: my lein alias:

lein run -m figwheel.main -O advanced -bo min
^{:final-output-to     "resources/public/js/compiled/app.js"
  :open-url            false
  :watch-dirs          ["test" "src"]
  :css-dirs            ["resources/public/css"]}
{:main example.core
 :target :bundle
 :bundle-cmd {:default ["npx" "webpack" "--mode=production" :output-to "-o" :final-output-to]}
 :output-dir           "resources/public/js/compiled/"
 :source-map-timestamp true
 :devcards             true
 :closure-defines {cljs.core/*global* "window"
                   goog.DEBUG false}}


Right, flushed node_modules and reinstalled, and building min. Doesn’t work:

[Figwheel:SEVERE] Bundling command failed
Hash: b732264b26408a237e25
Version: webpack 4.43.0
Time: 39221ms
Built at: 05/31/2020 1:22:58 AM
 1 asset
Entrypoint main = app.js
[7] ./resources/public/js/compiled/main.js 1.14 MiB {0} [built]
[8] (webpack)/buildin/global.js 472 bytes {0} [built]
    + 16 hidden modules

ERROR in ./resources/public/js/compiled/main.js
Module not found: Error: Can't resolve 'react' in '/<project folder>/resources/public/js/compiled'
 @ ./resources/public/js/compiled/main.js 36:82-98 48:101-117 246:78-94
Just can’t resolve libs like react, react-dom again… Now devs not working either… Just trying to debug why…

bhauman 2020-05-31T01:10:46.091100Z

Yeah this is tough to do over text.

bhauman 2020-05-31T01:11:23.091300Z

You should make sure that you also delete the resources/public/js/compiled dir as well between runs

bhauman 2020-05-31T01:11:29.091500Z

just to be safe

bhauman 2020-05-31T01:12:00.091700Z

you should also try compiling in :simple

bhauman 2020-05-31T01:12:49.091900Z

and then bundling from the command line and try to follow the source of the errors, it seems like there is a bad require path or something

bhauman 2020-05-31T01:14:13.092200Z

also perhaps compile the advanced build to a completely different directory than the dev build

bhauman 2020-05-31T01:14:59.092400Z

also you may have a webpack.config.js that webpack is reading from?


Nope, not setting any webpack.config.js stuff, I didn’t want to mess around with any settings you might have created…


I’m normally flushing the compiled folder and the node_modules folder. I’ll try bundling from the command line…


btw this bit is correct right?

:bundle-cmd {:default ["npx" "webpack" "--mode=production" :output-to "-o" :final-output-to]}


Ok I’m doing this in stages as requested, not really had to debug webpack before, but something interesting, this is the first webpack error:

ERROR in ./resources/public/js/compiled/main.js
Module not found: Error: Can't resolve 'react' in '/<project-folder>/resources/public/js/compiled'
 @ ./resources/public/js/compiled/main.js 36:82-98 48:101-117 246:78-94
It’s caused by multiple places performing:
which is as you suggested would be the problem, but the file itself has:
/** @license React v16.3.2
 * react.production.min.js
            ;(function(p,h){"object"===typeof exports&&"undefined"!==typeof module?module.exports=h():"function"===typeof define&&define.amd?define(h):p.React=h()})
I read that as it’s being exported as h? I thought that at this point the externs are not supposed to be minified?

bhauman 2020-05-31T13:37:59.093600Z

@folcon yeah so I assumed you had read this

bhauman 2020-05-31T13:38:00.093800Z

bhauman 2020-05-31T13:38:18.094Z



Oh, sorry no. The first thing I saw was the npm guide that you’d written, if that’s necessary info, perhaps link that?


Reading =)…


With regards to overriding foreign libs, I’m not actually trying to use the npm react, I’m using another npm lib, but for some reason it’s not using the reagent react lib…

bhauman 2020-05-31T14:14:55.094900Z

oh ……!

bhauman 2020-05-31T14:15:04.095100Z

well thats the problem

bhauman 2020-05-31T14:15:19.095300Z

I think

bhauman 2020-05-31T14:15:43.095500Z

or a problem

bhauman 2020-05-31T14:17:14.095700Z

but it doesn’t seem like it should be a problem

bhauman 2020-05-31T14:17:53.095900Z

if there is a require(“react”) it’s not using the react cljsjs lib

bhauman 2020-05-31T14:18:50.096100Z

I don’t know why it would do that if react isn’t in node_modules

bhauman 2020-05-31T14:19:42.096400Z

but this is easy enough to fix for now

bhauman 2020-05-31T14:20:22.096600Z

npm install react react-dom and then exclude the ones in reagent

bhauman 2020-05-31T14:22:20.096800Z

but there may be a bug here or something we don’t understand so it might be worth maybe creating a small example of this behavior to verify it

bhauman 2020-05-31T14:22:25.097Z

I might try that

bhauman 2020-05-31T14:22:58.097200Z

but this is a clojurescript problem not a figwheel problem per-se

bhauman 2020-05-31T14:23:23.097400Z

but I definitely need to understand it because I want the NPM docs to cover this well


well that doesn’t answer what this is coming from?

Module not found: Error: Can't resolve 'xmlhttprequest' 


I mean this system does seem to assume that the user is basically swapping cljs libs for npm ones, but tracking that is not trivial =)…

bhauman 2020-05-31T15:48:37.098Z

I’m not sure that’s really true, I’m going to check that with reagent right now

bhauman 2020-05-31T15:50:18.098200Z

I’m not sure that should be happening


Perhaps not, I’m very willing to believe I’ve configured something incorrectly, but I have no idea what…


Found a clue on stackoverflow[0]:

The xmlhttprequest package is meant for server-side JavaScript.
Is there something specifying webpack is targeting server-side instead of the browser? - [0]

bhauman 2020-05-31T20:12:59.099Z

hmmm react-dom-server is intended to be server side


Yea, I can’t find anything in my code =)…