X Tutup
Skip to content

Commit fe3a60d

Browse files
committed
Fix export all bug #927
1 parent 54569aa commit fe3a60d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/transformation/visitors/modules/export.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,20 @@ function transformExportAllFrom(context: TransformationContext, node: ts.ExportD
5151
const forKey = lua.createIdentifier("____exportKey");
5252
const forValue = lua.createIdentifier("____exportValue");
5353

54-
const body = lua.createBlock([
55-
lua.createAssignmentStatement(lua.createTableIndexExpression(createExportsIdentifier(), forKey), forValue),
54+
const ifBody = lua.createBlock([
55+
lua.createAssignmentStatement(
56+
lua.createTableIndexExpression(createExportsIdentifier(), lua.cloneIdentifier(forKey)),
57+
forValue
58+
),
5659
]);
5760

61+
const ifStatement = lua.createIfStatement(
62+
lua.createBinaryExpression(forKey, lua.createStringLiteral("default"), lua.SyntaxKind.InequalityOperator),
63+
ifBody
64+
);
65+
66+
const body = lua.createBlock([ifStatement]);
67+
5868
const pairsIdentifier = lua.createIdentifier("pairs");
5969
const forIn = lua.createForInStatement(
6070
body,

test/unit/modules/modules.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,17 @@ test("export default function with future reference", () => {
275275
.setReturnExport("result")
276276
.expectToMatchJsResult();
277277
});
278+
279+
test("export all does not include default", () => {
280+
util.testBundle`
281+
export * from "./module";
282+
`
283+
.addExtraFile(
284+
"module.ts",
285+
`
286+
export default true;
287+
export const foo = "bar";
288+
`
289+
)
290+
.expectToEqual({ foo: "bar" });
291+
});

0 commit comments

Comments
 (0)
X Tutup