Skip to content

Commit 209c42d

Browse files
authoredFeb 11, 2023
Merge pull request #240 from bmeurer/feat/x_google_ignoreList
feat(x_google_ignoreList): initial support for ignore lists
2 parents 74cba9f + 3c711cd commit 209c42d

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface DecodedSourceMap {
3838
sourcesContent: (string | null)[];
3939
names: string[];
4040
mappings: SourceMapSegment[][];
41+
x_google_ignoreList?: number[];
4142
}
4243

4344
export class SourceMap {
@@ -49,6 +50,7 @@ export class SourceMap {
4950
sourcesContent: (string | null)[];
5051
names: string[];
5152
mappings: string;
53+
x_google_ignoreList?: number[];
5254

5355
/**
5456
* Returns the equivalent of `JSON.stringify(map)`

‎src/SourceMap.js

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export default class SourceMap {
2222
this.sourcesContent = properties.sourcesContent;
2323
this.names = properties.names;
2424
this.mappings = encode(properties.mappings);
25+
if (typeof properties.x_google_ignoreList !== 'undefined') {
26+
this.x_google_ignoreList = properties.x_google_ignoreList;
27+
}
2528
}
2629

2730
toString() {

‎test/MagicString.SourceMap.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const assert = require('assert');
2+
const MagicString = require('../');
3+
4+
require('source-map-support').install();
5+
6+
describe('MagicString.SourceMap', () => {
7+
describe('options', () => {
8+
it('preserves ignore list information', () => {
9+
const map = new MagicString.SourceMap({
10+
file: 'foo.min.js',
11+
sources: ['foo.js'],
12+
sourcesContent: ['42'],
13+
names: [],
14+
mappings: [[0, 0]],
15+
x_google_ignoreList: [0]
16+
});
17+
18+
assert.deepEqual(map.x_google_ignoreList, [0]);
19+
});
20+
});
21+
22+
describe('toString', () => {
23+
it('serializes ignore list information', () => {
24+
const map = new MagicString.SourceMap({
25+
file: 'foo.min.js',
26+
sources: ['foo.js'],
27+
sourcesContent: ['42'],
28+
names: [],
29+
mappings: [[0, 0]],
30+
x_google_ignoreList: [0]
31+
});
32+
33+
assert.equal(map.toString(), '{"version":3,"file":"foo.min.js","sources":["foo.js"],"sourcesContent":["42"],"names":[],"mappings":"AAAAA,AAAAA","x_google_ignoreList":[0]}');
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)