-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(x_google_ignoreList): initial support for ignore lists
This patch introduces support for the `x_google_ignoreList` field to the `SourceMap` class. This extension was added to the Source Map Revision 3 Proposal[^1] to allow build tools to provide hints to debuggers (e.g. browser DevTools) about which files contain library or framework, and should thus be ignored by default for the purpose of stepping, break on exceptions, and the like[^2]. With this change it's possible for consumers of magic-string's `SourceMap` class to thread through and serialize the newly added `x_google_ignoreList` field (for example this is needed for rollup to support `x_google_ignoreList`). In a follow up change, we will also add support to the `Bundle` class to mark certain sources as ignore listed. [^1]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k [^2]: https://developer.chrome.com/blog/devtools-better-angular-debugging/
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]}'); | ||
}); | ||
}); | ||
}); |