Open ahwatts opened 11 months ago
A partial solution to the first issue, via https://clojuredocs.org/clojure.java.shell/sh#example-60754e7fe4b0b1e3652d74c5
Apparently on Windows, clojure.java.shell/sh
needs either the actual file name of the program to run (if it's not PowerShell or cmd) or else it needs to run the command in PowerShell or cmd, which handles omitting the extension.
So if I change dbn-frontend.cljs.edn
to
{:main dbn.frontend.core
:target :bundle
:bundle-cmd {:none ["powershell" "npx" "webpack"
"--mode=development"
"--entry" :output-to
"--output-path" :final-output-dir
"--output-filename" :final-output-filename]}
:output-dir "target/js/dbn-frontend"
:asset-path "js/dbn-frontend"}
or
{:main dbn.frontend.core
:target :bundle
:bundle-cmd {:none ["npx.cmd" "webpack"
"--mode=development"
"--entry" :output-to
"--output-path" :final-output-dir
"--output-filename" :final-output-filename]}
:output-dir "target/js/dbn-frontend"
:asset-path "js/dbn-frontend"}
then the bundling command will at least run.
The second problem then appears to happen because figwheel uses clojure.java.io/file
to assemble the paths to :output-to
and :final-output-dir
, which correctly uses \
as the directory separator on Windows, while Webpack appears to want the directory separator to be /
there. If I run this command on Windows:
~\Projects\dreamybandnames2> npx webpack --mode=development --entry ./target/js/dbn-frontend/main.js --output-path ./target/js/dbn-frontend --output-filename main_bundle.js
asset main_bundle.js 2.38 MiB [compared for emit] (name: main)
runtime modules 2.37 KiB 7 modules
orphan modules 311 bytes [orphan] 2 modules
modules by path ./node_modules/ 1.82 MiB 311 modules
modules by path ./target/js/dbn-frontend/*.js 1.45 KiB
./target/js/dbn-frontend/main.js 1.19 KiB [built] [code generated]
./target/js/dbn-frontend/npm_deps.js 264 bytes [built] [code generated]
webpack 5.90.1 compiled successfully in 908 ms
that builds the bundle correctly. Interestingly, it seems like only the first separator needs to be /
:
~\Projects\dreamybandnames2> npx webpack --mode=development --entry ./target\js\dbn-frontend\main.js --output-path ./target\js\dbn-frontend --output-filename main_bundle.js
asset main_bundle.js 2.38 MiB [compared for emit] (name: main)
runtime modules 2.37 KiB 7 modules
orphan modules 311 bytes [orphan] 2 modules
modules by path ./node_modules/ 1.82 MiB 311 modules
modules by path ./target/js/dbn-frontend/*.js 1.45 KiB
./target/js/dbn-frontend/main.js 1.19 KiB [built] [code generated]
./target/js/dbn-frontend/npm_deps.js 264 bytes [built] [code generated]
webpack 5.90.1 compiled successfully in 953 ms
That kind of makes it seem like that issue is really Webpack's, for requiring that relative paths start with ./
even on Windows.
This means that to solve this, two things need to happen:
:bundle-cmd
be different only on Windows.File.separator
needs to be /
, or else the first .\
needs to be ./
.I'm not sure how to get either to happen while not breaking dev on other platforms. I could just modify dbn-frontend.cljs.edn
and remember to not check in the change, or else I could have a different dbn-frontend.cljs.edn
for doing dev on Windows, but I don't think I can do logic in an EDN file, right? As for File.separator
, does Java or clojure.java.io
even allow you to change it temporarily (or permanently)?
When I try to bundle my code with Webpack on Windows, I'm getting the following error:
Something about how Figwheel is running
npx
is not working. It's present on my path:And I can run that command from the PS command-line, though it fails for different, webpack-related reasons:
My CLJS edn,
dbn-frontend.cljs.edn
:Is there something special I need to do to get figwheel-main to work with NPM / Webpack in Windows? The config I have works correctly on Mac / Linux.