contentOnly
and storeName
are both optionaloriginal
to TS definitionsdeclare module
(#127)default
property referencing self in index-legacy.js, to work around TypeScript bug (#121)overwrite
is a {storeName, contentOnly}
options object. storeName: true
is equivalent to true
before. contentOnly
will preserve existing appends/prepends to the chunk in questionmove
)remove
separately to overwrite
overwrite
or remove
(#113)appendLeft
, appendRight
, prependLeft
, prependRight
methods (#109)insertLeft
and insertRight
are deprecated in favour of appendLeft
and prependRight
respectivelyoverwrite
and remove
operations (#89)bundle.generateMap(...)
(#73)Bundle
in ES build, so ES consumers of magic-string can tree-shake it outs.slice()
issues (#62)insertAfter
is now insertLeft
, insertBefore
is now insertRight
insert
is no longer available. Use insertLeft
and insertRight
insertAfter
and insertBefore
insertAfter
and insertBefore
methodstrim()
findIndex
helper for 0.12 supportmove()
methodmove()
magicString.locate
and locateOrigin
are deprecatedmagicString.slice(...)
names
array is populated when generating sourcemaps, and mappings include name indices where appropriate (#16)jsnext:main
in package.jsons.clone()
clones indent exclusion ranges and sourcemap locationss.slice()
accepts negative numbers, and the second argument can be omitted (means 'original string length'), just like String.prototype.slice
s.replace()
is deprecated in favour of s.overwrite()
(identical signature)bundle.addSource()
can take a MagicString
instance as its sole argument, for convenienceoptions
in new MagicString(str, options)
can include filename
and indentExclusionRanges
options, which will be used when bundlings.snip( start, end )
file
option is optional when generating a bundle sourcemapsource.addSourcemapLocation()
vlq
dependency includedsource.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 untouchedbundle.addSource()
can take an indentExclusionRanges
optionsources
paths in sourcemaps relative to options.file
bundle.indent()
MagicString.Bundle
for concatenating magic stringss.generateMap()
have a toUrl()
method that generates a DataURIs.insert( index, content )
- roughly equivalent to s.replace( index, index, content )
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 lengths.trim()
returns this
(i.e. is chainable)s.slice()
s.trim()