This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
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.
This follows up on @tivac's suggestion in rollup/rollup#658 – rather than tracking which CommonJS features are used and injecting them haphazardly using the
intro
hook, modules importcommonjsHelpers
. This is cleaner, and will allow the results of the transformation to be cached.There is a wrinkle however: the synthetic ID used for the helpers goes through the same resolution process as any other ID. Since in this case that frequently means rollup-plugin-node-resolve, we end up passing trying to resolve whatever ID we use with the Node resolution algorithm, which will obviously fail.
So I'm proposing we adopt the following convention: plugins that generate synthetic helper modules, like this one, should use the null character (
\0
) in the ID. Plugins that implementresolveId
should ignore IDs with the null character. (The reason I'm suggesting NUL is that it's invalid in filenames on both *nix and Windows.)I've already taken the liberty of updating
createFilter
and node-resolve.Any thoughts @rollup/collaborators?
Apologies for the bad git discipline, I managed to roll some extra stuff in here 😕