-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commonjs): produce code which works when __esModule is already de…
…fined (#1379)
- Loading branch information
1 parent
b46cb29
commit dcb86a9
Showing
12 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
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
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/function/esm-with-esmodule/_config.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,3 @@ | ||
module.exports = { | ||
description: 'produces working code when esm module with __esModule property set is being bundled' | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/function/esm-with-esmodule/esm.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,3 @@ | ||
export const foo = 'foo'; | ||
|
||
export const __esModule = true; |
4 changes: 4 additions & 0 deletions
4
packages/commonjs/test/fixtures/function/esm-with-esmodule/main.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,4 @@ | ||
const esm = require('./esm.js'); | ||
|
||
t.is(esm.foo, 'foo'); | ||
t.is(esm.__esModule, true); |
6 changes: 6 additions & 0 deletions
6
packages/commonjs/test/fixtures/function/transform-mixed-modules-esmodule/_config.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,6 @@ | ||
module.exports = { | ||
description: 'transforms mixed modules when CommonJS module contains __esModule property', | ||
pluginOptions: { | ||
transformMixedEsModules: true | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/function/transform-mixed-modules-esmodule/dep.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,3 @@ | ||
const other = require('./other.js'); | ||
|
||
export { other }; |
6 changes: 6 additions & 0 deletions
6
packages/commonjs/test/fixtures/function/transform-mixed-modules-esmodule/main.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,6 @@ | ||
import { other } from './dep.js'; | ||
|
||
const dep = require('./dep.js'); | ||
|
||
t.is(other, 'other'); | ||
t.deepEqual(dep, { other: 'other' }); |
4 changes: 4 additions & 0 deletions
4
packages/commonjs/test/fixtures/function/transform-mixed-modules-esmodule/other.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,4 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
module.exports = 'other'; |
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
Binary file not shown.
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
Binary file not shown.