Skip to content

Commit 1a020be

Browse files
authored
Ensure deterministic order for exports of hoisted functions (microsoft#443)
1 parent 0372c39 commit 1a020be

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

internal/transformers/commonjsmodule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func (tx *CommonJSModuleTransformer) transformCommonJSModule(node *ast.SourceFil
347347
// initialize exports for function declarations, e.g.:
348348
// exports.f = f;
349349
// function f() {}
350-
for f := range tx.currentModuleInfo.exportedFunctions.Keys() {
350+
for f := range tx.currentModuleInfo.exportedFunctions.Values() {
351351
statements = tx.appendExportsOfClassOrFunctionDeclaration(statements, f.AsNode())
352352
}
353353

internal/transformers/externalmoduleinfo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/microsoft/typescript-go/internal/ast"
77
"github.com/microsoft/typescript-go/internal/binder"
8+
"github.com/microsoft/typescript-go/internal/collections"
89
"github.com/microsoft/typescript-go/internal/core"
910
"github.com/microsoft/typescript-go/internal/printer"
1011
"github.com/microsoft/typescript-go/internal/stringutil"
@@ -15,7 +16,7 @@ type externalModuleInfo struct {
1516
exportSpecifiers core.MultiMap[string, *ast.ExportSpecifier] // Maps local names to their associated export specifiers (excludes reexports)
1617
exportedBindings core.MultiMap[*ast.Declaration, *ast.ModuleExportName] // Maps local declarations to their associated export aliases
1718
exportedNames []*ast.ModuleExportName // all exported names in the module, both local and re-exported, excluding the names of locally exported function declarations
18-
exportedFunctions core.Set[*ast.FunctionDeclarationNode] // all of the top-level exported function declarations
19+
exportedFunctions collections.OrderedSet[*ast.FunctionDeclarationNode] // all of the top-level exported function declarations
1920
exportEquals *ast.ExportAssignment // an export= declaration if one was present
2021
hasExportStarsToExportValues bool // whether this module contains export*
2122
}

0 commit comments

Comments
 (0)