diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index 17ef92b1..97d958da 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -192,6 +192,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer { "x_google_ignoreList", null ); + // Support the renamed `ignoreList` field (spec rename of x_google_ignoreList). + const ignoreList = util.getArg(sourceMap, "ignoreList", null); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. @@ -220,7 +222,8 @@ class BasicSourceMapConsumer extends SourceMapConsumer { that._mappings = mappings; that._sourceMapURL = aSourceMapURL; that.file = file; - that.x_google_ignoreList = x_google_ignoreList; + that.x_google_ignoreList = x_google_ignoreList || ignoreList; + that.ignoreList = that.x_google_ignoreList; that._computedColumnSpans = false; that._wasmMappings = null; @@ -283,7 +286,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer { * @returns BasicSourceMapConsumer */ static fromSourceMap(aSourceMap, aSourceMapURL) { - return new BasicSourceMapConsumer(aSourceMap.toString()); + return new BasicSourceMapConsumer(aSourceMap.toString(), aSourceMapURL); } get sources() { @@ -458,6 +461,10 @@ class BasicSourceMapConsumer extends SourceMapConsumer { generatedColumn: util.getArg(aArgs, "column"), }; + if (needle.generatedLine == null || needle.generatedColumn == null) { + throw new Error("line and column must be provided"); + } + if (needle.generatedLine < 1) { throw new Error("Line numbers must be >= 1"); } diff --git a/lib/source-map-generator.js b/lib/source-map-generator.js index 847017fa..e705ddc1 100644 --- a/lib/source-map-generator.js +++ b/lib/source-map-generator.js @@ -30,6 +30,8 @@ class SourceMapGenerator { this._names = new ArraySet(); this._mappings = new MappingList(); this._sourcesContents = null; + this._ignoreList = util.getArg(aArgs, "ignoreList", null) || + util.getArg(aArgs, "x_google_ignoreList", null); } /** @@ -417,6 +419,9 @@ class SourceMapGenerator { if (this._sourceRoot != null) { map.sourceRoot = this._sourceRoot; } + if (this._ignoreList) { + map.ignoreList = this._ignoreList; + } if (this._sourcesContents) { map.sourcesContent = this._generateSourcesContent( map.sources, diff --git a/lib/source-node.js b/lib/source-node.js index 4d7cd3ed..84532194 100644 --- a/lib/source-node.js +++ b/lib/source-node.js @@ -355,6 +355,7 @@ class SourceNode { generated.code += chunk; if ( original.source !== null && + original.source !== "" && original.line !== null && original.column !== null ) { diff --git a/source-map.d.ts b/source-map.d.ts index 45646052..119962f6 100644 --- a/source-map.d.ts +++ b/source-map.d.ts @@ -381,7 +381,7 @@ export class SourceMapGenerator { } export class SourceNode { - children: SourceNode[]; + children: (SourceNode | string)[]; sourceContents: any; line: number; column: number;