Repository navigation
Releases
v1.2.4
Index source maps
-
Fix
originalPositionForreturning nulls at the first column of a section (#99) -
Fix a section's column offset being applied to its second line instead of its first (#104)
This affected sections with both a line and a column offset, in
eachMapping,generatedPositionFor,SourceMapGenerator.fromSourceMapandSourceNode.fromStringWithSourceMap. -
Support
allGeneratedPositionsFor(#105)It threw
TypeError: this._findSourceIndex is not a function. It now returns the same results as for the equivalent map without sections, with positions from every section that has the source.generatedPositionForon nested index maps threw the same error and works now too. -
Fix
generatedPositionForreturning made-up positions (#115)It only searched the first section that listed the source, and when that section had no match, it returned the section offset added to
null. It now searches all sections, sobiaspicks the closest mapping across them, and returns nulls when nothing matches. -
Add
computeColumnSpans(#116)
Other fixes
-
Fix
generatedPositionFor,allGeneratedPositionsForandeachMappingwithORIGINAL_ORDERthrowingTypeErrorwhen a source has no mappings (#100)Reported by @trackoor in #83. This is common in bundles, where a source can be listed after its code was tree-shaken away.
-
Fix
allGeneratedPositionsForreturning positions that belong to a different source (#102) -
Fix lookups throwing
RangeError: Maximum call stack size exceededon source maps with about 200,000 or more sources (#113) -
Fix
SourceNode#replaceRightthrowing on a node without children (#114)
TypeScript
-
Fix type definitions that didn't match the runtime, without breaking changes (#117)
SourceMapConsumeracceptsversionas a number,nullentries insourcesContent, a missingnames, index maps, JSON strings and thesourceMapUrlargument. Reported by @linsk1998 in #43; a fix forsourcesContentwas proposed by @lahmatiy in #75.SourceMapConsumer.fromSourceMapis declared, andallGeneratedPositionsFortakes an optionalcolumnand returnslastColumn.- The
skipValidationandignoreInvalidMappingoptions ofSourceMapGeneratorare typed. SourceNodeacceptsnulls and chunk arrays in the constructor, nested arrays inaddandprepend, and a RegExp or a replacer function inreplaceRight.
Return types that would need a breaking change, such as the
nulls fromoriginalPositionFor(#30), are documented in comments and left for the next major (#118).
Package
-
Set
engines.nodeto>=6.0.0(#97)The library already failed to load on older Node versions, so this only adds an install warning there.
v1.2.3
-
Fix CSP violation reported in browsers that don't permit unsafe-eval (#85)
Reported by @Viktor-Ivliev in #81. The library no longer uses
new Functionat all. As a side effect, sorting mappings is ~40% faster on Node 22, 24 and 26: consuming source maps is up to 40% faster, andSourceMapConsumer.fromSourceMap20–40% faster.
v1.2.2
v1.2.1
-
Fix TS2306 “not a module” errors in type definitions (#16) @andersk
-
Ensure null source is respected (#26) @dragomirtitian
-
Improve ts declarations to be null-safe (#27) @dragomirtitian
v1.2.0
v1.1.0
Add ignoreInvalidMapping option to SourceMapGenerator. If enabled, source-map-js will not throw an error on the incorrect previous source map. Instead, it will print warnings and ignore broken mappings.
var generator = new sourceMap.SourceMapGenerator({
file: "my-generated-javascript-file.js",
sourceRoot: "http://example.com/app/js/",
ignoreInvalidMapping: true,
});