Fix alias of module.exports->exports->IIFE#27992
Merged
Merged
Conversation
In JS, when you assign `module.exports = exports` and the entire module is
wrapped in an IIFE, the resulting `export=` symbol, after following
aliases, is the module itself. This results in trying to merge the
file's exports with itself inside `getCommonJsExportEquals`, since it
thinks that it has found new exports, possibly in an object literal,
that need to be merged with the file's exports.
For example:
```js
(function() {
exports.a = 1
module.exports = exports
})()
```
sandersn
commented
Oct 19, 2018
| if (moduleSymbol) { | ||
| const exportEquals = resolveSymbol(moduleSymbol.exports!.get(InternalSymbolName.ExportEquals), dontResolveAlias); | ||
| const exported = getCommonJsExportEquals(exportEquals, moduleSymbol); | ||
| return getMergedSymbol(exported) || moduleSymbol; |
Member
Author
There was a problem hiding this comment.
This just makes it easier to read -- I found the previous found obtuse and too nested.
sheetalkamat
approved these changes
Oct 19, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In JS, when you assign
module.exports = exportsand the entire module iswrapped in an IIFE, the resulting
export=symbol, after followingaliases, is the module itself. This results in trying to merge the
file's exports with itself inside
getCommonJsExportEquals, since itthinks that it has found new exports, possibly in an object literal,
that need to be merged with the file's exports.
For example:
Fixes #27365