Skip to content

Commit f0313fe

Browse files
committed
Add support for the sourcemaps ignorelist
Add support for the x_google_ignoreList to the SourceMapConsumer.
1 parent 4e304db commit f0313fe

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

.DS_Store

10 KB
Binary file not shown.

lib/source-map-consumer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ 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(sourceMap, "x_google_ignoreList", null);
190191

191192
// Once again, Sass deviates from the spec and supplies the version as a
192193
// string rather than a number, so we use loose equality checking here.
@@ -215,6 +216,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
215216
that._mappings = mappings;
216217
that._sourceMapURL = aSourceMapURL;
217218
that.file = file;
219+
that.x_google_ignoreList = x_google_ignoreList;
218220

219221
that._computedColumnSpans = false;
220222
that._mappingsPtr = 0;
@@ -799,6 +801,22 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
799801
return sources;
800802
}
801803

804+
/*
805+
*
806+
*/
807+
get x_google_ignoreList() {
808+
const x_google_ignoreList = [];
809+
for (let i = 0; i < this._sections.length; i++) {
810+
const ignoreList = this._sections[i].consumer.x_google_ignoreList;
811+
if (ignoreList) {
812+
for (let j = 0; j < ignoreList.length; j++) {
813+
x_google_ignoreList.push(ignoreList[j]);
814+
}
815+
}
816+
}
817+
return x_google_ignoreList;
818+
}
819+
802820
/**
803821
* Returns the original source, line, and column information for the generated
804822
* source's line and column positions provided. The only argument is an object

test/test-source-map-consumer.js

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

91+
exports["test that the SourceMapConsumer supports the ignoreList"] = async function (assert) {
92+
const map = await new SourceMapConsumer(util.testMapWithIgnoreList);
93+
const sources = map.sources;
94+
const ignoreList = map.x_google_ignoreList;
95+
assert.equal(ignoreList[0], 0);
96+
assert.equal(sources[ignoreList[0]], "/the/root/one.js");
97+
assert.equal(ignoreList.length, 1);
98+
map.destroy();
99+
}
100+
91101
exports["test that the source root is reflected in a mapping's source field"] =
92102
async function (assert) {
93103
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)