Fork me on GitHub
#figwheel-main
<
2020-10-19
>
kah0ona13:10:54

Hi folks, in my host page, for figwheel, should i include the /cljs-out/dev/main.js or main_bundle.js? (just started using npm import feature as well)

kah0ona13:10:55

“Your host page will need to load the final bundled asset.” doh

kah0ona13:10:08

Now I run into this:

[Figwheel] Successfully compiled build dev to "target/public/cljs-out/dev/main.js" in 28.101 seconds.
[Figwheel] Bundling: npx webpack --mode=development target/public/cljs-out/dev/main.js -o target/public/cljs-out/dev/main_bundle.js
[Figwheel:SEVERE] Bundling command failed
asset bundle.js 644 bytes [emitted] (name: main)

ERROR in main
Module not found: Error: Can't resolve 'target/public/cljs-out/dev/main.js' in '/Users/marten/Sites/clojure/aviationglass'

webpack 5.1.3 compiled with 1 error in 60 ms

wcalderipe13:10:36

it seems you and I are having the same issue..

wcalderipe13:10:22

by your file path I assume you're using Mac OS, thus it should be a cross-platform issue because I'm using Linux

wcalderipe13:10:25

I have tried to fix it over the weekend using auto-bundle and manual setup but I didn't have any luck!

wcalderipe13:10:53

what's your figwheel-main version?

kah0ona16:10:57

0.2.11, yes macOS

kah0ona16:10:21

ah yeah i only just saw the details of your post.

kah0ona16:10:34

i haven’t even tried the :auto-bundle yet

kah0ona16:10:04

it sort of seems figwheel tries to read the file too soon by shelling out to npx too early or something.

kah0ona16:10:53

would it be a problem with the webpack version?

kah0ona16:10:23

ok solution (workaround): add this to your dev.cljs.edn : :output-to "./target/public/cljs-out/dev/main.js"

kah0ona13:10:31

I can confirm the file is there, as the first log line indicates.

kah0ona13:10:01

anyone any idea?, using latest cljs and figwheel-main 0.2.11

kah0ona16:10:31

ah, so @wcalderipe and I bumped into the same issue 🙂

kah0ona16:10:01

No that’s not it, manually running this npx command from my terminal (when main.js is definitely there), still yields this error

kah0ona16:10:25

so, adding ./ in front would fix this

kah0ona16:10:15

@wcalderipe $ npx webpack --mode=development ./target/public/cljs-out/dev/main.js -o target/public/cljs-out/dev/main_bundle.js does run

🙌 3
wcalderipe17:10:43

great, mate.. thanks for sharing!

kah0ona16:10:01

{:main       aviationglass.core
 :target     :bundle
 :output-to  "./target/public/cljs-out/dev/main.js" ;; the ./ at the beginning is somehow mandatory. 
 :bundle-cmd {:none ["npx" "webpack" "--mode=development" :output-to "-o" :final-output-to]}}

kah0ona17:10:03

I figured this out by trying deliberately to run the cli command manually with a wrong filename, this yielded the exact same error. Then I just took a plunge and tried with ./ in front, and it compiled :man-shrugging:

athomasoriginal17:10:22

@wcalderipe @kah0ona As was noted in your thread, try downgrading the webpack version of 4.xx. I ran into this last night and that resolves the issue. Of course, your solution of modifying the :bundle-cmd also works

athomasoriginal17:10:37

haha solid timing 😉

kah0ona17:10:38

opened an issue for it

👍 3
kah0ona17:10:55

might even be able to make a PR soon, but gtg now

kah0ona17:10:19

and it should probably be tested through various versions of webpack i assume? not sure what the policy is on this 🙂