diff --git a/index.d.ts b/index.d.ts index 2ffe0e9..2ec2bba 100644 --- a/index.d.ts +++ b/index.d.ts @@ -38,6 +38,7 @@ export interface DecodedSourceMap { sourcesContent: (string | null)[]; names: string[]; mappings: SourceMapSegment[][]; + x_google_ignoreList?: number[]; } export class SourceMap { @@ -49,6 +50,7 @@ export class SourceMap { sourcesContent: (string | null)[]; names: string[]; mappings: string; + x_google_ignoreList?: number[]; /** * Returns the equivalent of `JSON.stringify(map)` diff --git a/src/SourceMap.js b/src/SourceMap.js index feb1e02..9389315 100644 --- a/src/SourceMap.js +++ b/src/SourceMap.js @@ -22,6 +22,9 @@ export default class SourceMap { this.sourcesContent = properties.sourcesContent; this.names = properties.names; this.mappings = encode(properties.mappings); + if (typeof properties.x_google_ignoreList !== 'undefined') { + this.x_google_ignoreList = properties.x_google_ignoreList; + } } toString() { diff --git a/test/MagicString.SourceMap.js b/test/MagicString.SourceMap.js new file mode 100644 index 0000000..257b010 --- /dev/null +++ b/test/MagicString.SourceMap.js @@ -0,0 +1,36 @@ +const assert = require('assert'); +const MagicString = require('../'); + +require('source-map-support').install(); + +describe('MagicString.SourceMap', () => { + describe('options', () => { + it('preserves ignore list information', () => { + const map = new MagicString.SourceMap({ + file: 'foo.min.js', + sources: ['foo.js'], + sourcesContent: ['42'], + names: [], + mappings: [[0, 0]], + x_google_ignoreList: [0] + }); + + assert.deepEqual(map.x_google_ignoreList, [0]); + }); + }); + + describe('toString', () => { + it('serializes ignore list information', () => { + const map = new MagicString.SourceMap({ + file: 'foo.min.js', + sources: ['foo.js'], + sourcesContent: ['42'], + names: [], + mappings: [[0, 0]], + x_google_ignoreList: [0] + }); + + assert.equal(map.toString(), '{"version":3,"file":"foo.min.js","sources":["foo.js"],"sourcesContent":["42"],"names":[],"mappings":"AAAAA,AAAAA","x_google_ignoreList":[0]}'); + }); + }); +});