Repository navigation
Minor Changes
-
Add
SourceMapConsumer#ignoreList, the indices of the sources that are third-party code, and keep it inSourceMapGenerator.fromSourceMap()(#125)The consumer reads the map's
ignoreList, or the deprecatedx_google_ignoreListwhen there's noignoreList. For an indexed map, it covers the sources of every section. A generator created withSourceMapGenerator.fromSourceMap()writes the consumer's ignored sources toignoreList.
Patch Changes
-
Fix
SourceMapGenerator.fromSourceMap()throwing on the consumer of an index source map (#132)It threw
Cannot read properties of undefined (reading 'replace')for an index map with sources, and"<source>" is not in the SourceMap.for one with a source without content. -
Fix
SourceMapConsumer#fileon index source maps: it was alwaysundefined, even when the map has afile(#130)SourceMapGenerator#applySourceMap()can now take the source file from an index map'sfile, as it does from a regular source map's. As ECMA-426 asks, afilethat isn't a string is read asnull. An index map withoutfilestill givesundefined. -
Fix
eachMapping()on index source maps dropping the name of every mapping that uses the first entry of a section'snames(#128)SourceNode.fromStringWithSourceMap()lost those names too, since it reads the mappings witheachMapping().originalPositionFor()wasn't affected. A name index outside a section'snamesnow gives no name instead of throwing, as ECMA-426 allows. -
Fix
SourceMapGenerator#applySourceMap()andSourceNode.fromStringWithSourceMap()throwing"<source>" is not in the SourceMap.for an index source map with a source that has no content (#131) -
Fix index source maps throwing
Support for url field in sections not implementedon a section that has bothmapandurl(#123)The section's
mapis now used andurlis ignored, as ECMA-426 asks for properties it doesn't define. A section with aurland nomapstill throws. -
Fix
sourceContentFor()on index source maps throwing for a source that's in the map but has no content; it now returnsnull, as on regular source maps (#142)A source that isn't in the map still throws
"<source>" is not in the SourceMap. -
Fix
eachMapping()on index source maps giving a mapping without an original position the source"."instead ofnull(#129)Also fix
SourceNode.fromStringWithSourceMap()throwingCannot read properties of null (reading 'match')when it's given a relative path and the source map has code without an original position. -
Drop mappings with a negative generated column, as ECMA-426 asks, instead of keeping them at that column (#135)
Only invalid source maps have them.
SourceMapGenerator.fromSourceMap()threwInvalid mappingon such a mapping. The other fields of a dropped segment still count for the next segment, as before, so the next segments decode as they did. -
Keep a mapping with a negative original line or column without its original position, as ECMA-426 asks, instead of returning line 0 or a negative column (#137)
Only invalid source maps have them.
originalPositionFor()returnedline: 0or a negativecolumnfor such a mapping, andSourceMapGenerator.fromSourceMap()threwInvalid mappingon it. As in the spec, the mapping keeps its name, and its original line and column still count for the next segment. -
Read a
sourcesContententry that isn't a string asnull, as ECMA-426 asks, instead of returning the value fromsourceContentFor()(#143)hasContentsOfAllSources()counted such an entry as content, andSourceMapGenerator.fromSourceMap()copied it into its output. -
Fix
SourceMapGenerator.fromSourceMap()giving a source the wrong content, or none, when the map has asourceRootthat its sources start with (#133)With
sourceRoot: 'src', a sourcesrc/a.jslost its content, and with sourcessrc/vendor.jsandvendor.js, both got the content ofvendor.js, even whensrc/vendor.jshad none. -
Fix decoding of positive and negative mapping deltas with magnitudes from 2^30 through 2^31 - 1 (#124)
mappingsstores each line, column and index as a delta from the previous one. ECMA-426 allows deltas up to 2^31 - 1 either way. The generator already encoded them correctly, but the consumer read those from 2^30 (1,073,741,824) on with the wrong sign: 2^30 as -2^30, and 2^31 - 1 as -1.