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

Support bundleDependencies with nx release #21789

Open
1 task
kentcdodds opened this issue Feb 12, 2024 · 5 comments
Open
1 task

Support bundleDependencies with nx release #21789

kentcdodds opened this issue Feb 12, 2024 · 5 comments

Comments

@kentcdodds
Copy link

Description

I would like nx release to support bundleDependencies.

Because in npm workspaces, some of the node_modules are hoisted to the top directory, when running the publish script those aren't in the directory where you're publishing so they won't be bundled.

Motivation

Without this feature then it violates the principle of least surprise because bundleDependencies is a feature of npm publish and it seems like this would be a missing feature.

Suggested Implementation

Make it easy to copy all the appropriate node_modules into the proper directory before publishing

Alternate Implementations

I'm going to script this myself (wish me luck), but having something built-in would be nice!

@kentcdodds
Copy link
Author

In case it's helpful, here's my release script which now should handle this properly: https://github.com/epicweb-dev/kcdshop/blob/42a29726911ecfc3b538079635042e5e87bfc86d/other/release.ts

I'm sure I'm missing things, but maybe this will work ok? One downside is it makes my releases take much longer. So it would be cool if I were more surgical about which packages get copied, but that would require tracing dependencies so that would be tricky.

I do think that I can improve this by only copying things over if the package has bundleDependencies configured...

@JamesHenry JamesHenry self-assigned this Feb 13, 2024
@JamesHenry
Copy link
Collaborator

I'll need to think more about this one but my instinctive reaction is that npm should support this within npm workspaces, rather than it being an Nx specific concern.

There is a long standing issue open about it: npm/cli#3466

Therefore, at least initially, having it be something that is part of a release script does seem to make sense to me (and note, this is particularly necessary for the use-case of publishing from "dist" (in your case the publish/ directory), for some other cases of publishing from source, perhaps all the bundledDependencies would already be in the project directory, although again because of npm workspaces being a thing, not necessarily...)

With that said, perhaps we could do more by providing the copying utility from the programmatic API so that folks could trivially wire it up instead of having to reinvent what you have done here.

I'll keep you posted!

@kentcdodds
Copy link
Author

Thanks!

Copy link

This issue has been automatically marked as stale because it hasn't had any activity for 6 months.
Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore.
If at this point, this is still an issue, please respond with updated information.
It will be closed in 21 days if no further activity occurs.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Aug 15, 2024
@kentcdodds
Copy link
Author

I'd still love this

@github-actions github-actions bot removed the stale label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants