Skip to content

Commit cc2ba49

Browse files
committed
fix: some exports not working
1 parent c4ab321 commit cc2ba49

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/index.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,28 @@ const transformer = (_: ts.Program) => (context: ts.TransformationContext) => (
127127
if (!node.moduleSpecifier || !ts.isStringLiteral(node.moduleSpecifier)) {
128128
return node;
129129
}
130-
if (
131-
!node.exportClause &&
132-
!compilerOptions.isolatedModules &&
133-
!resolver.moduleExportsSomeValue(node.moduleSpecifier)
134-
) {
135-
return node;
136-
}
137-
if (node.exportClause && resolver.isValueAliasDeclaration(node)) {
138-
return node;
139-
}
140130

141131
const file = bindModuleToFile(node.moduleSpecifier.text);
142132
if (!file) {
143133
return node;
144134
}
145135
const fileLiteral = ts.createLiteral(file);
146136

137+
if (
138+
(!node.exportClause &&
139+
!compilerOptions.isolatedModules &&
140+
!resolver.moduleExportsSomeValue(node.moduleSpecifier)) ||
141+
(node.exportClause && resolver.isValueAliasDeclaration(node))
142+
) {
143+
return ts.updateExportDeclaration(
144+
node,
145+
node.decorators,
146+
node.modifiers,
147+
node.exportClause,
148+
fileLiteral
149+
);
150+
}
151+
147152
const exportClause = ts.visitNode(
148153
node.exportClause,
149154
visitNamedExports as any,

tests/core/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { subs, sum, NoRuntimecodeHere } from "@utils";
1+
export { sum } from "@utils";
2+
import { subs, NoRuntimecodeHere } from "@utils";
23
import "@circular/b";
34
import { A } from "@circular/a";
45

56
const n: NoRuntimecodeHere = null as any;
67

7-
sum(2, 3);
88
subs(2, 3);
99
const a = new A("");

0 commit comments

Comments
 (0)