- Add support for sourcemap
debugId
property (#292) (ef531a8)
- not use negative indices for remove in empty string (#281) (5c1cba0)
- avoid create uncessary overrides for
replace
(a1b857c)
- handle last empty line correctly when using update/overwrite (#274) (29c7bfa)
- support Web Workers by using the global
btoa
(#269) (8679648)
- correct mappings for update containing new line (#261) (adaece9)
- use global
btoa
, support services worker, close #258 (#259) (2dea20b)
- add the ability to ignore-list sources (#243) (e238f04)
- x_google_ignoreList: initial support for ignore lists (3c711cd)
- typings: sourcesContent may contain null (#235) (c2b652a)
- use @jridgewell/sourcemap-codec (e68f3e0)
- add
update
method as safer alternative to overwrite
(#212) (9a312e3)
- update typescript definition file to contain
replaceAll()
(#224) (45a4921)
- fix
.replace()
when searching string, add .replaceAll()
(#222) (04a05bd)
- avoiding use of Object.defineProperty in Chunk constructor (#219) (130794b)
- replace: match replacer function signature with spec (902541f)
- Support of Node.js v10 is dropped. Now
magic-string
requires Node.js v12 or higher. (#204)
- ESM bundle is now shipped with
.mjs
extension (#197)
- "module": "dist/magic-string.es.js",
+ "module": "dist/magic-string.es.mjs",
+ "exports": {
+ "./package.json": "./package.json",
+ ".": {
+ "import": "./dist/magic-string.es.mjs",
+ "require": "./dist/magic-string.cjs.js"
+ }
+ },
- allowed overwrite across moved content preceded by split (#192) (403fa86)
- types: make options partial by default (2815e77)
- use defineProperty for appending prop in
storeName
(#194) (96b7cd3)
- types: mark
MagicString
options as optional (#183) (15c3e66)
- fix bundle mappings after remove and move in multiple sources (#172)
- Use bitwise operators for small performance boost (#171)
- Use a bitset to reduce memory consumption (#167)
- Clone
intro
and outro
(#162)
- Fix typing of
SourceMap.version
.
- Remove deprecated
new Buffer(...)
- Handle characters outside Latin1 range when generating a sourcemap in browser (#154)
- Additional types for index.d.ts (#148)
- Add
length
method (#145)
- Fix trimming chunks with intro/outro (#144)
- Add
lastLine
and lastChar
methods (#142)
- Add
isEmpty
methods (#137)
- Fix a potential race condition (#136)
- Fix CJS/ES bundles inlining
sourcemap-codec
in 0.23.2.
- Add
generateDecodedMap
methods (#134)
- Use
sourcemap-codec
for improved performance (#133)
- Add TypeScript interfaces used by rollup (#131)
- Remove src directory from npm package
contentOnly
and storeName
are both optional
- Add
original
to TS definitions
- Avoid
declare module
(#127)
- Update TypeScript definitions (#124)
- Prevent
overwrite
state corruption (#115)
- Various bugfixes (#126)
- Clone
indentExclusionRanges
correctly (#122)
- Fix more typings (#122)
- Add
default
property referencing self in index-legacy.js, to work around TypeScript bug (#121)
- Add typings file to package
- Add TypeScript bindings (#119)
- The fourth argument to
overwrite
is a {storeName, contentOnly}
options object. storeName: true
is equivalent to true
before. contentOnly
will preserve existing appends/prepends to the chunk in question
- Prevent overwrites across a split point (i.e. following a
move
)
- Implement
remove
separately to overwrite
- More accurate bundle sourcemaps (#114)
- Optimisation – remove empty chunks following
overwrite
or remove
(#113)
- Add
appendLeft
, appendRight
, prependLeft
, prependRight
methods (#109)
insertLeft
and insertRight
are deprecated in favour of appendLeft
and prependRight
respectively
- Include inserts in range for
overwrite
and remove
operations (#89)
- Make options optional for
bundle.generateMap(...)
(#73)
- Generate correct bundle sourcemap with prepended/appended content
- Use named export of
Bundle
in ES build, so ES consumers of magic-string can tree-shake it out
- Throw if overwrite of zero-length range is attempted
- Correctly handle redundant move operations
- Fix a bevy of
s.slice()
issues (#62)
- Breaking:
insertAfter
is now insertLeft
, insertBefore
is now insertRight
- Breaking:
insert
is no longer available. Use insertLeft
and insertRight
- Significant performance improvements
- Fix sourcemap generation with
insertAfter
and insertBefore
- Add
insertAfter
and insertBefore
methods
- Fix two regression bugs with
trim()
- More informative error message on illegal removals
- Fix trim methods to ensure correct sourcemaps with trimmed content (#53)
- Support sourcemaps with moved content
- Use
findIndex
helper for 0.12 support
- Add experimental
move()
method
- Refactor internals to support
move()
- Do not overwrite inserts at the end of patched ranges (#35)
- Zero-length inserts are not removed on adjacent overwrites
- Complete rewrite, resulting in ~40x speed increase (#30)
- Breaking –
magicString.locate
and locateOrigin
are deprecated
- More forgiving rules about contiguous patches, and which ranges are valid with
magicString.slice(...)
- Add an ES6 build, change default UMD build to CommonJS (but keeping existing UMD build with bundled dependencies)
- Make properties non-enumerable, for cleaner logging
- Update dependencies
- The
names
array is populated when generating sourcemaps, and mappings include name indices where appropriate (#16)
- Replaced content is mapped correctly in sourcemaps (#15)
- Adjust mappings correctly when removing replaced content
- Error correctly when removed characters are used as slice anchors
- Fix
jsnext:main
in package.json
- Fix bug with positive integer coercion
- Intro content is correctly indented
- Content following an intro with trailing newline is correctly indented
- Noop indents are still chainable (fixes bug introduced in 0.6.1)
- Indenting with an empty string is a noop
- Use rollup for bundling, instead of esperanto
- Correct sourcemap generation with bundles containing varied separators
s.clone()
clones indent exclusion ranges and sourcemap locations
s.slice()
accepts negative numbers, and the second argument can be omitted (means 'original string length'), just like String.prototype.slice
- More informative error message when trying to overwrite content illegally
- Allow bundle separator to be the empty string
- Indenting is handled correctly with empty string separator
s.replace()
is deprecated in favour of s.overwrite()
(identical signature)
bundle.addSource()
can take a MagicString
instance as its sole argument, for convenience
- The
options
in new MagicString(str, options)
can include filename
and indentExclusionRanges
options, which will be used when bundling
- New method:
s.snip( start, end )
file
option is optional when generating a bundle sourcemap
- Repeated insertions at position 0 behave the same as other positions (#10)
- Overlapping ranges can be removed
- Non-string content is rejected (#9)
- Implement
source.addSourcemapLocation()
- Another Windows fix, this time for file paths when bundling
- Handle Windows-style CRLF newlines when determining whether a line is empty
- Fix typo in package.json (d'oh again)
- Use only relative paths for internal modules - makes bundling with dependents (i.e. esperanto) possible
- Includes correct files in npm package (d'oh)
- Fixes a bug whereby multiple insertions at the same location would cause text to repeat (#5)
- Breaking change -
source.indentStr
is null
if no lines are indented. Use source.getIndentString()
for the old behaviour (guess, and if no lines are indented, return \t
)
bundle.getIndentString()
ignores sources with no indented lines when guessing indentation (#3)
source.trimLines()
removes empty lines from start/end of source, leaving other whitespace untouched
- Indentation is not added to an empty source
- Performance improvement - adjustments are only made when necessary
- Single spaces are ignored when guessing indentation - experience shows these are more likely to be e.g. JSDoc comments than actual indentation
bundle.addSource()
can take an indentExclusionRanges
option
- Empty lines are not indented
- Fixes edge case with bundle sourcemaps
- Make
sources
paths in sourcemaps relative to options.file
- Minor fix for
bundle.indent()
- Implement
MagicString.Bundle
for concatenating magic strings
- Better performance when indenting large chunks of code
- Sourcemaps generated with
s.generateMap()
have a toUrl()
method that generates a DataURI
- Implement
s.insert( index, content )
- roughly equivalent to s.replace( index, index, content )
- Version bump for npm's benefit
s.indent({ exclude: [ x, y ] })
prevents lines between (original) characters x
and y
from being indented. Multiple exclusion ranges are also supported (e.g. exclude: [[a, b], [c, d]]
)
s.locate()
doesn't throw out-of-bound error if index is equal to original string's length
s.trim()
returns this
(i.e. is chainable)