diff --git a/internal/bundler/bundler.go b/internal/bundler/bundler.go index 0d193c35..3a665c5f 100644 --- a/internal/bundler/bundler.go +++ b/internal/bundler/bundler.go @@ -29,7 +29,6 @@ import ( "github.com/evanw/esbuild/internal/logger" "github.com/evanw/esbuild/internal/resolver" "github.com/evanw/esbuild/internal/runtime" - "github.com/evanw/esbuild/internal/sourcemap" "github.com/evanw/esbuild/internal/xxhash" ) @@ -43,7 +42,6 @@ const ( type file struct { module graph.Module - sourceMap *sourcemap.SourceMap pluginData interface{} // The minimum number of links in the module graph to get from an entry point @@ -486,7 +484,7 @@ func parseFile(args parseArgs) { if repr, ok := result.file.module.Repr.(*graph.JSRepr); ok && repr.AST.SourceMapComment.Text != "" { if path, contents := extractSourceMapFromComment(args.log, args.fs, &args.caches.FSCache, args.res, &source, repr.AST.SourceMapComment, absResolveDir); contents != nil { - result.file.sourceMap = js_parser.ParseSourceMap(args.log, logger.Source{ + result.file.module.InputSourceMap = js_parser.ParseSourceMap(args.log, logger.Source{ KeyPath: path, PrettyPath: args.res.PrettyPath(path), Contents: *contents, @@ -2042,7 +2040,7 @@ func (b *Bundle) computeDataForSourceMapsInParallel(options *config.Options, rea go func(sourceIndex uint32, f *file, repr *graph.JSRepr) { result := &results[sourceIndex] result.lineOffsetTables = js_printer.GenerateLineOffsetTables(f.module.Source.Contents, repr.AST.ApproximateLineCount) - sm := f.sourceMap + sm := f.module.InputSourceMap if !options.ExcludeSourcesContent { if sm == nil { // Simple case: no nested source map diff --git a/internal/bundler/linker.go b/internal/bundler/linker.go index 2797674a..2c6db27b 100644 --- a/internal/bundler/linker.go +++ b/internal/bundler/linker.go @@ -3633,7 +3633,7 @@ func (c *linkerContext) generateCodeForFileInChunkJS( var lineOffsetTables []js_printer.LineOffsetTable if file.module.Loader.CanHaveSourceMap() && c.options.SourceMap != config.SourceMapNone { addSourceMappings = true - inputSourceMap = file.sourceMap + inputSourceMap = file.module.InputSourceMap lineOffsetTables = dataForSourceMaps[partRange.sourceIndex].lineOffsetTables } @@ -5041,7 +5041,7 @@ func (c *linkerContext) generateSourceMapForChunk( file := &c.files[result.sourceIndex] // Simple case: no nested source map - if file.sourceMap == nil { + if file.module.InputSourceMap == nil { var quotedContents []byte if !c.options.ExcludeSourcesContent { quotedContents = dataForSourceMaps[result.sourceIndex].quotedContents[0] @@ -5056,7 +5056,7 @@ func (c *linkerContext) generateSourceMapForChunk( } // Complex case: nested source map - sm := file.sourceMap + sm := file.module.InputSourceMap for i, source := range sm.Sources { path := logger.Path{ Namespace: file.module.Source.KeyPath.Namespace, diff --git a/internal/graph/module.go b/internal/graph/module.go index ae15eea2..fc8a5f4f 100644 --- a/internal/graph/module.go +++ b/internal/graph/module.go @@ -7,13 +7,15 @@ import ( "github.com/evanw/esbuild/internal/js_ast" "github.com/evanw/esbuild/internal/logger" "github.com/evanw/esbuild/internal/resolver" + "github.com/evanw/esbuild/internal/sourcemap" ) type Module struct { - Source logger.Source - Repr ModuleRepr - Loader config.Loader - SideEffects SideEffects + Source logger.Source + Repr ModuleRepr + Loader config.Loader + SideEffects SideEffects + InputSourceMap *sourcemap.SourceMap // If this file ends up being used in the bundle, these are additional files // that must be written to the output directory. It's used by the "file"