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

Support sideEffect: false with CommonJS #1770

Merged
merged 1 commit into from
Jul 22, 2018
Merged

Conversation

fathyb
Copy link
Contributor

@fathyb fathyb commented Jul 21, 2018

Part of the fixes for #1699.

We currently can't require a module with sideEffects: false. This PR adds a $require$NAME entry to cacheData.imports so we can treat require like it is a wildcard import.

}

asset.cacheData.imports['$require$' + source] = [source, '*'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially conflict with a real import, right? e.g. import $require$foo from './foo'

Copy link
Contributor Author

@fathyb fathyb Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, in imports we would use $id$import$$require$foo as key :

asset.cacheData.imports = {
  "$require$foo": ['foo', '*'],
  "$id$import$$require$foo": ['./foo', 'default']
}

or is there another place where it would conflict?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right...

@devongovett devongovett merged commit f3a43a8 into master Jul 22, 2018
@devongovett devongovett deleted the fix/side-effect-cjs branch July 22, 2018 00:25
@rafaelrinaldi
Copy link

Awesome work, thank you for your efforts.

devongovett pushed a commit that referenced this pull request Oct 15, 2018
devongovett pushed a commit that referenced this pull request Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants