-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commonjs): inject __esModule marker into ES namespaces
- Loading branch information
1 parent
55a9cb2
commit 87623e3
Showing
9 changed files
with
471 additions
and
141 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
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
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/function/import-esm-with-interop/_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: 'adds the __esModule property when requiring an ES module and support live-bindings' | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/commonjs/test/fixtures/function/import-esm-with-interop/lib.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,9 @@ | ||
/* eslint-disable import/no-mutable-exports */ | ||
let foo = 'foo'; | ||
let bar = 'bar'; | ||
export { foo as default, bar }; | ||
|
||
export function update(newFoo, newBar) { | ||
foo = newFoo; | ||
bar = newBar; | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/commonjs/test/fixtures/function/import-esm-with-interop/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,15 @@ | ||
/* eslint-disable */ | ||
var lib = require('./lib.js'); | ||
|
||
function _interopDefault(e) { | ||
return e && e.__esModule ? e : { default: e }; | ||
} | ||
|
||
var lib__default = /*#__PURE__*/_interopDefault(lib); | ||
t.is(lib__default['default'], 'foo') | ||
t.is(lib.bar, 'bar') | ||
|
||
lib.update('newFoo', 'newBar'); | ||
t.is(lib__default['default'], 'newFoo') | ||
t.is(lib.bar, 'newBar') | ||
|
Oops, something went wrong.