forked from nodejs/import-in-the-middle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
export * from 'module'
ESM syntax
This change adds support for modules that export entities through the `export * from 'module'` ESM syntax. This resolves issue nodejs#31.
- Loading branch information
1 parent
5845e21
commit 20e8b5c
Showing
6 changed files
with
80 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import bar from './something.mjs' | ||
export default bar | ||
export * from './fantasia.mjs' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function sayName() { | ||
return 'Moon Child' | ||
} | ||
|
||
export const Morla = 'Ancient one' |
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,20 @@ | ||
import { strictEqual } from 'assert' | ||
import Hook from '../../index.js' | ||
Hook((exports, name) => { | ||
if (/bundle\.mjs/.test(name) === false) return | ||
|
||
const bar = exports.default | ||
exports.default = function wrappedBar() { | ||
return bar() + '-wrapped' | ||
} | ||
|
||
const sayName = exports.sayName | ||
exports.sayName = function wrappedSayName() { | ||
return `Bastion: "${sayName()}"` | ||
} | ||
}) | ||
|
||
import { default as bar, sayName } from '../fixtures/bundle.mjs' | ||
|
||
strictEqual(bar(), '42-wrapped') | ||
strictEqual(sayName(), 'Bastion: "Moon Child"') |