feat(build): Add rollup config for Node bundles #5142
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we have the ability to create rollup configs for two types of bundles, both intended for use in the browser: standalone SDKs (like browser or vue) and SDK add-ons (like integrations). This adds a third option, namely bundles for Node. Though it's clearly a less-common use case, there are Node situations (like serverless functions) where having a single, fully-treeshaken file could be helpful. (Indeed, the reason for this addition is our AWS lambda layer, and a desire for a simpler and more robust way to make sure that it includes all of the necessary dependencies without a lot of unnecessary extras.)
Adding this option required a small amount of refactoring - exchanging a boolean indicator of bundle type for a string option, and switching to a(n admittedly slightly hacky) sorting mechanism for ordering plugins rather than manually inserting specific plugins at various spots in the array. (This was necessary because adding the node config meant shifting plugins around in such a way that it became impossible to merge plugin arrays by simple concatenation. As a bonus side effect, it allowed the insertion logic to be removed as well.)