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

Sanitize chunk names to allow for virtually created chunks #2590

Merged
merged 1 commit into from Dec 15, 2018

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

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 enable rollup-plugin-multi-entry to work with rollup@1.0 as it creates such a virtual entry point,.

@lukastaegert lukastaegert changed the title Sanitizes chunk names to allow for virtually created chunks Sanitize chunk names to allow for virtually created chunks Dec 11, 2018
@lukastaegert lukastaegert force-pushed the sanitize-chunk-names branch 3 times, most recently from 8e0e0ce to f7d4562 Compare December 12, 2018 06:23
@lukastaegert lukastaegert added this to In progress in Release 1.0.0 via automation Dec 12, 2018
@lukastaegert lukastaegert moved this from In progress to In Review in Release 1.0.0 Dec 12, 2018
@@ -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);
Copy link
Contributor

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.

Copy link
Member Author

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.

@lukastaegert lukastaegert merged commit 551654c into master Dec 15, 2018
Release 1.0.0 automation moved this from In Review to Done Dec 15, 2018
@lukastaegert lukastaegert deleted the sanitize-chunk-names branch December 15, 2018 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Release 1.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants