Retain typescript export-from-source (#10167)
This commit is contained in:
parent
106bb41d47
commit
bff79e198a
@ -98,6 +98,7 @@ export default declare(
|
||||
ExportNamedDeclaration(path) {
|
||||
// remove export declaration if it's exporting only types
|
||||
if (
|
||||
!path.node.source &&
|
||||
path.node.specifiers.length > 0 &&
|
||||
!path.node.specifiers.find(exportSpecifier =>
|
||||
path.scope.hasOwnBinding(exportSpecifier.local.name),
|
||||
@ -109,7 +110,10 @@ export default declare(
|
||||
|
||||
ExportSpecifier(path) {
|
||||
// remove type exports
|
||||
if (!path.scope.hasOwnBinding(path.node.local.name)) {
|
||||
if (
|
||||
!path.parent.source &&
|
||||
!path.scope.hasOwnBinding(path.node.local.name)
|
||||
) {
|
||||
path.remove();
|
||||
}
|
||||
},
|
||||
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/default-literal/input.mjs
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/default-literal/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default "foo";
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/default-literal/output.mjs
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/default-literal/output.mjs
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default "foo";
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/export-from/input.mjs
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/export-from/input.mjs
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { bar } from './bar';
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/export-from/output.mjs
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/exports/export-from/output.mjs
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { bar } from './bar';
|
||||
Loading…
x
Reference in New Issue
Block a user