-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default interop missing when importing a CommonJS module (#7991)
* Add test case for missing default interop for commonjs import * Add interopDefault helper if the dep kind is require * Add test case for 'static' hybrid interop * Update test description Co-authored-by: Eric Eldredge <lettertwo@gmail.com> * Update test dirname Co-authored-by: Eric Eldredge <lettertwo@gmail.com> * Fix dirname * Update packages/core/integration-tests/test/scope-hoisting.js Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> * Store import kinds in imported symbols and only set symbols when kinds match while iterating * Remove unnecessary conditions * Only set symbols for esm deps when iterating through hoist_result.re_exports * Add comments for new dep Map structure * Key by specifier + specifierType instead of keeping an array of deps * Make import specifiers unique in packager * Track specifier types in wrapped_requires * Don't append specifier types to placeholders, since they are already hashed with DependencyKind's * Fix hoist unit tests Co-authored-by: lettertwo <lettertwo@gmail.com> Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
- Loading branch information
1 parent
1beacec
commit 99cf505
Showing
8 changed files
with
152 additions
and
59 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...ation-tests/test/integration/scope-hoisting/commonjs/interop-commonjs-hybrid-dynamic/a.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import b from './b'; | ||
export const foo = b.foo; // <-- missing default interop | ||
export const bar = (() => require('./b').foo)(); | ||
|
||
output = foo + bar; |
1 change: 1 addition & 0 deletions
1
...ation-tests/test/integration/scope-hoisting/commonjs/interop-commonjs-hybrid-dynamic/b.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {foo: 1}; |
5 changes: 5 additions & 0 deletions
5
...e/integration-tests/test/integration/scope-hoisting/commonjs/interop-commonjs-hybrid/a.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import b from './b'; | ||
const foo = b.foo; | ||
const bar = require('./b').foo; | ||
|
||
output = foo + bar; |
1 change: 1 addition & 0 deletions
1
...e/integration-tests/test/integration/scope-hoisting/commonjs/interop-commonjs-hybrid/b.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {foo: 1}; |
This file contains 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
This file contains 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
Oops, something went wrong.