@@ -41,13 +41,6 @@ type linkerContext struct {
41
41
// This helps avoid an infinite loop when matching imports to exports
42
42
cycleDetector []importTracker
43
43
44
- // We may need to refer to the CommonJS "module" symbol for exports
45
- unboundModuleRef js_ast.Ref
46
-
47
- // We may need to refer to the "__esm" and/or "__commonJS" runtime symbols
48
- cjsRuntimeRef js_ast.Ref
49
- esmRuntimeRef js_ast.Ref
50
-
51
44
// This represents the parallel computation of source map related data.
52
45
// Calling this will block until the computation is done. The resulting value
53
46
// is shared between threads and must be treated as immutable.
@@ -56,6 +49,13 @@ type linkerContext struct {
56
49
// This is passed to us from the bundling phase
57
50
uniqueKeyPrefix string
58
51
uniqueKeyPrefixBytes []byte // This is just "uniqueKeyPrefix" in byte form
52
+
53
+ // We may need to refer to the CommonJS "module" symbol for exports
54
+ unboundModuleRef js_ast.Ref
55
+
56
+ // We may need to refer to the "__esm" and/or "__commonJS" runtime symbols
57
+ cjsRuntimeRef js_ast.Ref
58
+ esmRuntimeRef js_ast.Ref
59
59
}
60
60
61
61
type partRange struct {
@@ -72,11 +72,6 @@ type chunkInfo struct {
72
72
filesWithPartsInChunk map [uint32 ]bool
73
73
entryBits helpers.BitSet
74
74
75
- // This information is only useful if "isEntryPoint" is true
76
- isEntryPoint bool
77
- sourceIndex uint32 // An index into "c.sources"
78
- entryPointBit uint // An index into "c.graph.EntryPoints"
79
-
80
75
// For code splitting
81
76
crossChunkImports []chunkImport
82
77
@@ -94,11 +89,6 @@ type chunkInfo struct {
94
89
// If non-empty, this chunk needs to generate an external legal comments file.
95
90
externalLegalComments []byte
96
91
97
- // When this chunk is initially generated in isolation, the output pieces
98
- // will contain slices of the output with the unique keys of other chunks
99
- // omitted.
100
- intermediateOutput intermediateOutput
101
-
102
92
// This contains the hash for just this chunk without including information
103
93
// from the hashes of other chunks. Later on in the linking process, the
104
94
// final hash for this chunk will be constructed by merging the isolated
@@ -109,7 +99,18 @@ type chunkInfo struct {
109
99
// Other fields relating to the output file for this chunk
110
100
jsonMetadataChunkCallback func (finalOutputSize int ) helpers.Joiner
111
101
outputSourceMap sourcemap.SourceMapPieces
112
- isExecutable bool
102
+
103
+ // When this chunk is initially generated in isolation, the output pieces
104
+ // will contain slices of the output with the unique keys of other chunks
105
+ // omitted.
106
+ intermediateOutput intermediateOutput
107
+
108
+ // This information is only useful if "isEntryPoint" is true
109
+ entryPointBit uint // An index into "c.graph.EntryPoints"
110
+ sourceIndex uint32 // An index into "c.sources"
111
+ isEntryPoint bool
112
+
113
+ isExecutable bool
113
114
}
114
115
115
116
type chunkImport struct {
@@ -141,15 +142,15 @@ type outputPiece struct {
141
142
}
142
143
143
144
type intermediateOutput struct {
145
+ // If the chunk has references to other chunks, then "pieces" contains the
146
+ // contents of the chunk and "joiner" should not be used. Another joiner
147
+ // will have to be constructed later when merging the pieces together.
148
+ pieces []outputPiece
149
+
144
150
// If the chunk doesn't have any references to other chunks, then "pieces" is
145
151
// nil and "joiner" contains the contents of the chunk. This is more efficient
146
152
// because it avoids doing a join operation twice.
147
153
joiner helpers.Joiner
148
-
149
- // Otherwise, "pieces" contains the contents of the chunk and "joiner" should
150
- // not be used. Another joiner will have to be constructed later when merging
151
- // the pieces together.
152
- pieces []outputPiece
153
154
}
154
155
155
156
type chunkRepr interface { isChunk () }
@@ -162,10 +163,10 @@ type chunkReprJS struct {
162
163
partsInChunkInOrder []partRange
163
164
164
165
// For code splitting
165
- crossChunkPrefixStmts []js_ast.Stmt
166
- crossChunkSuffixStmts []js_ast.Stmt
167
166
exportsToOtherChunks map [js_ast.Ref ]string
168
167
importsFromOtherChunks map [uint32 ]crossChunkImportItemArray
168
+ crossChunkPrefixStmts []js_ast.Stmt
169
+ crossChunkSuffixStmts []js_ast.Stmt
169
170
}
170
171
171
172
type chunkReprCSS struct {
@@ -994,8 +995,8 @@ func (c *linkerContext) computeCrossChunkDependencies(chunks []chunkInfo) {
994
995
}
995
996
996
997
type crossChunkImport struct {
997
- chunkIndex uint32
998
998
sortedImportItems crossChunkImportItemArray
999
+ chunkIndex uint32
999
1000
}
1000
1001
1001
1002
// This type is just so we can use Go's native sort function
@@ -1031,8 +1032,8 @@ func (c *linkerContext) sortedCrossChunkImports(chunks []chunkInfo, importsFromO
1031
1032
}
1032
1033
1033
1034
type crossChunkImportItem struct {
1034
- ref js_ast.Ref
1035
1035
exportAlias string
1036
+ ref js_ast.Ref
1036
1037
}
1037
1038
1038
1039
// This type is just so we can use Go's native sort function
@@ -2128,9 +2129,9 @@ const (
2128
2129
)
2129
2130
2130
2131
type matchImportResult struct {
2132
+ alias string
2131
2133
kind matchImportKind
2132
2134
namespaceRef js_ast.Ref
2133
- alias string
2134
2135
sourceIndex uint32
2135
2136
nameLoc logger.Loc // Optional, goes with sourceIndex, ignore if zero
2136
2137
otherSourceIndex uint32
@@ -2859,8 +2860,8 @@ func (c *linkerContext) findImportedCSSFilesInJSOrder(entryPoint uint32) (order
2859
2860
// traversal order is B D C A.
2860
2861
func (c * linkerContext ) findImportedFilesInCSSOrder (entryPoints []uint32 ) (externalOrder []externalImportCSS , internalOrder []uint32 ) {
2861
2862
type externalImportsCSS struct {
2862
- unconditional bool
2863
2863
conditions [][]css_ast.Token
2864
+ unconditional bool
2864
2865
}
2865
2866
2866
2867
visited := make (map [uint32 ]bool )
@@ -4893,13 +4894,12 @@ func (c *linkerContext) generateGlobalNamePrefix() string {
4893
4894
type compileResultCSS struct {
4894
4895
css_printer.PrintResult
4895
4896
4896
- sourceIndex uint32
4897
-
4898
4897
// This is the line and column offset since the previous CSS string
4899
4898
// or the start of the file if this is the first CSS string.
4900
4899
generatedOffset sourcemap.LineColumnOffset
4901
4900
4902
- hasCharset bool
4901
+ sourceIndex uint32
4902
+ hasCharset bool
4903
4903
}
4904
4904
4905
4905
func (c * linkerContext ) generateChunkCSS (chunks []chunkInfo , chunkIndex int , chunkWaitGroup * sync.WaitGroup ) {
0 commit comments