From 1c3124ab2e235766d7e8e375970b9a79d1bab3a7 Mon Sep 17 00:00:00 2001 From: Hanabi9248 Date: Wed, 9 Sep 2026 08:45:00 +0800 Subject: [PATCH 1/4] Support the standard ignoreList source map field --- lib/source-map-consumer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index 7381a668..6c95a91c 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -220,6 +220,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer { that._mappings = mappings; that._sourceMapURL = aSourceMapURL; that.file = file; + that.ignoreList = util.getArg( + sourceMap, + "ignoreList", + x_google_ignoreList + ); that.x_google_ignoreList = x_google_ignoreList; that._computedColumnSpans = false; From 703ddad4b6e0e212c32d2eec4672a75ff6c4556e Mon Sep 17 00:00:00 2001 From: Hanabi9248 Date: Wed, 9 Sep 2026 08:46:08 +0800 Subject: [PATCH 2/4] Test standard and legacy ignoreList precedence --- test/test-ignore-list.js | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/test-ignore-list.js diff --git a/test/test-ignore-list.js b/test/test-ignore-list.js new file mode 100644 index 00000000..1caf6753 --- /dev/null +++ b/test/test-ignore-list.js @@ -0,0 +1,49 @@ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + +const { SourceMapConsumer } = require("../source-map"); + +const cases = [ + ["standard field", { ignoreList: [1] }, [1]], + ["legacy fallback", { x_google_ignoreList: [0] }, [0]], + ["standard precedence", { ignoreList: [1], x_google_ignoreList: [0] }, [1]], + ["empty standard field", { ignoreList: [], x_google_ignoreList: [0] }, []], + ["absent fields", {}, null], +]; + +for (const [name, fields, expected] of cases) { + exports["test ignoreList " + name] = async function (assert) { + const raw = { + version: 3, + sources: ["app.js", "vendor.js"], + names: [], + mappings: "AAAA,CCAA", + ...fields, + }; + for (const input of [raw, JSON.stringify(raw)]) { + await SourceMapConsumer.with(input, null, consumer => { + if (expected === null) { + assert.strictEqual(consumer.ignoreList, null); + } else { + assert.ok(Array.isArray(consumer.ignoreList)); + assert.equal(consumer.ignoreList.length, expected.length); + expected.forEach((sourceIndex, i) => { + assert.equal(consumer.ignoreList[i], sourceIndex); + assert.equal( + consumer.sources[sourceIndex], + raw.sources[sourceIndex] + ); + }); + } + // The legacy property continues to reflect only the legacy input. + assert.equal( + JSON.stringify(consumer.x_google_ignoreList), + JSON.stringify(fields.x_google_ignoreList || null) + ); + }); + } + }; +} From 5fa15c3aa403f0ad40b73f7d4e362d6d447b8868 Mon Sep 17 00:00:00 2001 From: Hanabi9248 Date: Wed, 9 Sep 2026 08:47:39 +0800 Subject: [PATCH 3/4] Declare standard and legacy ignoreList fields --- source-map.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source-map.d.ts b/source-map.d.ts index 45646052..59f6256e 100644 --- a/source-map.d.ts +++ b/source-map.d.ts @@ -20,6 +20,8 @@ export interface RawSourceMap { sourcesContent?: string[]; mappings: string; file: string; + ignoreList?: number[]; + x_google_ignoreList?: number[]; } export interface RawIndexMap extends StartOfSourceMap { @@ -294,6 +296,8 @@ export interface BasicSourceMapConsumer extends SourceMapConsumer { sourceRoot: string; sources: string[]; sourcesContent: string[]; + ignoreList: number[] | null; + x_google_ignoreList: number[] | null; } export interface BasicSourceMapConsumerConstructor { From 437f79a6f96c1669299b69c379a02964f84d9974 Mon Sep 17 00:00:00 2001 From: Hanabi9248 Date: Wed, 9 Sep 2026 08:50:22 +0800 Subject: [PATCH 4/4] Document standard ignoreList precedence and compatibility --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 3e78caf0..9498bade 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,12 @@ following attributes: of indices refering to urls in the sources array. This is used to identify third-party sources, that the developer might want to avoid when debugging. [Read more](https://developer.chrome.com/articles/x-google-ignore-list/) +A `BasicSourceMapConsumer` also exposes the standard `ignoreList` field described +in the [source map specification](https://tc39.es/ecma426/#sec-source-map-format). +It falls back to `x_google_ignoreList` only when `ignoreList` is absent, or `null` +when neither is present. An explicit empty array takes precedence over the +legacy field. The `x_google_ignoreList` property retains the legacy field's value. + The promise of the constructed souce map consumer is returned. When the `SourceMapConsumer` will no longer be used anymore, you must call its