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
Sanitize chunk names to allow for virtually created chunks #2590
Conversation
8e0e0ce
to
f7d4562
Compare
@@ -977,10 +974,10 @@ export default class Chunk { | |||
|
|||
private computeChunkName(): string { | |||
if (this.facadeModule !== null && this.facadeModule.chunkAlias) { | |||
return this.facadeModule.chunkAlias; | |||
return sanitizeFileName(this.facadeModule.chunkAlias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be good to ensure that chunkAlias
is sanitized at the time it is set on the modules, instead of at this stage. Strictly speaking, we should probably throw for invalid scenarios over sanitizing as this is user input? But it's very much a nit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact no, we should not sanitize the id on the module. The reason is that by convention, some plugins (such as rollup-plugin-multi-entry) create virtual modules with an id that starts with a \0
to signal that other plugins should ignore this module for e.g. loading and transformation. Thus we need to keep the module id unsanitized to not break plugins. The chunk id, however, is what is written to disk and is something we can choose rather freely.
f7d4562
to
b3a9330
Compare
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This will allow plugins to use virtual modules (i.e. starting with a
\0
) as entry points. This will enablerollup-plugin-multi-entry
to work with rollup@1.0 as it creates such a virtual entry point,.