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

chris_l
  • 57
  • 6

1 Answers1

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.

Thomas Heller
  • 3,842
  • 1
  • 9
  • 9
  • Thanks for the answer. I tried just using `:advanced` but that didn't work. I guess I'll look at the tools you recommended. – chris_l Mar 17 '19 at 13:15
  • So do these two tools you mention work with any npm module? It doesn't seem clear to me from reading the pages... – chris_l Mar 17 '19 at 19:38
  • 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. – Thomas Heller Mar 18 '19 at 10:06
  • Well, if `shadow-cljs` is more mature, I'll just use that. Thanks. – chris_l Mar 18 '19 at 13:04
  • 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)? – chris_l Mar 18 '19 at 15:23
  • `:browser` has built-in support for workers. See https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers – Thomas Heller Mar 18 '19 at 16:18