Skip to content

Commit 6cc15e1

Browse files
authored
Merge pull request #481 from bomsy/master
Add support for the sourcemaps ignorelist
2 parents 4e304db + b2ddafe commit 6cc15e1

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

.DS_Store

10 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ following attributes:
240240

241241
- `file`: Optional. The generated filename this source map is associated with.
242242

243+
- `x_google_ignoreList`: Optional. An additional extension field which is an array
244+
of indices refering to urls in the sources array. This is used to identify third-party
245+
sources, that the developer might want to avoid when debugging. [Read more](https://developer.chrome.com/articles/x-google-ignore-list/)
246+
243247
The promise of the constructed souce map consumer is returned.
244248

245249
When the `SourceMapConsumer` will no longer be used anymore, you must call its

lib/source-map-consumer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
187187
const sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
188188
const mappings = util.getArg(sourceMap, "mappings");
189189
const file = util.getArg(sourceMap, "file", null);
190+
const x_google_ignoreList = util.getArg(
191+
sourceMap,
192+
"x_google_ignoreList",
193+
null
194+
);
190195

191196
// Once again, Sass deviates from the spec and supplies the version as a
192197
// string rather than a number, so we use loose equality checking here.
@@ -215,6 +220,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
215220
that._mappings = mappings;
216221
that._sourceMapURL = aSourceMapURL;
217222
that.file = file;
223+
that.x_google_ignoreList = x_google_ignoreList;
218224

219225
that._computedColumnSpans = false;
220226
that._mappingsPtr = 0;

test/test-source-map-consumer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ exports["test that the `sources` field has the original sources"] =
8888
map.destroy();
8989
};
9090

91+
exports["test that the SourceMapConsumer supports the ignoreList"] =
92+
async function (assert) {
93+
const map = await new SourceMapConsumer(util.testMapWithIgnoreList);
94+
const sources = map.sources;
95+
const ignoreList = map.x_google_ignoreList;
96+
assert.equal(ignoreList.length, 1);
97+
assert.equal(ignoreList[0], 0);
98+
assert.equal(sources[ignoreList[0]], "/the/root/one.js");
99+
map.destroy();
100+
};
101+
91102
exports["test that the source root is reflected in a mapping's source field"] =
92103
async function (assert) {
93104
let map;

test/util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ exports.testMap = {
3737
mappings:
3838
"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA",
3939
};
40+
41+
exports.testMapWithIgnoreList = {
42+
version: 3,
43+
file: "min.js",
44+
names: ["bar", "baz", "n"],
45+
sources: ["one.js", "two.js"],
46+
sourceRoot: "/the/root",
47+
mappings:
48+
"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA",
49+
x_google_ignoreList: [0],
50+
};
51+
4052
exports.testMapNoSourceRoot = {
4153
version: 3,
4254
file: "min.js",

wasm-mappings/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)