1

this is a simple question, but I have been puzzling over it for a while now and it doesn't have much documentation to look at:

I've got a development setup with ClojureScript, figwheel, npm deps working just fine for me. But when I produce a production, compiled JS file, it does not find the npm dependency files. So where and how do I place which of these packages in the production web server, so that they will be found and loaded?

Regards, Chris

1 Answer 1

1

All files required to run your JS will be included in the compilation output after :advanced optimizations. No node_modules files will be required at all so there should not be any need to place them anywhere. Only the files produced by the build directly should be loaded.

:npm-deps however is an alpha feature with many known issues. You can use alternate solutions like webpack or shadow-cljs which work much more reliable.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for the answer. I tried just using :advanced but that didn't work. I guess I'll look at the tools you recommended.
So do these two tools you mention work with any npm module? It doesn't seem clear to me from reading the pages...
I'm the author of shadow-cljs and yes it works with nearly all npm modules. Just npm install the-thing and (:require ["the-thing" :as x]), no additional steps needed. webpack is a bit more involved and you should follow the guide I linked. Maybe your :npm-deps setup can be fixed but you did not provide enough information to help. Maybe post your build config and the errors you get.
Well, if shadow-cljs is more mature, I'll just use that. Thanks.
As you are the author of shadow-cljs, could I ask one more thing? what is the appropriate target for using the compiled file with a web worker (using servant)?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.