Open kentcdodds opened 8 months ago
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...
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: https://github.com/npm/cli/issues/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!
Thanks!
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! 🙏
I'd still love this
Description
I would like
nx release
to supportbundleDependencies
.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 ofnpm 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 publishingAlternate Implementations
I'm going to script this myself (wish me luck), but having something built-in would be nice!