-
Notifications
You must be signed in to change notification settings - Fork 28
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 (#43)
This change adds support for modules that export entities through the `export * from 'module'` ESM syntax. This resolves issue #31.
- Loading branch information
1 parent
9d1f3c4
commit 5ec0576
Showing
10 changed files
with
142 additions
and
14 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
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,7 @@ | ||
export const a = 'a' | ||
|
||
export function aFunc() { | ||
return a | ||
} | ||
|
||
export * from './foo.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const b = 'b' | ||
|
||
export function bFunc() { | ||
return b | ||
} |
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 @@ | ||
import bar from './something.mjs' | ||
export default bar | ||
export * from './a.mjs' | ||
export * from './b.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 foo() { | ||
return 'foo' | ||
} | ||
|
||
export * from './lib/baz.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function baz() { | ||
return 'baz' | ||
} |
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,32 @@ | ||
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 foo = exports.foo | ||
exports.foo = function wrappedFoo() { | ||
return foo() + '-wrapped' | ||
} | ||
|
||
const aFunc = exports.aFunc | ||
exports.aFunc = function wrappedAFunc() { | ||
return aFunc() + '-wrapped' | ||
} | ||
}) | ||
|
||
import { | ||
default as bar, | ||
foo, | ||
aFunc, | ||
baz | ||
} from '../fixtures/bundle.mjs' | ||
|
||
strictEqual(bar(), '42-wrapped') | ||
strictEqual(foo(), 'foo-wrapped') | ||
strictEqual(aFunc(), 'a-wrapped') | ||
strictEqual(baz(), 'baz') |