diff --git a/internal/bundler/bundler.go b/internal/bundler/bundler.go index 06a4928b..ed550215 100644 --- a/internal/bundler/bundler.go +++ b/internal/bundler/bundler.go @@ -32,12 +32,12 @@ import ( "github.com/evanw/esbuild/internal/xxhash" ) -type entryPointKind uint8 +type EntryPointKind uint8 const ( - entryPointNone entryPointKind = iota - entryPointUserSpecified - entryPointDynamicImport + EntryPointNone EntryPointKind = iota + EntryPointUserSpecified + EntryPointDynamicImport ) type scannerFile struct { @@ -50,34 +50,34 @@ type scannerFile struct { jsonMetadataChunk string } -type linkerFile struct { - module graph.Module +type LinkerFile struct { + Module graph.Module // The minimum number of links in the module graph to get from an entry point // to this file - distanceFromEntryPoint uint32 + DistanceFromEntryPoint uint32 // This is true if this file has been marked as live by the tree shaking // algorithm. - isLive bool + IsLive bool // This holds all entry points that can reach this file. It will be used to // assign the parts in this file to a chunk. - entryBits helpers.BitSet + EntryBits helpers.BitSet // If "entryPointKind" is not "entryPointNone", this is the index of the // corresponding entry point chunk. - entryPointChunkIndex uint32 + EntryPointChunkIndex uint32 // This file is an entry point if and only if this is not "entryPointNone". // Note that dynamically-imported files are allowed to also be specified by // the user as top-level entry points, so some dynamically-imported files // may be "entryPointUserSpecified" instead of "entryPointDynamicImport". - entryPointKind entryPointKind + EntryPointKind EntryPointKind } -func (f *linkerFile) isEntryPoint() bool { - return f.entryPointKind != entryPointNone +func (f *LinkerFile) IsEntryPoint() bool { + return f.EntryPointKind != EntryPointNone } // This is data related to source maps. It's computed in parallel with linking @@ -1879,9 +1879,9 @@ func (b *Bundle) Compile(log logger.Log, options config.Options) ([]graph.Output options.OutputFormat = config.FormatESModule } - files := make([]linkerFile, len(b.files)) + files := make([]LinkerFile, len(b.files)) for i, file := range b.files { - files[i].module = file.module + files[i].Module = file.module } // Get the base path from the options or choose the lowest common ancestor of all entry points @@ -1987,7 +1987,7 @@ func (b *Bundle) Compile(log logger.Log, options config.Options) ([]graph.Output // deterministic given that the entry point order is deterministic, since the // returned order is the postorder of the graph traversal and import record // order within a given file is deterministic. -func findReachableFiles(files []linkerFile, entryPoints []entryMeta) []uint32 { +func findReachableFiles(files []LinkerFile, entryPoints []entryMeta) []uint32 { visited := make(map[uint32]bool) var order []uint32 var visit func(uint32) @@ -1997,10 +1997,10 @@ func findReachableFiles(files []linkerFile, entryPoints []entryMeta) []uint32 { if !visited[sourceIndex] { visited[sourceIndex] = true file := &files[sourceIndex] - if repr, ok := file.module.Repr.(*graph.JSRepr); ok && repr.CSSSourceIndex.IsValid() { + if repr, ok := file.Module.Repr.(*graph.JSRepr); ok && repr.CSSSourceIndex.IsValid() { visit(repr.CSSSourceIndex.GetIndex()) } - for _, record := range *file.module.Repr.ImportRecords() { + for _, record := range *file.Module.Repr.ImportRecords() { if record.SourceIndex.IsValid() { visit(record.SourceIndex.GetIndex()) } diff --git a/internal/bundler/debug.go b/internal/bundler/debug.go index e8540e14..6173e09c 100644 --- a/internal/bundler/debug.go +++ b/internal/bundler/debug.go @@ -24,7 +24,7 @@ func (c *linkerContext) generateExtraDataForFileJS(sourceIndex uint32) string { } file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) sb := strings.Builder{} quoteSym := func(ref js_ast.Ref) string { @@ -50,7 +50,7 @@ func (c *linkerContext) generateExtraDataForFileJS(sourceIndex uint32) string { sb.WriteString(`,"wrapperPartIndex":true`) } else if len(part.Stmts) > 0 { start := part.Stmts[0].Loc.Start - end := len(file.module.Source.Contents) + end := len(file.Module.Source.Contents) if partIndex+1 < len(repr.AST.Parts) { if nextStmts := repr.AST.Parts[partIndex+1].Stmts; len(nextStmts) > 0 { if nextStart := nextStmts[0].Loc.Start; nextStart >= start { @@ -58,7 +58,7 @@ func (c *linkerContext) generateExtraDataForFileJS(sourceIndex uint32) string { } } } - code = file.module.Source.Contents[start:end] + code = file.Module.Source.Contents[start:end] } // importRecords @@ -74,7 +74,7 @@ func (c *linkerContext) generateExtraDataForFileJS(sourceIndex uint32) string { } else { sb.WriteByte(',') } - path := c.files[record.SourceIndex.GetIndex()].module.Source.PrettyPath + path := c.files[record.SourceIndex.GetIndex()].Module.Source.PrettyPath sb.WriteString(fmt.Sprintf(`{"source":%s}`, js_printer.QuoteForJSON(path, c.options.ASCIIOnly))) } sb.WriteByte(']') @@ -115,7 +115,7 @@ func (c *linkerContext) generateExtraDataForFileJS(sourceIndex uint32) string { sb.WriteByte(',') } sb.WriteString(fmt.Sprintf(`{"source":%s,"partIndex":%d}`, - js_printer.QuoteForJSON(c.files[dep.SourceIndex].module.Source.PrettyPath, c.options.ASCIIOnly), + js_printer.QuoteForJSON(c.files[dep.SourceIndex].Module.Source.PrettyPath, c.options.ASCIIOnly), dep.PartIndex, )) } diff --git a/internal/bundler/linker.go b/internal/bundler/linker.go index bc91b8c2..46a12c40 100644 --- a/internal/bundler/linker.go +++ b/internal/bundler/linker.go @@ -38,7 +38,7 @@ type linkerContext struct { res resolver.Resolver symbols js_ast.SymbolMap entryPoints []entryMeta - files []linkerFile + files []LinkerFile // This helps avoid an infinite loop when matching imports to exports cycleDetector []importTracker @@ -191,7 +191,7 @@ func newLinkerContext( log logger.Log, fs fs.FS, res resolver.Resolver, - files []linkerFile, + files []LinkerFile, entryPoints []entryMeta, reachableFiles []uint32, dataForSourceMaps func() []dataForSourceMap, @@ -205,7 +205,7 @@ func newLinkerContext( fs: fs, res: res, entryPoints: append([]entryMeta{}, entryPoints...), - files: make([]linkerFile, len(files)), + files: make([]LinkerFile, len(files)), symbols: js_ast.NewSymbolMap(len(files)), reachableFiles: reachableFiles, dataForSourceMaps: dataForSourceMaps, @@ -215,13 +215,13 @@ func newLinkerContext( for _, sourceIndex := range c.reachableFiles { file := files[sourceIndex] - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.JSRepr: // Clone the representation { clone := *repr repr = &clone - file.module.Repr = repr + file.Module.Repr = repr } // Clone the symbol map @@ -287,7 +287,7 @@ func newLinkerContext( { clone := *repr repr = &clone - file.module.Repr = repr + file.Module.Repr = repr } // Clone the import records @@ -295,7 +295,7 @@ func newLinkerContext( } // All files start off as far as possible from an entry point - file.distanceFromEntryPoint = ^uint32(0) + file.DistanceFromEntryPoint = ^uint32(0) // Update the file in our copy of the file array c.files[sourceIndex] = file @@ -310,9 +310,9 @@ func newLinkerContext( // Mark all entry points so we don't add them again for import() expressions for _, entryPoint := range entryPoints { file := &c.files[entryPoint.sourceIndex] - file.entryPointKind = entryPointUserSpecified + file.EntryPointKind = EntryPointUserSpecified - if repr, ok := file.module.Repr.(*graph.JSRepr); ok { + if repr, ok := file.Module.Repr.(*graph.JSRepr); ok { // Loaders default to CommonJS when they are the entry point and the output // format is not ESM-compatible since that avoids generating the ESM-to-CJS // machinery. @@ -336,7 +336,7 @@ func newLinkerContext( // Allocate a new unbound symbol called "module" in case we need it later if c.options.OutputFormat == config.FormatCommonJS { runtimeSymbols := &c.symbols.SymbolsForSource[runtime.SourceIndex] - runtimeScope := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr).AST.ModuleScope + runtimeScope := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr).AST.ModuleScope c.unboundModuleRef = js_ast.Ref{SourceIndex: runtime.SourceIndex, InnerIndex: uint32(len(*runtimeSymbols))} runtimeScope.Generated = append(runtimeScope.Generated, c.unboundModuleRef) *runtimeSymbols = append(*runtimeSymbols, js_ast.Symbol{ @@ -355,7 +355,7 @@ func (c *linkerContext) addPartToFile(sourceIndex uint32, part js_ast.Part) uint if part.SymbolUses == nil { part.SymbolUses = make(map[js_ast.Ref]js_ast.SymbolUse) } - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) partIndex := uint32(len(repr.AST.Parts)) repr.AST.Parts = append(repr.AST.Parts, part) repr.Meta.PartMeta = append(repr.Meta.PartMeta, graph.PartMeta{}) @@ -493,7 +493,7 @@ func (c *linkerContext) generateChunksInParallel(chunks []chunkInfo) []graph.Out // Each file may optionally contain additional files to be copied to the // output directory. This is used by the "file" loader. for _, sourceIndex := range chunk.filesInChunkInOrder { - outputFiles = append(outputFiles, c.files[sourceIndex].module.AdditionalFiles...) + outputFiles = append(outputFiles, c.files[sourceIndex].Module.AdditionalFiles...) } // Path substitution for the chunk itself @@ -662,13 +662,13 @@ func (c *linkerContext) pathRelativeToOutbase( // Use the extension from the explicit output file path. However, don't do // that if this is a CSS chunk but the entry point file is not CSS. In that // case use the standard extension. This happens when importing CSS into JS. - if _, ok := file.module.Repr.(*graph.CSSRepr); ok || stdExt != c.options.OutputExtensionCSS { + if _, ok := file.Module.Repr.(*graph.CSSRepr); ok || stdExt != c.options.OutputExtensionCSS { baseExt = ext } return } - absPath := file.module.Source.KeyPath.Text + absPath := file.Module.Source.KeyPath.Text isCustomOutputPath := false if outPath := c.entryPoints[entryPointBit].outputPath; outPath != "" { @@ -678,7 +678,7 @@ func (c *linkerContext) pathRelativeToOutbase( absPath = c.fs.Join(c.options.AbsOutputBase, absPath) } isCustomOutputPath = true - } else if file.module.Source.KeyPath.Namespace != "file" { + } else if file.Module.Source.KeyPath.Namespace != "file" { // Come up with a path for virtual paths (i.e. non-file-system paths) dir, base, _ := logger.PlatformIndependentPathDirBaseExt(absPath) if avoidIndex && base == "index" { @@ -779,7 +779,7 @@ func (c *linkerContext) computeCrossChunkDependencies(chunks []chunkInfo) { // Go over each file in this chunk for sourceIndex := range chunk.filesWithPartsInChunk { // Go over each part in this file that's marked for inclusion in this chunk - switch repr := c.files[sourceIndex].module.Repr.(type) { + switch repr := c.files[sourceIndex].Module.Repr.(type) { case *graph.JSRepr: for partIndex, partMeta := range repr.Meta.PartMeta { if !partMeta.IsLive { @@ -791,7 +791,7 @@ func (c *linkerContext) computeCrossChunkDependencies(chunks []chunkInfo) { for _, importRecordIndex := range part.ImportRecordIndices { record := &repr.AST.ImportRecords[importRecordIndex] if record.SourceIndex.IsValid() && c.isExternalDynamicImport(record, sourceIndex) { - otherChunkIndex := c.files[record.SourceIndex.GetIndex()].entryPointChunkIndex + otherChunkIndex := c.files[record.SourceIndex.GetIndex()].EntryPointChunkIndex record.Path.Text = chunks[otherChunkIndex].uniqueKey record.SourceIndex = ast.Index32{} @@ -866,14 +866,14 @@ func (c *linkerContext) computeCrossChunkDependencies(chunks []chunkInfo) { // Include the exports if this is an entry point chunk if chunk.isEntryPoint { - if repr, ok := c.files[chunk.sourceIndex].module.Repr.(*graph.JSRepr); ok { + if repr, ok := c.files[chunk.sourceIndex].Module.Repr.(*graph.JSRepr); ok { if repr.Meta.Wrap != graph.WrapCJS { for _, alias := range repr.Meta.SortedAndFilteredExportAliases { export := repr.Meta.ResolvedExports[alias] targetRef := export.Ref // If this is an import, then target what the import points to - if importData, ok := c.files[export.SourceIndex].module.Repr.(*graph.JSRepr).Meta.ImportsToBind[targetRef]; ok { + if importData, ok := c.files[export.SourceIndex].Module.Repr.(*graph.JSRepr).Meta.ImportsToBind[targetRef]; ok { targetRef = importData.Ref } @@ -1101,24 +1101,24 @@ func (c *linkerContext) scanImportsAndExports() { // Step 1: Figure out what modules must be CommonJS for _, sourceIndex := range c.reachableFiles { file := &c.files[sourceIndex] - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.CSSRepr: // Inline URLs for non-CSS files into the CSS file var additionalFiles []graph.OutputFile for importRecordIndex := range repr.AST.ImportRecords { if record := &repr.AST.ImportRecords[importRecordIndex]; record.SourceIndex.IsValid() { otherFile := &c.files[record.SourceIndex.GetIndex()] - if otherRepr, ok := otherFile.module.Repr.(*graph.JSRepr); ok { + if otherRepr, ok := otherFile.Module.Repr.(*graph.JSRepr); ok { record.Path.Text = otherRepr.AST.URLForCSS record.Path.Namespace = "" record.SourceIndex = ast.Index32{} // Copy the additional files to the output directory - additionalFiles = append(additionalFiles, otherFile.module.AdditionalFiles...) + additionalFiles = append(additionalFiles, otherFile.Module.AdditionalFiles...) } } } - file.module.AdditionalFiles = additionalFiles + file.Module.AdditionalFiles = additionalFiles case *graph.JSRepr: for importRecordIndex := range repr.AST.ImportRecords { @@ -1128,7 +1128,7 @@ func (c *linkerContext) scanImportsAndExports() { } otherFile := &c.files[record.SourceIndex.GetIndex()] - otherRepr := otherFile.module.Repr.(*graph.JSRepr) + otherRepr := otherFile.Module.Repr.(*graph.JSRepr) switch record.Kind { case ast.ImportStmt: @@ -1169,11 +1169,11 @@ func (c *linkerContext) scanImportsAndExports() { case ast.ImportDynamic: if c.options.CodeSplitting { // Files that are imported with import() must be entry points - if otherFile.entryPointKind == entryPointNone { + if otherFile.EntryPointKind == EntryPointNone { c.entryPoints = append(c.entryPoints, entryMeta{ sourceIndex: record.SourceIndex.GetIndex(), }) - otherFile.entryPointKind = entryPointDynamicImport + otherFile.EntryPointKind = EntryPointDynamicImport } } else { // If we're not splitting, then import() is just a require() that @@ -1192,7 +1192,7 @@ func (c *linkerContext) scanImportsAndExports() { // that uses CommonJS features will need to be wrapped, even though the // resulting wrapper won't be invoked by other files. An exception is made // for entry point files in CommonJS format (or when in pass-through mode). - if repr.AST.ExportsKind == js_ast.ExportsCommonJS && (!file.isEntryPoint() || + if repr.AST.ExportsKind == js_ast.ExportsCommonJS && (!file.IsEntryPoint() || c.options.OutputFormat == config.FormatIIFE || c.options.OutputFormat == config.FormatESModule) { repr.Meta.Wrap = graph.WrapCJS } @@ -1204,7 +1204,7 @@ func (c *linkerContext) scanImportsAndExports() { // In this case the export star must be evaluated at run time instead of at // bundle time. for _, sourceIndex := range c.reachableFiles { - repr, ok := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr, ok := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if !ok { continue } @@ -1226,7 +1226,7 @@ func (c *linkerContext) scanImportsAndExports() { // that imports that entry point). for _, record := range repr.AST.ImportRecords { if record.SourceIndex.IsValid() { - otherRepr := c.files[record.SourceIndex.GetIndex()].module.Repr.(*graph.JSRepr) + otherRepr := c.files[record.SourceIndex.GetIndex()].Module.Repr.(*graph.JSRepr) if otherRepr.AST.ExportsKind == js_ast.ExportsCommonJS { c.recursivelyWrapDependencies(record.SourceIndex.GetIndex()) } @@ -1239,7 +1239,7 @@ func (c *linkerContext) scanImportsAndExports() { // are ignored for those modules. exportStarStack := make([]uint32, 0, 32) for _, sourceIndex := range c.reachableFiles { - repr, ok := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr, ok := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if !ok { continue } @@ -1276,7 +1276,7 @@ func (c *linkerContext) scanImportsAndExports() { // export stars because imports can bind to export star re-exports. for _, sourceIndex := range c.reachableFiles { file := &c.files[sourceIndex] - repr, ok := file.module.Repr.(*graph.JSRepr) + repr, ok := file.Module.Repr.(*graph.JSRepr) if !ok { continue } @@ -1290,7 +1290,7 @@ func (c *linkerContext) scanImportsAndExports() { // symbols. In that case make sure to mark them as such so they don't // get minified. if (c.options.OutputFormat == config.FormatPreserve || c.options.OutputFormat == config.FormatCommonJS) && - repr.Meta.Wrap == graph.WrapNone && file.isEntryPoint() { + repr.Meta.Wrap == graph.WrapNone && file.IsEntryPoint() { exportsRef := js_ast.FollowSymbols(c.symbols, repr.AST.ExportsRef) moduleRef := js_ast.FollowSymbols(c.symbols, repr.AST.ModuleRef) c.symbols.Get(exportsRef).Kind = js_ast.SymbolUnbound @@ -1303,7 +1303,7 @@ func (c *linkerContext) scanImportsAndExports() { // imported using an import star statement. waitGroup := sync.WaitGroup{} for _, sourceIndex := range c.reachableFiles { - repr, ok := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr, ok := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if !ok { continue } @@ -1318,14 +1318,14 @@ func (c *linkerContext) scanImportsAndExports() { for alias, export := range repr.Meta.ResolvedExports { // Re-exporting multiple symbols with the same name causes an ambiguous // export. These names cannot be used and should not end up in generated code. - otherRepr := c.files[export.SourceIndex].module.Repr.(*graph.JSRepr) + otherRepr := c.files[export.SourceIndex].Module.Repr.(*graph.JSRepr) if len(export.PotentiallyAmbiguousExportStarRefs) > 0 { mainRef := export.Ref if imported, ok := otherRepr.Meta.ImportsToBind[export.Ref]; ok { mainRef = imported.Ref } for _, ambiguousExport := range export.PotentiallyAmbiguousExportStarRefs { - ambiguousRepr := c.files[ambiguousExport.SourceIndex].module.Repr.(*graph.JSRepr) + ambiguousRepr := c.files[ambiguousExport.SourceIndex].Module.Repr.(*graph.JSRepr) ambiguousRef := ambiguousExport.Ref if imported, ok := ambiguousRepr.Meta.ImportsToBind[ambiguousExport.Ref]; ok { ambiguousRef = imported.Ref @@ -1360,7 +1360,7 @@ func (c *linkerContext) scanImportsAndExports() { // parts that declare the export to all parts that use the import. for _, sourceIndex := range c.reachableFiles { file := &c.files[sourceIndex] - repr, ok := file.module.Repr.(*graph.JSRepr) + repr, ok := file.Module.Repr.(*graph.JSRepr) if !ok { continue } @@ -1368,7 +1368,7 @@ func (c *linkerContext) scanImportsAndExports() { // Pre-generate symbols for re-exports CommonJS symbols in case they // are necessary later. This is done now because the symbols map cannot be // mutated later due to parallelism. - if file.isEntryPoint() && c.options.OutputFormat == config.FormatESModule { + if file.IsEntryPoint() && c.options.OutputFormat == config.FormatESModule { copies := make([]js_ast.Ref, len(repr.Meta.SortedAndFilteredExportAliases)) for i, alias := range repr.Meta.SortedAndFilteredExportAliases { symbols := &c.symbols.SymbolsForSource[sourceIndex] @@ -1390,7 +1390,7 @@ func (c *linkerContext) scanImportsAndExports() { // Use "init_*" for ESM wrappers instead of "require_*" if repr.Meta.Wrap == graph.WrapESM { - c.symbols.Get(repr.AST.WrapperRef).OriginalName = "init_" + file.module.Source.IdentifierName + c.symbols.Get(repr.AST.WrapperRef).OriginalName = "init_" + file.Module.Source.IdentifierName } // If this isn't CommonJS, then rename the unused "exports" and "module" @@ -1398,9 +1398,9 @@ func (c *linkerContext) scanImportsAndExports() { // actual CommonJS files from being renamed. This is purely about // aesthetics and is not about correctness. This is done here because by // this point, we know the CommonJS status will not change further. - if repr.Meta.Wrap != graph.WrapCJS && repr.AST.ExportsKind != js_ast.ExportsCommonJS && (!file.isEntryPoint() || + if repr.Meta.Wrap != graph.WrapCJS && repr.AST.ExportsKind != js_ast.ExportsCommonJS && (!file.IsEntryPoint() || c.options.OutputFormat != config.FormatCommonJS) { - name := file.module.Source.IdentifierName + name := file.Module.Source.IdentifierName c.symbols.Get(repr.AST.ExportsRef).OriginalName = name + "_exports" c.symbols.Get(repr.AST.ModuleRef).OriginalName = name + "_module" } @@ -1409,7 +1409,7 @@ func (c *linkerContext) scanImportsAndExports() { // previous step. The previous step can't do this because it's running in // parallel and can't safely mutate the "importsToBind" map of another file. if repr.Meta.NeedsExportSymbolFromRuntime || repr.Meta.NeedsMarkAsModuleSymbolFromRuntime { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) exportPart := &repr.AST.Parts[repr.Meta.NSExportPartIndex] if repr.Meta.NeedsExportSymbolFromRuntime { exportRef := runtimeRepr.AST.ModuleScope.Members["__export"].Ref @@ -1422,7 +1422,7 @@ func (c *linkerContext) scanImportsAndExports() { } for importRef, importData := range repr.Meta.ImportsToBind { - resolvedRepr := c.files[importData.SourceIndex].module.Repr.(*graph.JSRepr) + resolvedRepr := c.files[importData.SourceIndex].Module.Repr.(*graph.JSRepr) partsDeclaringSymbol := resolvedRepr.AST.TopLevelSymbolToParts[importData.Ref] for _, partIndex := range repr.AST.NamedImports[importRef].LocalPartsWithUses { @@ -1449,7 +1449,7 @@ func (c *linkerContext) scanImportsAndExports() { func (c *linkerContext) generateCodeForLazyExport(sourceIndex uint32) { file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) // Grab the lazy expression if len(repr.AST.Parts) < 1 { @@ -1539,7 +1539,7 @@ func (c *linkerContext) generateCodeForLazyExport(sourceIndex uint32) { clone := *object clone.Properties = append(make([]js_ast.Property, 0, len(clone.Properties)), clone.Properties...) for i, property := range clone.Properties { - if str, ok := property.Key.Data.(*js_ast.EString); ok && (!file.isEntryPoint() || js_lexer.IsIdentifierUTF16(str.Value)) { + if str, ok := property.Key.Data.(*js_ast.EString); ok && (!file.IsEntryPoint() || js_lexer.IsIdentifierUTF16(str.Value)) { name := js_lexer.UTF16ToString(str.Value) export := generateExport(name, name, *property.Value, nil) prevExports = append(prevExports, export) @@ -1550,7 +1550,7 @@ func (c *linkerContext) generateCodeForLazyExport(sourceIndex uint32) { } // Generate the default export - generateExport(file.module.Source.IdentifierName+"_default", "default", jsonValue, prevExports) + generateExport(file.Module.Source.IdentifierName+"_default", "default", jsonValue, prevExports) } func (c *linkerContext) createExportsForFile(sourceIndex uint32) { @@ -1560,7 +1560,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { //////////////////////////////////////////////////////////////////////////////// file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) // Generate a getter per export properties := []js_ast.Property{} @@ -1573,7 +1573,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { // was eventually resolved to. We need to do this because imports have // already been resolved by this point, so we can't generate a new import // and have that be resolved later. - if importData, ok := c.files[export.SourceIndex].module.Repr.(*graph.JSRepr).Meta.ImportsToBind[export.Ref]; ok { + if importData, ok := c.files[export.SourceIndex].Module.Repr.(*graph.JSRepr).Meta.ImportsToBind[export.Ref]; ok { export.Ref = importData.Ref export.SourceIndex = importData.SourceIndex nsExportDependencies = append(nsExportDependencies, importData.ReExports...) @@ -1603,7 +1603,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { nsExportSymbolUses[export.Ref] = js_ast.SymbolUse{CountEstimate: 1} // Make sure the part that declares the export is included - for _, partIndex := range c.files[export.SourceIndex].module.Repr.(*graph.JSRepr).AST.TopLevelSymbolToParts[export.Ref] { + for _, partIndex := range c.files[export.SourceIndex].Module.Repr.(*graph.JSRepr).AST.TopLevelSymbolToParts[export.Ref] { // Use a non-local dependency since this is likely from a different // file if it came in through an export star nsExportDependencies = append(nsExportDependencies, js_ast.Dependency{ @@ -1616,7 +1616,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { // Prefix this part with "var exports = {}" if this isn't a CommonJS module declaredSymbols := []js_ast.DeclaredSymbol{} var nsExportStmts []js_ast.Stmt - if repr.AST.ExportsKind != js_ast.ExportsCommonJS && (!file.isEntryPoint() || c.options.OutputFormat != config.FormatCommonJS) { + if repr.AST.ExportsKind != js_ast.ExportsCommonJS && (!file.IsEntryPoint() || c.options.OutputFormat != config.FormatCommonJS) { nsExportStmts = append(nsExportStmts, js_ast.Stmt{Data: &js_ast.SLocal{Decls: []js_ast.Decl{{ Binding: js_ast.Binding{Data: &js_ast.BIdentifier{Ref: repr.AST.ExportsRef}}, Value: &js_ast.Expr{Data: &js_ast.EObject{}}, @@ -1632,8 +1632,8 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { // be done before any to "require()" or circular imports of multiple modules // that have been each converted from ESM to CommonJS may not work correctly. if repr.AST.ExportKeyword.Len > 0 && (repr.AST.ExportsKind == js_ast.ExportsCommonJS || - (file.isEntryPoint() && c.options.OutputFormat == config.FormatCommonJS)) { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + (file.IsEntryPoint() && c.options.OutputFormat == config.FormatCommonJS)) { + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) markAsModuleRef := runtimeRepr.AST.ModuleScope.Members["__markAsModule"].Ref nsExportStmts = append(nsExportStmts, js_ast.Stmt{Data: &js_ast.SExpr{Value: js_ast.Expr{Data: &js_ast.ECall{ Target: js_ast.Expr{Data: &js_ast.EIdentifier{Ref: markAsModuleRef}}, @@ -1657,7 +1657,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { // "__export(exports, { foo: () => foo })" exportRef := js_ast.InvalidRef if len(properties) > 0 { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) exportRef = runtimeRepr.AST.ModuleScope.Members["__export"].Ref nsExportStmts = append(nsExportStmts, js_ast.Stmt{Data: &js_ast.SExpr{Value: js_ast.Expr{Data: &js_ast.ECall{ Target: js_ast.Expr{Data: &js_ast.EIdentifier{Ref: exportRef}}, @@ -1711,7 +1711,7 @@ func (c *linkerContext) createExportsForFile(sourceIndex uint32) { func (c *linkerContext) matchImportsWithExportsForFile(sourceIndex uint32) { file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) // Sort imports for determinism. Otherwise our unit tests will randomly // fail sometimes when error messages are reordered. @@ -1758,7 +1758,7 @@ func (c *linkerContext) matchImportsWithExportsForFile(sourceIndex uint32) { case matchImportCycle: namedImport := repr.AST.NamedImports[importRef] - c.log.AddRangeError(&file.module.Source, js_lexer.RangeOfIdentifier(file.module.Source, namedImport.AliasLoc), + c.log.AddRangeError(&file.Module.Source, js_lexer.RangeOfIdentifier(file.Module.Source, namedImport.AliasLoc), fmt.Sprintf("Detected cycle while resolving import %q", namedImport.Alias)) case matchImportProbablyTypeScriptType: @@ -1766,13 +1766,13 @@ func (c *linkerContext) matchImportsWithExportsForFile(sourceIndex uint32) { case matchImportAmbiguous: namedImport := repr.AST.NamedImports[importRef] - r := js_lexer.RangeOfIdentifier(file.module.Source, namedImport.AliasLoc) + r := js_lexer.RangeOfIdentifier(file.Module.Source, namedImport.AliasLoc) var notes []logger.MsgData // Provide the locations of both ambiguous exports if possible if result.nameLoc.Start != 0 && result.otherNameLoc.Start != 0 { - a := c.files[result.sourceIndex].module.Source - b := c.files[result.otherSourceIndex].module.Source + a := c.files[result.sourceIndex].Module.Source + b := c.files[result.otherSourceIndex].Module.Source notes = []logger.MsgData{ logger.RangeData(&a, js_lexer.RangeOfIdentifier(a, result.nameLoc), "One matching export is here"), logger.RangeData(&b, js_lexer.RangeOfIdentifier(b, result.otherNameLoc), "Another matching export is here"), @@ -1790,10 +1790,10 @@ func (c *linkerContext) matchImportsWithExportsForFile(sourceIndex uint32) { // "undefined" instead of emitting an error. symbol.ImportItemStatus = js_ast.ImportItemMissing msg := fmt.Sprintf("Import %q will always be undefined because there are multiple matching exports", namedImport.Alias) - c.log.AddRangeWarningWithNotes(&file.module.Source, r, msg, notes) + c.log.AddRangeWarningWithNotes(&file.Module.Source, r, msg, notes) } else { msg := fmt.Sprintf("Ambiguous import %q has multiple matching exports", namedImport.Alias) - c.log.AddRangeErrorWithNotes(&file.module.Source, r, msg, notes) + c.log.AddRangeErrorWithNotes(&file.Module.Source, r, msg, notes) } } } @@ -1876,7 +1876,7 @@ loop: // though. This is the case for star imports, where the import is the // namespace. trackerFile := &c.files[tracker.sourceIndex] - namedImport := trackerFile.module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] + namedImport := trackerFile.Module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] if namedImport.NamespaceRef != js_ast.InvalidRef { if result.kind == matchImportNormal { result.kind = matchImportNormalAndNamespace @@ -1893,18 +1893,18 @@ loop: // Warn about importing from a file that is known to not have any exports if status == importCommonJSWithoutExports { - source := trackerFile.module.Source + source := trackerFile.Module.Source symbol := c.symbols.Get(tracker.importRef) symbol.ImportItemStatus = js_ast.ImportItemMissing c.log.AddRangeWarning(&source, js_lexer.RangeOfIdentifier(source, namedImport.AliasLoc), fmt.Sprintf("Import %q will always be undefined because the file %q has no exports", - namedImport.Alias, c.files[nextTracker.sourceIndex].module.Source.PrettyPath)) + namedImport.Alias, c.files[nextTracker.sourceIndex].Module.Source.PrettyPath)) } case importDynamicFallback: // If it's a file with dynamic export fallback, rewrite the import to a property access trackerFile := &c.files[tracker.sourceIndex] - namedImport := trackerFile.module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] + namedImport := trackerFile.Module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] if result.kind == matchImportNormal { result.kind = matchImportNormalAndNamespace result.namespaceRef = nextTracker.importRef @@ -1920,8 +1920,8 @@ loop: case importNoMatch: symbol := c.symbols.Get(tracker.importRef) trackerFile := &c.files[tracker.sourceIndex] - source := trackerFile.module.Source - namedImport := trackerFile.module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] + source := trackerFile.Module.Source + namedImport := trackerFile.Module.Repr.(*graph.JSRepr).AST.NamedImports[tracker.importRef] r := js_lexer.RangeOfIdentifier(source, namedImport.AliasLoc) // Report mismatched imports and exports @@ -1938,7 +1938,7 @@ loop: "Import %q will always be undefined because there is no matching export", namedImport.Alias)) } else { c.log.AddRangeError(&source, r, fmt.Sprintf("No matching export in %q for import %q", - c.files[nextTracker.sourceIndex].module.Source.PrettyPath, namedImport.Alias)) + c.files[nextTracker.sourceIndex].Module.Source.PrettyPath, namedImport.Alias)) } case importProbablyTypeScriptType: @@ -1951,7 +1951,7 @@ loop: // statements, trace them all to see if they point to different things. for _, ambiguousTracker := range potentiallyAmbiguousExportStarRefs { // If this is a re-export of another import, follow the import - if _, ok := c.files[ambiguousTracker.SourceIndex].module.Repr.(*graph.JSRepr).AST.NamedImports[ambiguousTracker.Ref]; ok { + if _, ok := c.files[ambiguousTracker.SourceIndex].Module.Repr.(*graph.JSRepr).AST.NamedImports[ambiguousTracker.Ref]; ok { // Save and restore the cycle detector to avoid mixing information oldCycleDetector := c.cycleDetector ambiguousResult, newReExportFiles := c.matchImportWithExport(importTracker{ @@ -1985,7 +1985,7 @@ loop: // Depend on the statement(s) that declared this import symbol in the // original file - for _, resolvedPartIndex := range c.files[tracker.sourceIndex].module.Repr.(*graph.JSRepr).AST.TopLevelSymbolToParts[tracker.importRef] { + for _, resolvedPartIndex := range c.files[tracker.sourceIndex].Module.Repr.(*graph.JSRepr).AST.TopLevelSymbolToParts[tracker.importRef] { reExports = append(reExports, js_ast.Dependency{ SourceIndex: tracker.sourceIndex, PartIndex: resolvedPartIndex, @@ -1994,7 +1994,7 @@ loop: // If this is a re-export of another import, continue for another // iteration of the loop to resolve that import as well - if _, ok := c.files[nextTracker.sourceIndex].module.Repr.(*graph.JSRepr).AST.NamedImports[nextTracker.importRef]; ok { + if _, ok := c.files[nextTracker.sourceIndex].Module.Repr.(*graph.JSRepr).AST.NamedImports[nextTracker.importRef]; ok { tracker = nextTracker continue } @@ -2028,7 +2028,7 @@ loop: } func (c *linkerContext) recursivelyWrapDependencies(sourceIndex uint32) { - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if repr.DidWrapDependencies { return } @@ -2058,7 +2058,7 @@ func (c *linkerContext) recursivelyWrapDependencies(sourceIndex uint32) { func (c *linkerContext) hasDynamicExportsDueToExportStar(sourceIndex uint32, visited map[uint32]bool) bool { // Terminate the traversal now if this file already has dynamic exports - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if repr.AST.ExportsKind == js_ast.ExportsCommonJS || repr.AST.ExportsKind == js_ast.ExportsESMWithDynamicFallback { return true } @@ -2076,7 +2076,7 @@ func (c *linkerContext) hasDynamicExportsDueToExportStar(sourceIndex uint32, vis // This file has dynamic exports if the exported imports are from a file // that either has dynamic exports directly or transitively by itself // having an export star from a file with dynamic exports. - if (!record.SourceIndex.IsValid() && (!c.files[sourceIndex].isEntryPoint() || !c.options.OutputFormat.KeepES6ImportExportSyntax())) || + if (!record.SourceIndex.IsValid() && (!c.files[sourceIndex].IsEntryPoint() || !c.options.OutputFormat.KeepES6ImportExportSyntax())) || (record.SourceIndex.IsValid() && record.SourceIndex.GetIndex() != sourceIndex && c.hasDynamicExportsDueToExportStar(record.SourceIndex.GetIndex(), visited)) { repr.AST.ExportsKind = js_ast.ExportsESMWithDynamicFallback return true @@ -2098,7 +2098,7 @@ func (c *linkerContext) addExportsForExportStar( } } sourceIndexStack = append(sourceIndexStack, sourceIndex) - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) for _, importRecordIndex := range repr.AST.ExportStarImportRecords { record := &repr.AST.ImportRecords[importRecordIndex] @@ -2115,7 +2115,7 @@ func (c *linkerContext) addExportsForExportStar( // exports even though it still uses CommonJS features. However, when // doing this we'd also have to rewrite any imports of these export star // re-exports as property accesses off of a generated require() call. - otherRepr := c.files[otherSourceIndex].module.Repr.(*graph.JSRepr) + otherRepr := c.files[otherSourceIndex].Module.Repr.(*graph.JSRepr) if otherRepr.AST.ExportsKind == js_ast.ExportsCommonJS { // All exports will be resolved at run time instead continue @@ -2131,7 +2131,7 @@ func (c *linkerContext) addExportsForExportStar( // This export star is shadowed if any file in the stack has a matching real named export for _, prevSourceIndex := range sourceIndexStack { - prevRepr := c.files[prevSourceIndex].module.Repr.(*graph.JSRepr) + prevRepr := c.files[prevSourceIndex].Module.Repr.(*graph.JSRepr) if _, ok := prevRepr.AST.NamedExports[alias]; ok { continue nextExport } @@ -2205,7 +2205,7 @@ const ( func (c *linkerContext) advanceImportTracker(tracker importTracker) (importTracker, importStatus, []graph.ImportData) { file := &c.files[tracker.sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) namedImport := repr.AST.NamedImports[tracker.importRef] // Is this an external file? @@ -2216,12 +2216,12 @@ func (c *linkerContext) advanceImportTracker(tracker importTracker) (importTrack // Is this a disabled file? otherSourceIndex := record.SourceIndex.GetIndex() - if c.files[otherSourceIndex].module.Source.KeyPath.IsDisabled() { + if c.files[otherSourceIndex].Module.Source.KeyPath.IsDisabled() { return importTracker{sourceIndex: otherSourceIndex, importRef: js_ast.InvalidRef}, importDisabled, nil } // Is this a named import of a file without any exports? - otherRepr := c.files[otherSourceIndex].module.Repr.(*graph.JSRepr) + otherRepr := c.files[otherSourceIndex].Module.Repr.(*graph.JSRepr) if !namedImport.AliasIsStar && !otherRepr.AST.HasLazyExport && // CommonJS exports otherRepr.AST.ExportKeyword.Len == 0 && namedImport.Alias != "default" && @@ -2262,7 +2262,7 @@ func (c *linkerContext) advanceImportTracker(tracker importTracker) (importTrack } // Missing re-exports in TypeScript files are indistinguishable from types - if file.module.Loader.IsTypeScript() && namedImport.IsExported { + if file.Module.Loader.IsTypeScript() && namedImport.IsExported { return importTracker{}, importProbablyTypeScriptType, nil } @@ -2275,9 +2275,9 @@ func (c *linkerContext) markPartsReachableFromEntryPoints() { // Generate wrapper parts for wrapped files for _, sourceIndex := range c.reachableFiles { file := &c.files[sourceIndex] - file.entryBits = helpers.NewBitSet(bitCount) + file.EntryBits = helpers.NewBitSet(bitCount) - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.JSRepr: // If this is a CommonJS file, we're going to need to generate a wrapper // for the CommonJS closure. That will end up looking something like this: @@ -2294,7 +2294,7 @@ func (c *linkerContext) markPartsReachableFromEntryPoints() { // dependencies and let the general-purpose reachablity analysis take care // of it. if repr.Meta.Wrap == graph.WrapCJS { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) commonJSRef := runtimeRepr.AST.NamedExports["__commonJS"].Ref commonJSParts := runtimeRepr.AST.TopLevelSymbolToParts[commonJSRef] @@ -2333,7 +2333,7 @@ func (c *linkerContext) markPartsReachableFromEntryPoints() { // This depends on the "__esm" symbol and declares the "init_foo" symbol // for similar reasons to the CommonJS closure above. if repr.Meta.Wrap == graph.WrapESM { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) esmRef := runtimeRepr.AST.NamedExports["__esm"].Ref esmParts := runtimeRepr.AST.TopLevelSymbolToParts[esmRef] @@ -2377,25 +2377,25 @@ func (c *linkerContext) markPartsReachableFromEntryPoints() { func (c *linkerContext) markFileAsReachable(sourceIndex uint32, entryPointBit uint, distanceFromEntryPoint uint32) { file := &c.files[sourceIndex] - if !file.isLive { + if !file.IsLive { return } traverseAgain := false // Track the minimum distance to an entry point - if distanceFromEntryPoint < file.distanceFromEntryPoint { - file.distanceFromEntryPoint = distanceFromEntryPoint + if distanceFromEntryPoint < file.DistanceFromEntryPoint { + file.DistanceFromEntryPoint = distanceFromEntryPoint traverseAgain = true } distanceFromEntryPoint++ // Don't mark this file more than once - if file.entryBits.HasBit(entryPointBit) && !traverseAgain { + if file.EntryBits.HasBit(entryPointBit) && !traverseAgain { return } - file.entryBits.SetBit(entryPointBit) + file.EntryBits.SetBit(entryPointBit) - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.JSRepr: // If the JavaScript stub for a CSS file is included, also include the CSS file if repr.CSSSourceIndex.IsValid() { @@ -2443,12 +2443,12 @@ func (c *linkerContext) markFileAsLive(sourceIndex uint32) { file := &c.files[sourceIndex] // Don't mark this file more than once - if file.isLive { + if file.IsLive { return } - file.isLive = true + file.IsLive = true - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.JSRepr: isTreeShakingEnabled := config.IsTreeShakingEnabled(c.options.Mode, c.options.OutputFormat) @@ -2472,7 +2472,7 @@ func (c *linkerContext) markFileAsLive(sourceIndex uint32) { // Don't include this module for its side effects if it can be // considered to have no side effects - if otherFile := &c.files[otherSourceIndex]; otherFile.module.SideEffects.Kind != graph.HasSideEffects && !c.options.IgnoreDCEAnnotations { + if otherFile := &c.files[otherSourceIndex]; otherFile.Module.SideEffects.Kind != graph.HasSideEffects && !c.options.IgnoreDCEAnnotations { // This is currently unsafe when code splitting is enabled, so // disable it in that case if len(c.entryPoints) < 2 { @@ -2492,24 +2492,24 @@ func (c *linkerContext) markFileAsLive(sourceIndex uint32) { // Include all parts in this file with side effects, or just include // everything if tree-shaking is disabled. Note that we still want to // perform tree-shaking on the runtime even if tree-shaking is disabled. - if !canBeRemovedIfUnused || (!part.ForceTreeShaking && !isTreeShakingEnabled && file.isEntryPoint()) { + if !canBeRemovedIfUnused || (!part.ForceTreeShaking && !isTreeShakingEnabled && file.IsEntryPoint()) { c.markPartAsLive(sourceIndex, uint32(partIndex)) } } // If this is an entry point, include all exports - if file.isEntryPoint() { + if file.IsEntryPoint() { for _, alias := range repr.Meta.SortedAndFilteredExportAliases { export := repr.Meta.ResolvedExports[alias] targetSourceIndex := export.SourceIndex targetRef := export.Ref // If this is an import, then target what the import points to - targetRepr := c.files[targetSourceIndex].module.Repr.(*graph.JSRepr) + targetRepr := c.files[targetSourceIndex].Module.Repr.(*graph.JSRepr) if importData, ok := targetRepr.Meta.ImportsToBind[targetRef]; ok { targetSourceIndex = importData.SourceIndex targetRef = importData.Ref - targetRepr = c.files[targetSourceIndex].module.Repr.(*graph.JSRepr) + targetRepr = c.files[targetSourceIndex].Module.Repr.(*graph.JSRepr) } // Pull in all declarations of this symbol @@ -2543,7 +2543,7 @@ func (c *linkerContext) markPartsAsLiveForRuntimeSymbol( part *js_ast.Part, repr *graph.JSRepr, useCount uint32, name string, ) { if useCount > 0 { - runtimeRepr := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr) + runtimeRepr := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr) ref := runtimeRepr.AST.NamedExports[name].Ref // Depend on the symbol from the runtime @@ -2579,12 +2579,12 @@ func (c *linkerContext) generateUseOfSymbolForInclude( } func (c *linkerContext) isExternalDynamicImport(record *ast.ImportRecord, sourceIndex uint32) bool { - return record.Kind == ast.ImportDynamic && c.files[record.SourceIndex.GetIndex()].isEntryPoint() && record.SourceIndex.GetIndex() != sourceIndex + return record.Kind == ast.ImportDynamic && c.files[record.SourceIndex.GetIndex()].IsEntryPoint() && record.SourceIndex.GetIndex() != sourceIndex } func (c *linkerContext) markPartAsLive(sourceIndex uint32, partIndex uint32) { file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) partMeta := &repr.Meta.PartMeta[partIndex] // Don't mark this part more than once @@ -2621,7 +2621,7 @@ func (c *linkerContext) markPartAsLive(sourceIndex uint32, partIndex uint32) { } otherSourceIndex := record.SourceIndex.GetIndex() - otherRepr := c.files[otherSourceIndex].module.Repr.(*graph.JSRepr) + otherRepr := c.files[otherSourceIndex].Module.Repr.(*graph.JSRepr) if record.Kind == ast.ImportRequire || record.Kind == ast.ImportDynamic || (record.Kind == ast.ImportStmt && otherRepr.Meta.Wrap != graph.WrapNone) { @@ -2670,10 +2670,10 @@ func (c *linkerContext) markPartAsLive(sourceIndex uint32, partIndex uint32) { record := &repr.AST.ImportRecords[importRecordIndex] // Is this export star evaluated at run time? - happensAtRunTime := !record.SourceIndex.IsValid() && (!file.isEntryPoint() || !c.options.OutputFormat.KeepES6ImportExportSyntax()) + happensAtRunTime := !record.SourceIndex.IsValid() && (!file.IsEntryPoint() || !c.options.OutputFormat.KeepES6ImportExportSyntax()) if record.SourceIndex.IsValid() { otherSourceIndex := record.SourceIndex.GetIndex() - otherRepr := c.files[otherSourceIndex].module.Repr.(*graph.JSRepr) + otherRepr := c.files[otherSourceIndex].Module.Repr.(*graph.JSRepr) if otherSourceIndex != sourceIndex && otherRepr.AST.ExportsKind.IsDynamic() { happensAtRunTime = true } @@ -2761,7 +2761,7 @@ func (c *linkerContext) computeChunks() []chunkInfo { filesWithPartsInChunk: make(map[uint32]bool), } - switch file.module.Repr.(type) { + switch file.Module.Repr.(type) { case *graph.JSRepr: info.chunkRepr = &chunkReprJS{} jsChunks[entryBits.String()] = info @@ -2775,18 +2775,18 @@ func (c *linkerContext) computeChunks() []chunkInfo { // Figure out which files are in which chunk for _, sourceIndex := range c.reachableFiles { file := &c.files[sourceIndex] - if !file.isLive { + if !file.IsLive { // Ignore this file if it's not included in the bundle continue } - key := file.entryBits.String() + key := file.EntryBits.String() var chunk chunkInfo var ok bool - switch file.module.Repr.(type) { + switch file.Module.Repr.(type) { case *graph.JSRepr: chunk, ok = jsChunks[key] if !ok { - chunk.entryBits = file.entryBits + chunk.entryBits = file.EntryBits chunk.filesWithPartsInChunk = make(map[uint32]bool) chunk.chunkRepr = &chunkReprJS{} jsChunks[key] = chunk @@ -2794,7 +2794,7 @@ func (c *linkerContext) computeChunks() []chunkInfo { case *graph.CSSRepr: chunk, ok = cssChunks[key] if !ok { - chunk.entryBits = file.entryBits + chunk.entryBits = file.EntryBits chunk.filesWithPartsInChunk = make(map[uint32]bool) chunk.chunkRepr = &chunkReprCSS{} @@ -2842,12 +2842,12 @@ func (c *linkerContext) computeChunks() []chunkInfo { // and a CSS chunk. Don't link the CSS chunk to the JS file since the CSS // chunk is secondary (the JS chunk is primary). if _, ok := chunk.chunkRepr.(*chunkReprCSS); ok { - if _, ok := file.module.Repr.(*graph.JSRepr); ok { + if _, ok := file.Module.Repr.(*graph.JSRepr); ok { continue } } - file.entryPointChunkIndex = uint32(chunkIndex) + file.EntryPointChunkIndex = uint32(chunkIndex) } } @@ -2903,7 +2903,7 @@ func (c *linkerContext) computeChunks() []chunkInfo { var dir, base, ext string var template []config.PathTemplate if chunk.isEntryPoint { - if c.files[chunk.sourceIndex].entryPointKind == entryPointUserSpecified { + if c.files[chunk.sourceIndex].EntryPointKind == EntryPointUserSpecified { dir, base, ext = c.pathRelativeToOutbase(chunk.sourceIndex, chunk.entryPointBit, stdExt, false /* avoidIndex */) template = c.options.EntryPathTemplate } else { @@ -2968,7 +2968,7 @@ func (c *linkerContext) shouldIncludePart(repr *graph.JSRepr, part js_ast.Part) if len(part.Stmts) == 1 { if s, ok := part.Stmts[0].Data.(*js_ast.SImport); ok { record := &repr.AST.ImportRecords[s.ImportRecordIndex] - if record.SourceIndex.IsValid() && c.files[record.SourceIndex.GetIndex()].module.Repr.(*graph.JSRepr).Meta.Wrap == graph.WrapNone { + if record.SourceIndex.IsValid() && c.files[record.SourceIndex.GetIndex()].Module.Repr.(*graph.JSRepr).Meta.Wrap == graph.WrapNone { return false } } @@ -2984,7 +2984,7 @@ func (c *linkerContext) chunkFileOrder(chunk *chunkInfo) (js []uint32, jsParts [ file := &c.files[sourceIndex] sorted = append(sorted, chunkOrder{ sourceIndex: sourceIndex, - distance: file.distanceFromEntryPoint, + distance: file.DistanceFromEntryPoint, tieBreaker: c.stableSourceIndices[sourceIndex], }) } @@ -3007,9 +3007,9 @@ func (c *linkerContext) chunkFileOrder(chunk *chunkInfo) (js []uint32, jsParts [ visited[sourceIndex] = true file := &c.files[sourceIndex] - isFileInThisChunk := chunk.entryBits.Equals(file.entryBits) + isFileInThisChunk := chunk.entryBits.Equals(file.EntryBits) - switch repr := file.module.Repr.(type) { + switch repr := file.Module.Repr.(type) { case *graph.JSRepr: // Wrapped files can't be split because they are all inside the wrapper canFileBeSplit := repr.Meta.Wrap == graph.WrapNone @@ -3092,7 +3092,7 @@ func (c *linkerContext) shouldRemoveImportExportStmt( namespaceRef js_ast.Ref, importRecordIndex uint32, ) bool { - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) record := &repr.AST.ImportRecords[importRecordIndex] // Is this an external import? @@ -3120,7 +3120,7 @@ func (c *linkerContext) shouldRemoveImportExportStmt( } otherFile := &c.files[record.SourceIndex.GetIndex()] - otherRepr := otherFile.module.Repr.(*graph.JSRepr) + otherRepr := otherFile.Module.Repr.(*graph.JSRepr) switch otherRepr.Meta.Wrap { case graph.WrapNone: // Remove the statement entirely if this module is not wrapped @@ -3139,7 +3139,7 @@ func (c *linkerContext) shouldRemoveImportExportStmt( // Ignore this file if it's not included in the bundle. This can happen for // wrapped ESM files but not for wrapped CommonJS files because we allow // tree shaking inside wrapped ESM files. - if !otherFile.isLive { + if !otherFile.IsLive { break } @@ -3159,8 +3159,8 @@ func (c *linkerContext) shouldRemoveImportExportStmt( func (c *linkerContext) convertStmtsForChunk(sourceIndex uint32, stmtList *stmtList, partStmts []js_ast.Stmt) { file := &c.files[sourceIndex] - shouldStripExports := c.options.Mode != config.ModePassThrough || !file.isEntryPoint() - repr := file.module.Repr.(*graph.JSRepr) + shouldStripExports := c.options.Mode != config.ModePassThrough || !file.IsEntryPoint() + repr := file.Module.Repr.(*graph.JSRepr) shouldExtractESMStmtsForWrap := repr.Meta.Wrap != graph.WrapNone for _, stmt := range partStmts { @@ -3219,7 +3219,7 @@ func (c *linkerContext) convertStmtsForChunk(sourceIndex uint32, stmtList *stmtL } // Prefix this module with "__reExport(exports, ns)" - exportStarRef := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr).AST.ModuleScope.Members["__reExport"].Ref + exportStarRef := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr).AST.ModuleScope.Members["__reExport"].Ref stmtList.insideWrapperPrefix = append(stmtList.insideWrapperPrefix, js_ast.Stmt{ Loc: stmt.Loc, Data: &js_ast.SExpr{Value: js_ast.Expr{Loc: stmt.Loc, Data: &js_ast.ECall{ @@ -3239,7 +3239,7 @@ func (c *linkerContext) convertStmtsForChunk(sourceIndex uint32, stmtList *stmtL } } else { if record.SourceIndex.IsValid() { - if otherRepr := c.files[record.SourceIndex.GetIndex()].module.Repr.(*graph.JSRepr); otherRepr.Meta.Wrap == graph.WrapESM { + if otherRepr := c.files[record.SourceIndex.GetIndex()].Module.Repr.(*graph.JSRepr); otherRepr.Meta.Wrap == graph.WrapESM { stmtList.insideWrapperPrefix = append(stmtList.insideWrapperPrefix, js_ast.Stmt{Loc: stmt.Loc, Data: &js_ast.SExpr{Value: js_ast.Expr{Loc: stmt.Loc, Data: &js_ast.ECall{ Target: js_ast.Expr{Loc: stmt.Loc, Data: &js_ast.EIdentifier{Ref: otherRepr.AST.WrapperRef}}}}}}) @@ -3249,7 +3249,7 @@ func (c *linkerContext) convertStmtsForChunk(sourceIndex uint32, stmtList *stmtL if record.CallsRunTimeExportStarFn { var target js_ast.E if record.SourceIndex.IsValid() { - if otherRepr := c.files[record.SourceIndex.GetIndex()].module.Repr.(*graph.JSRepr); otherRepr.AST.ExportsKind == js_ast.ExportsESMWithDynamicFallback { + if otherRepr := c.files[record.SourceIndex.GetIndex()].Module.Repr.(*graph.JSRepr); otherRepr.AST.ExportsKind == js_ast.ExportsESMWithDynamicFallback { // Prefix this module with "__reExport(exports, otherExports)" target = &js_ast.EIdentifier{Ref: otherRepr.AST.ExportsRef} } @@ -3258,7 +3258,7 @@ func (c *linkerContext) convertStmtsForChunk(sourceIndex uint32, stmtList *stmtL // Prefix this module with "__reExport(exports, require(path))" target = &js_ast.ERequire{ImportRecordIndex: s.ImportRecordIndex} } - exportStarRef := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr).AST.ModuleScope.Members["__reExport"].Ref + exportStarRef := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr).AST.ModuleScope.Members["__reExport"].Ref stmtList.insideWrapperPrefix = append(stmtList.insideWrapperPrefix, js_ast.Stmt{ Loc: stmt.Loc, Data: &js_ast.SExpr{Value: js_ast.Expr{Loc: stmt.Loc, Data: &js_ast.ECall{ @@ -3440,7 +3440,7 @@ type compileResultJS struct { } func (c *linkerContext) requireOrImportMetaForSource(sourceIndex uint32) (meta js_printer.RequireOrImportMeta) { - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) meta.WrapperRef = repr.AST.WrapperRef meta.IsWrapperAsync = repr.Meta.IsAsyncOrHasAsyncDependency if repr.Meta.Wrap == graph.WrapESM { @@ -3464,7 +3464,7 @@ func (c *linkerContext) generateCodeForFileInChunkJS( dataForSourceMaps []dataForSourceMap, ) { file := &c.files[partRange.sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) nsExportPartIndex := repr.Meta.NSExportPartIndex needsWrapper := false stmtList := stmtList{} @@ -3631,9 +3631,9 @@ func (c *linkerContext) generateCodeForFileInChunkJS( var addSourceMappings bool var inputSourceMap *sourcemap.SourceMap var lineOffsetTables []js_printer.LineOffsetTable - if file.module.Loader.CanHaveSourceMap() && c.options.SourceMap != config.SourceMapNone { + if file.Module.Loader.CanHaveSourceMap() && c.options.SourceMap != config.SourceMapNone { addSourceMappings = true - inputSourceMap = file.module.InputSourceMap + inputSourceMap = file.Module.InputSourceMap lineOffsetTables = dataForSourceMaps[partRange.sourceIndex].lineOffsetTables } @@ -3675,7 +3675,7 @@ func (c *linkerContext) generateEntryPointTailJS( sourceIndex uint32, ) (result compileResultJS) { file := &c.files[sourceIndex] - repr := file.module.Repr.(*graph.JSRepr) + repr := file.Module.Repr.(*graph.JSRepr) var stmts []js_ast.Stmt switch c.options.OutputFormat { @@ -3847,7 +3847,7 @@ func (c *linkerContext) generateEntryPointTailJS( // was eventually resolved to. We need to do this because imports have // already been resolved by this point, so we can't generate a new import // and have that be resolved later. - if importData, ok := c.files[export.SourceIndex].module.Repr.(*graph.JSRepr).Meta.ImportsToBind[export.Ref]; ok { + if importData, ok := c.files[export.SourceIndex].Module.Repr.(*graph.JSRepr).Meta.ImportsToBind[export.Ref]; ok { export.Ref = importData.Ref export.SourceIndex = importData.SourceIndex } @@ -3970,7 +3970,7 @@ func (c *linkerContext) renameSymbolsInChunk(chunk *chunkInfo, filesInOrder []ui // Determine the reserved names (e.g. can't generate the name "if") moduleScopes := make([]*js_ast.Scope, len(filesInOrder)) for i, sourceIndex := range filesInOrder { - moduleScopes[i] = c.files[sourceIndex].module.Repr.(*graph.JSRepr).AST.ModuleScope + moduleScopes[i] = c.files[sourceIndex].Module.Repr.(*graph.JSRepr).AST.ModuleScope } reservedNames := renamer.ComputeReservedNames(moduleScopes, c.symbols) @@ -3985,14 +3985,14 @@ func (c *linkerContext) renameSymbolsInChunk(chunk *chunkInfo, filesInOrder []ui // Determine the first top-level slot (i.e. not in a nested scope) var firstTopLevelSlots js_ast.SlotCounts for _, sourceIndex := range filesInOrder { - firstTopLevelSlots.UnionMax(c.files[sourceIndex].module.Repr.(*graph.JSRepr).AST.NestedScopeSlotCounts) + firstTopLevelSlots.UnionMax(c.files[sourceIndex].Module.Repr.(*graph.JSRepr).AST.NestedScopeSlotCounts) } r := renamer.NewMinifyRenamer(c.symbols, firstTopLevelSlots, reservedNames) // Accumulate symbol usage counts into their slots freq := js_ast.CharFreq{} for _, sourceIndex := range filesInOrder { - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if repr.AST.CharFreq != nil { freq.Include(repr.AST.CharFreq) } @@ -4050,7 +4050,7 @@ func (c *linkerContext) renameSymbolsInChunk(chunk *chunkInfo, filesInOrder []ui } for _, sourceIndex := range filesInOrder { - repr := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) var scopes []*js_ast.Scope // Modules wrapped in a CommonJS closure look like this: @@ -4156,7 +4156,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun chunk := &chunks[chunkIndex] chunkRepr := chunk.chunkRepr.(*chunkReprJS) compileResults := make([]compileResultJS, 0, len(chunk.partsInChunkInOrder)) - runtimeMembers := c.files[runtime.SourceIndex].module.Repr.(*graph.JSRepr).AST.ModuleScope.Members + runtimeMembers := c.files[runtime.SourceIndex].Module.Repr.(*graph.JSRepr).AST.ModuleScope.Members commonJSRef := js_ast.FollowSymbols(c.symbols, runtimeMembers["__commonJS"].Ref) esmRef := js_ast.FollowSymbols(c.symbols, runtimeMembers["__esm"].Ref) toModuleRef := js_ast.FollowSymbols(c.symbols, runtimeMembers["__toModule"].Ref) @@ -4256,7 +4256,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun isExecutable := false if chunk.isEntryPoint { - repr := c.files[chunk.sourceIndex].module.Repr.(*graph.JSRepr) + repr := c.files[chunk.sourceIndex].Module.Repr.(*graph.JSRepr) // Start with the hashbang if there is one if repr.AST.Hashbang != "" { @@ -4332,7 +4332,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun var aliases []string if c.options.OutputFormat.KeepES6ImportExportSyntax() { if chunk.isEntryPoint { - if fileRepr := c.files[chunk.sourceIndex].module.Repr.(*graph.JSRepr); fileRepr.Meta.Wrap == graph.WrapCJS { + if fileRepr := c.files[chunk.sourceIndex].Module.Repr.(*graph.JSRepr); fileRepr.Meta.Wrap == graph.WrapCJS { aliases = []string{"default"} } else { resolvedExports := fileRepr.Meta.ResolvedExports @@ -4363,7 +4363,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun jMeta.AddString("\n ") } if chunk.isEntryPoint { - entryPoint := c.files[chunk.sourceIndex].module.Source.PrettyPath + entryPoint := c.files[chunk.sourceIndex].Module.Source.PrettyPath jMeta.AddString(fmt.Sprintf("],\n \"entryPoint\": %s,\n \"inputs\": {", js_printer.QuoteForJSON(entryPoint, c.options.ASCIIOnly))) } else { jMeta.AddString("],\n \"inputs\": {") @@ -4397,7 +4397,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun j.AddString("\n") } - path := c.files[compileResult.sourceIndex].module.Source.PrettyPath + path := c.files[compileResult.sourceIndex].Module.Source.PrettyPath // Make sure newlines in the path can't cause a syntax error. This does // not minimize allocations because it's expected that this case never @@ -4437,7 +4437,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun // Include this file in the metadata if c.options.NeedsMetafile { // Accumulate file sizes since a given file may be split into multiple parts - path := c.files[compileResult.sourceIndex].module.Source.PrettyPath + path := c.files[compileResult.sourceIndex].Module.Source.PrettyPath if count, ok := metaByteCount[path]; ok { metaByteCount[path] = count + len(compileResult.JS) } else { @@ -4507,7 +4507,7 @@ func (c *linkerContext) generateChunkJS(chunks []chunkInfo, chunkIndex int, chun } else { jMeta.AddString(",") } - path := c.files[sourceIndex].module.Source.PrettyPath + path := c.files[sourceIndex].Module.Source.PrettyPath extra := c.generateExtraDataForFileJS(sourceIndex) jMeta.AddString(fmt.Sprintf("\n %s: {\n \"bytesInOutput\": %d\n %s}", js_printer.QuoteForJSON(path, c.options.ASCIIOnly), metaByteCount[path], extra)) @@ -4588,7 +4588,7 @@ func (c *linkerContext) generateChunkCSS(chunks []chunkInfo, chunkIndex int, chu waitGroup.Add(1) go func(sourceIndex uint32, compileResult *compileResultCSS) { file := &c.files[sourceIndex] - ast := file.module.Repr.(*graph.CSSRepr).AST + ast := file.Module.Repr.(*graph.CSSRepr).AST // Filter out "@import" rules rules := make([]css_ast.R, 0, len(ast.Rules)) @@ -4687,9 +4687,9 @@ func (c *linkerContext) generateChunkCSS(chunks []chunkInfo, chunkIndex int, chu // Do not generate "entryPoint" for CSS files that are the result of // importing CSS into JavaScript. We want this to be a 1:1 relationship // and there is already an output file for the JavaScript entry point. - if _, ok := file.module.Repr.(*graph.CSSRepr); ok { + if _, ok := file.Module.Repr.(*graph.CSSRepr); ok { jMeta.AddString(fmt.Sprintf("],\n \"entryPoint\": %s,\n \"inputs\": {", - js_printer.QuoteForJSON(file.module.Source.PrettyPath, c.options.ASCIIOnly))) + js_printer.QuoteForJSON(file.Module.Source.PrettyPath, c.options.ASCIIOnly))) } else { jMeta.AddString("],\n \"inputs\": {") } @@ -4705,7 +4705,7 @@ func (c *linkerContext) generateChunkCSS(chunks []chunkInfo, chunkIndex int, chu if newlineBeforeComment { j.AddString("\n") } - j.AddString(fmt.Sprintf("/* %s */\n", c.files[compileResult.sourceIndex].module.Source.PrettyPath)) + j.AddString(fmt.Sprintf("/* %s */\n", c.files[compileResult.sourceIndex].Module.Source.PrettyPath)) } if len(compileResult.printedCSS) > 0 { newlineBeforeComment = true @@ -4720,7 +4720,7 @@ func (c *linkerContext) generateChunkCSS(chunks []chunkInfo, chunkIndex int, chu jMeta.AddString(",") } jMeta.AddString(fmt.Sprintf("\n %s: {\n \"bytesInOutput\": %d\n }", - js_printer.QuoteForJSON(c.files[compileResult.sourceIndex].module.Source.PrettyPath, c.options.ASCIIOnly), + js_printer.QuoteForJSON(c.files[compileResult.sourceIndex].Module.Source.PrettyPath, c.options.ASCIIOnly), len(compileResult.printedCSS))) } } @@ -4847,20 +4847,20 @@ func (c *linkerContext) generateIsolatedHash(chunk *chunkInfo, channel chan []by var filePath string file := &c.files[partRange.sourceIndex] - if file.module.Source.KeyPath.Namespace == "file" { + if file.Module.Source.KeyPath.Namespace == "file" { // Use the pretty path as the file name since it should be platform- // independent (relative paths and the "/" path separator) - filePath = file.module.Source.PrettyPath + filePath = file.Module.Source.PrettyPath } else { // If this isn't in the "file" namespace, just use the full path text // verbatim. This could be a source of cross-platform differences if // plugins are storing platform-specific information in here, but then // that problem isn't caused by esbuild itself. - filePath = file.module.Source.KeyPath.Text + filePath = file.Module.Source.KeyPath.Text } // Include the path namespace in the hash - hashWriteLengthPrefixed(hash, []byte(file.module.Source.KeyPath.Namespace)) + hashWriteLengthPrefixed(hash, []byte(file.Module.Source.KeyPath.Namespace)) // Then include the file path hashWriteLengthPrefixed(hash, []byte(filePath)) @@ -4949,7 +4949,7 @@ func preventBindingsFromBeingRenamed(binding js_ast.Binding, symbols js_ast.Symb // This is only used when a module is compiled independently. We use a very // different way of handling exports and renaming/minifying when bundling. func (c *linkerContext) preventExportsFromBeingRenamed(sourceIndex uint32) { - repr, ok := c.files[sourceIndex].module.Repr.(*graph.JSRepr) + repr, ok := c.files[sourceIndex].Module.Repr.(*graph.JSRepr) if !ok { return } @@ -5041,14 +5041,14 @@ func (c *linkerContext) generateSourceMapForChunk( file := &c.files[result.sourceIndex] // Simple case: no nested source map - if file.module.InputSourceMap == nil { + if file.Module.InputSourceMap == nil { var quotedContents []byte if !c.options.ExcludeSourcesContent { quotedContents = dataForSourceMaps[result.sourceIndex].quotedContents[0] } items = append(items, item{ - path: file.module.Source.KeyPath, - prettyPath: file.module.Source.PrettyPath, + path: file.Module.Source.KeyPath, + prettyPath: file.Module.Source.PrettyPath, quotedContents: quotedContents, }) nextSourcesIndex++ @@ -5056,17 +5056,17 @@ func (c *linkerContext) generateSourceMapForChunk( } // Complex case: nested source map - sm := file.module.InputSourceMap + sm := file.Module.InputSourceMap for i, source := range sm.Sources { path := logger.Path{ - Namespace: file.module.Source.KeyPath.Namespace, + Namespace: file.Module.Source.KeyPath.Namespace, Text: source, } // If this file is in the "file" namespace, change the relative path in // the source map into an absolute path using the directory of this file if path.Namespace == "file" { - path.Text = c.fs.Join(c.fs.Dir(file.module.Source.KeyPath.Text), source) + path.Text = c.fs.Join(c.fs.Dir(file.Module.Source.KeyPath.Text), source) } var quotedContents []byte