diff --git a/tools/mujs/lib/compiler/transform.ts b/tools/mujs/lib/compiler/transform.ts index ceb153a75..a2882378b 100644 --- a/tools/mujs/lib/compiler/transform.ts +++ b/tools/mujs/lib/compiler/transform.ts @@ -390,8 +390,12 @@ export class Transformer { this.currentModuleMembers[member.name.ident] = member; } else { - // This is a top-level module statement; place it into the module initializer. - statements.push(element); + // This is a top-level module statement; place it into the module initializer. Note that we + // skip empty statements just to avoid superfluously polluting the module with initializers. + let stmt = element; + if (stmt.kind !== ast.emptyStatementKind) { + statements.push(stmt); + } } } } diff --git a/tools/mujs/tests/output/modules/export/Mu.out.json b/tools/mujs/tests/output/modules/export/Mu.out.json index 71d91529c..0afb35716 100644 --- a/tools/mujs/tests/output/modules/export/Mu.out.json +++ b/tools/mujs/tests/output/modules/export/Mu.out.json @@ -287,9 +287,6 @@ "body": { "kind": "Block", "statements": [ - { - "kind": "EmptyStatement" - }, { "kind": "BinaryOperatorExpression", "left": {