-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Improve support for node library/application package management #3817
Comments
Please refer to This link |
Hey @reajuria, thanks for the tip! I'm currently not able to test this, so I'm gonna ask instead. When I use this method, do I have to populate the Because if it doesn't, it'd mean that I'd still have to manage |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Description
Also described in this reddit comment.
Recently I migrated some of my company's code to an NX repo. It consists of:
Bundling and dockerizing a front-end application is a piece of cake - bundle and you're done.
On the other hand, bundling and dockerizing a node app is a pain.
Since an NX repo only has a single
package.json
, you need a different mechanism for bundling your dependencies, an example for such is described in this issue, and in issues linked to it.In the reddit post, I described a problem I had which made me do an even uglier workaround, to do get a
node_modules
directory in my code, since a library I used (jaeger-client
) relied to reading an asset from there.What I ended up doing was save a list of all dependencies that are specific to node libraries and apps (which is still more than you need, but much less than you would get otherwise) and generate a
package.json
using this list.Motivation
I think that there should be a more standard way to bundle/build node applications, such that supports
node_modules
cleanly. Running the applications locally could work the same as it does now, but another option to bundle it with a proper node_modules should be available.Suggested Implementation
One thing I thought of would be to generate a
package.json
as part of the bundling.In order to generate the
package.json
, you'd have each node library and application specify its distinct dependencies in a configuration file. It would be just the names of the dependencies, since the versions are specified in the repo-levelpackage.json
.In the build process, since dependencies are known, you could collect all the dependencies from all libraries used, and the built application, and combine it into a
package.json
.This
package.json
is then easily used by a Dockerfile that would copy thepackage.json
, thennpm install
(ornpm ci
if we can generate a lock file as well), and then copy thedist
files themselves.Alternate Implementations
I can't think of any non-hacky solutions, but it would revolve around libraries specifying their dependencies, and later a more compact
node_modules
is created.If you could take the actual
node_modules
of the repo, copy it, and curate it to contain only the needed dependencies.I don't know how the curation process would work, but I also don't know if this would work well with docker layer caching 🤷🏻♂️
The text was updated successfully, but these errors were encountered: