diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..bf67d3d6 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 1d2741df..72402e35 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,10 @@ following attributes: - `file`: Optional. The generated filename this source map is associated with. +- `x_google_ignoreList`: Optional. An additional extension field which is an array + 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/) + The promise of the constructed souce map consumer is returned. When the `SourceMapConsumer` will no longer be used anymore, you must call its diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index b2db4d55..be1289d9 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -187,6 +187,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer { const sourcesContent = util.getArg(sourceMap, "sourcesContent", null); const mappings = util.getArg(sourceMap, "mappings"); const file = util.getArg(sourceMap, "file", null); + const x_google_ignoreList = util.getArg( + sourceMap, + "x_google_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. @@ -215,6 +220,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer { that._mappings = mappings; that._sourceMapURL = aSourceMapURL; that.file = file; + that.x_google_ignoreList = x_google_ignoreList; that._computedColumnSpans = false; that._mappingsPtr = 0; diff --git a/test/test-source-map-consumer.js b/test/test-source-map-consumer.js index 23b2a34f..1bc09b85 100644 --- a/test/test-source-map-consumer.js +++ b/test/test-source-map-consumer.js @@ -88,6 +88,17 @@ exports["test that the `sources` field has the original sources"] = map.destroy(); }; +exports["test that the SourceMapConsumer supports the ignoreList"] = + async function (assert) { + const map = await new SourceMapConsumer(util.testMapWithIgnoreList); + const sources = map.sources; + const ignoreList = map.x_google_ignoreList; + assert.equal(ignoreList.length, 1); + assert.equal(ignoreList[0], 0); + assert.equal(sources[ignoreList[0]], "/the/root/one.js"); + map.destroy(); + }; + exports["test that the source root is reflected in a mapping's source field"] = async function (assert) { let map; diff --git a/test/util.js b/test/util.js index fe2fc641..d99669c3 100644 --- a/test/util.js +++ b/test/util.js @@ -37,6 +37,18 @@ exports.testMap = { mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA", }; + +exports.testMapWithIgnoreList = { + version: 3, + file: "min.js", + names: ["bar", "baz", "n"], + sources: ["one.js", "two.js"], + sourceRoot: "/the/root", + mappings: + "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA", + x_google_ignoreList: [0], +}; + exports.testMapNoSourceRoot = { version: 3, file: "min.js", diff --git a/wasm-mappings/.DS_Store b/wasm-mappings/.DS_Store new file mode 100644 index 00000000..b30e622b Binary files /dev/null and b/wasm-mappings/.DS_Store differ