Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not expose the synthetic namespace export in namespaces
- Loading branch information
1 parent
aee44fe
commit 33b5dc9
Showing
15 changed files
with
85 additions
and
13 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from 'external1'; | ||
export * from './synthetic'; | ||
export * from 'external2'; | ||
export const __synthetic = { module: 'reexport' }; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export const __synthetic = { foo: 'foo' }; | ||
export const __synthetic = { module: 'synthetic' }; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from 'external1'; | ||
export * from './synthetic'; | ||
export * from 'external2'; | ||
export const __synthetic = { module: 'reexport' }; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export const __synthetic = { foo: 'foo' }; | ||
export const __synthetic = { module: 'synthetic' }; |
39 changes: 39 additions & 0 deletions
39
test/function/samples/synthetic-named-export-entry/_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,39 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
const ID_OVERRIDE = path.join(__dirname, 'override.js'); | ||
const ID_NOOVERRIDE = path.join(__dirname, 'noOverride.js'); | ||
const ID_HIDDENNAMESPACE = path.join(__dirname, 'hiddenNamespace.js'); | ||
|
||
module.exports = { | ||
description: 'does not expose synthetic named exports on entry points', | ||
options: { | ||
plugins: [ | ||
{ | ||
transform(code, id) { | ||
switch (id) { | ||
case ID_MAIN: | ||
return { syntheticNamedExports: 'synthMain' }; | ||
case ID_OVERRIDE: | ||
return { syntheticNamedExports: 'synthOverride' }; | ||
case ID_NOOVERRIDE: | ||
return { syntheticNamedExports: 'synthNoOverride' }; | ||
case ID_HIDDENNAMESPACE: | ||
return { syntheticNamedExports: 'synthHiddenNamespace' }; | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
explicitReexport: { override: true }, | ||
hiddenNamespace: 'hiddenNamespace', | ||
main: 'main', | ||
noOverride: 'noOverride', | ||
override: 'override', | ||
synthHiddenNamespace: 'hidden in override', | ||
synthOverride: 'overridden' | ||
}); | ||
} | ||
}; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/synthetic-named-export-entry/hiddenNamespace.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,2 @@ | ||
export const hiddenNamespace = 'hiddenNamespace'; | ||
export const synthHiddenNamespace = { hiddenNamespace: true }; |
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 main = 'main'; | ||
export const synthMain = { main: true }; | ||
export * from './noOverride.js'; | ||
export * from './override.js'; | ||
export * from './hiddenNamespace.js'; | ||
export const synthOverride = 'overridden'; | ||
export { synthOverride as explicitReexport } from './override.js'; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/synthetic-named-export-entry/noOverride.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,2 @@ | ||
export const noOverride = 'noOverride'; | ||
export const synthNoOverride = { noOverride: true }; |
3 changes: 3 additions & 0 deletions
3
test/function/samples/synthetic-named-export-entry/override.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 override = 'override'; | ||
export const synthOverride = { override: true }; | ||
export const synthHiddenNamespace = 'hidden in override'; |
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