Skip to content

v1.3.0

Latest

Choose a tag to compare

@7rulnik 7rulnik released this 29 Nov 22:50
· 8 commits to main since this release

Minor Changes

  • Add SourceMapConsumer#ignoreList, the indices of the sources that are third-party code, and keep it in SourceMapGenerator.fromSourceMap() (#125)

    The consumer reads the map's ignoreList, or the deprecated x_google_ignoreList when there's no ignoreList. For an indexed map, it covers the sources of every section. A generator created with SourceMapGenerator.fromSourceMap() writes the consumer's ignored sources to ignoreList.

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#file on index source maps: it was always undefined, even when the map has a file (#130)

    SourceMapGenerator#applySourceMap() can now take the source file from an index map's file, as it does from a regular source map's. As ECMA-426 asks, a file that isn't a string is read as null. An index map without file still gives undefined.

  • Fix eachMapping() on index source maps dropping the name of every mapping that uses the first entry of a section's names (#128)

    SourceNode.fromStringWithSourceMap() lost those names too, since it reads the mappings with eachMapping(). originalPositionFor() wasn't affected. A name index outside a section's names now gives no name instead of throwing, as ECMA-426 allows.

  • Fix SourceMapGenerator#applySourceMap() and SourceNode.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 implemented on a section that has both map and url (#123)

    The section's map is now used and url is ignored, as ECMA-426 asks for properties it doesn't define. A section with a url and no map still throws.

  • Fix sourceContentFor() on index source maps throwing for a source that's in the map but has no content; it now returns null, 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 of null (#129)

    Also fix SourceNode.fromStringWithSourceMap() throwing Cannot 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() threw Invalid mapping on 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() returned line: 0 or a negative column for such a mapping, and SourceMapGenerator.fromSourceMap() threw Invalid mapping on it. As in the spec, the mapping keeps its name, and its original line and column still count for the next segment.

  • Read a sourcesContent entry that isn't a string as null, as ECMA-426 asks, instead of returning the value from sourceContentFor() (#143)

    hasContentsOfAllSources() counted such an entry as content, and SourceMapGenerator.fromSourceMap() copied it into its output.

  • Fix SourceMapGenerator.fromSourceMap() giving a source the wrong content, or none, when the map has a sourceRoot that its sources start with (#133)

    With sourceRoot: 'src', a source src/a.js lost its content, and with sources src/vendor.js and vendor.js, both got the content of vendor.js, even when src/vendor.js had none.

  • Fix decoding of positive and negative mapping deltas with magnitudes from 2^30 through 2^31 - 1 (#124)

    mappings stores 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.