Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow :npm-deps to be specified per-build or per-target #1038

Open
aiba opened this issue Jul 27, 2022 · 2 comments
Open

Allow :npm-deps to be specified per-build or per-target #1038

aiba opened this issue Jul 27, 2022 · 2 comments

Comments

@aiba
Copy link
Sponsor Contributor

aiba commented Jul 27, 2022

I have a project that has both a browser frontend and also a react-native frontend, and they share clojurescript code and a single deps.edn file and a single shadow-cljs.edn file. But they need to have separate node_modules directories.

I'd like to be able to specify different :npm-deps for different targets, e.g.:

 :target-defaults
 {:browser {:js-options {:js-package-dirs ["web/node_modules"]
                          :npm-deps {:install-dir "web"}}}
  :react-native {:js-options {:js-package-dirs ["mobile/node_modules"]
                              :npm-deps {:install-dir "mobile"}}}}

But it seems that :npm-deps is only accepted at the top level of the config.

@thheller
Copy link
Owner

Currently, this is tricky since the :npm-deps install runs once when shadow-cljs first starts. This is far before any actual builds are looked at or started. See #998

Most likely I will be removing the automatic install of :npm-deps entirely at some point. It has been nothing but a nuisance and has lots of quirks. Instead it'll probably become manual command, which you could then pass a directory to I guess.

So, something like npx shadow-cljs install-npm-deps --dir mobile or so.

Would that be a suitable fix? I mean its not impossible to look at build configs and running the install multiple times, I'm just skeptical of the automatic install given the problems it has.

@aiba
Copy link
Sponsor Contributor Author

aiba commented Jul 27, 2022

Yes, that would work great for my use case. If it's not too much trouble, it would also be handy to get a message or warning when running watch or compile, indicating that it may be necessary to re-run install-npm-deps command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants