-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure reexported namespaces do not prevent creation of default expor…
…t helpers (#5466) * Add test * Use better variable name * Ensure reexported namespaces do not prevent creation of default export helpers
- Loading branch information
1 parent
2fdfe1c
commit cfbaaaa
Showing
7 changed files
with
129 additions
and
16 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
27 changes: 27 additions & 0 deletions
27
test/function/samples/external-namespace-and-default-reexport-compat/_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,27 @@ | ||
const assert = require('node:assert'); | ||
|
||
module.exports = defineTest({ | ||
description: 'reexports both a namespace and the default export when using compat interop', | ||
options: { | ||
external: true, | ||
output: { exports: 'named', interop: 'compat' } | ||
}, | ||
context: { | ||
require: id => { | ||
if (id === 'external') { | ||
return { | ||
__esModule: true, | ||
default: 'default', | ||
foo: 'foo' | ||
}; | ||
} | ||
throw new Error(`Cannot find module ${id}`); | ||
} | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
default: 'default', | ||
foo: 'foo' | ||
}); | ||
} | ||
}); |
2 changes: 2 additions & 0 deletions
2
test/function/samples/external-namespace-and-default-reexport-compat/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,2 @@ | ||
export * from "external"; | ||
export { default } from "external"; |
33 changes: 33 additions & 0 deletions
33
test/function/samples/external-namespace-and-default-reexport-compat2/_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,33 @@ | ||
const assert = require('node:assert'); | ||
|
||
module.exports = defineTest({ | ||
description: | ||
'reexports both a namespace, the namespace as a name and the default export when using compat interop', | ||
options: { | ||
external: true, | ||
output: { exports: 'named', interop: 'compat' } | ||
}, | ||
context: { | ||
require: id => { | ||
if (id === 'external') { | ||
return { | ||
__esModule: true, | ||
default: 'default', | ||
foo: 'foo' | ||
}; | ||
} | ||
throw new Error(`Cannot find module ${id}`); | ||
} | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
default: 'default', | ||
foo: 'foo', | ||
external: { | ||
__esModule: true, | ||
default: 'default', | ||
foo: 'foo' | ||
} | ||
}); | ||
} | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/function/samples/external-namespace-and-default-reexport-compat2/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,3 @@ | ||
export * from "external"; | ||
export * as external from 'external'; | ||
export { default } from "external"; |
34 changes: 34 additions & 0 deletions
34
test/function/samples/external-namespace-and-default-reexport-compat3/_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,34 @@ | ||
const assert = require('node:assert'); | ||
|
||
module.exports = defineTest({ | ||
description: 'reexports both a namespace and the default export when using compat interop', | ||
options: { | ||
external: true, | ||
output: { exports: 'named', interop: 'compat' } | ||
}, | ||
context: { | ||
require: id => { | ||
if (id === 'external') { | ||
return { | ||
__esModule: true, | ||
default: 'default', | ||
foo: 'foo' | ||
}; | ||
} | ||
throw new Error(`Cannot find module ${id}`); | ||
} | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
default: 'default', | ||
foo: 'foo', | ||
wrappedExternal: { | ||
external: { | ||
__esModule: true, | ||
default: 'default', | ||
foo: 'foo' | ||
} | ||
} | ||
}); | ||
} | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/function/samples/external-namespace-and-default-reexport-compat3/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,5 @@ | ||
export * from 'external'; | ||
import * as external from "external"; | ||
|
||
export const wrappedExternal = { external }; | ||
export { default } from 'external'; |