Skip to content

Interface: RolldownMagicString

Extends

  • BindingMagicString

Properties

isRolldownMagicString

  • Type: true

Accessors

filename

Get Signature

  • Type: () => string | null
Defined in: binding.d.cts:1482
Returns

string | null

Inherited from

NativeBindingMagicString.filename


offset

Get Signature

  • Type: () => number
Defined in: binding.d.cts:1483
Returns

number

Set Signature

  • Type: (offset: number) => void
Defined in: binding.d.cts:1484
Parameters
offset

number

Returns

void

Inherited from

NativeBindingMagicString.offset


original

Get Signature

  • Type: () => string
Defined in: binding.d.cts:1481
Returns

string

Inherited from

NativeBindingMagicString.original

Methods

append()

  • Type: (content: string) => this
Defined in: binding.d.cts:1488

Parameters

content

string

Returns

this

Inherited from

NativeBindingMagicString.append


appendLeft()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1491

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.appendLeft


appendRight()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1492

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.appendRight


clone()

  • Type: () => BindingMagicString
Defined in: binding.d.cts:1522

Returns a clone of the MagicString instance.

Returns

BindingMagicString

Inherited from

NativeBindingMagicString.clone


generateDecodedMap()

  • Type: (options?: BindingSourceMapOptions | null) => BindingDecodedMap
Defined in: binding.d.cts:1549

Generates a decoded source map for the transformations applied to this MagicString. Returns a BindingDecodedMap object with mappings as an array of arrays.

Parameters

options?

BindingSourceMapOptions | null

Returns

BindingDecodedMap

Inherited from

NativeBindingMagicString.generateDecodedMap


generateMap()

  • Type: (options?: BindingSourceMapOptions | null) => BindingSourceMap
Defined in: binding.d.cts:1544

Generates a source map for the transformations applied to this MagicString. Returns a BindingSourceMap object with version, file, sources, sourcesContent, names, mappings.

Parameters

options?

BindingSourceMapOptions | null

Returns

BindingSourceMap

Inherited from

NativeBindingMagicString.generateMap


hasChanged()

  • Type: () => boolean
Defined in: binding.d.cts:1495

Returns

boolean

Inherited from

NativeBindingMagicString.hasChanged


indent()

  • Type: (indentor?: string | null) => this
Defined in: binding.d.cts:1507

Parameters

indentor?

string | null

Returns

this

Inherited from

NativeBindingMagicString.indent


insert()

  • Type: (index: number, content: string) => void
Defined in: binding.d.cts:1520

Deprecated method that throws an error directing users to use prependRight or appendLeft. This matches the original magic-string API which deprecated this method.

Parameters

index

number

content

string

Returns

void

Inherited from

NativeBindingMagicString.insert


isEmpty()

  • Type: () => boolean
Defined in: binding.d.cts:1497

Returns

boolean

Inherited from

NativeBindingMagicString.isEmpty


lastChar()

  • Type: () => string
Defined in: binding.d.cts:1524

Returns the last character of the generated string, or an empty string if empty.

Returns

string

Inherited from

NativeBindingMagicString.lastChar


lastLine()

  • Type: () => string
Defined in: binding.d.cts:1526

Returns the content after the last newline in the generated string.

Returns

string

Inherited from

NativeBindingMagicString.lastLine


length()

  • Type: () => number
Defined in: binding.d.cts:1496

Returns

number

Inherited from

NativeBindingMagicString.length


move()

  • Type: (start: number, end: number, index: number) => this
Defined in: binding.d.cts:1506

Alias for relocate to match the original magic-string API. Moves the characters from start to end to index. Returns this for method chaining.

Parameters

start

number

end

number

index

number

Returns

this

Inherited from

NativeBindingMagicString.move


overwrite()

  • Type: (start: number, end: number, content: string) => this
Defined in: binding.d.cts:1493

Parameters

start

number

end

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.overwrite


prepend()

  • Type: (content: string) => this
Defined in: binding.d.cts:1487

Parameters

content

string

Returns

this

Inherited from

NativeBindingMagicString.prepend


prependLeft()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1489

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.prependLeft


prependRight()

  • Type: (index: number, content: string) => this
Defined in: binding.d.cts:1490

Parameters

index

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.prependRight


relocate()

  • Type: (start: number, end: number, to: number) => this
Defined in: binding.d.cts:1500

Parameters

start

number

end

number

to

number

Returns

this

Inherited from

NativeBindingMagicString.relocate


remove()

  • Type: (start: number, end: number) => this
Defined in: binding.d.cts:1498

Parameters

start

number

end

number

Returns

this

Inherited from

NativeBindingMagicString.remove


replace()

  • Type: (from: string, to: string) => this
Defined in: binding.d.cts:1485

Parameters

from

string

to

string

Returns

this

Inherited from

NativeBindingMagicString.replace


replaceAll()

  • Type: (from: string, to: string) => this
Defined in: binding.d.cts:1486

Parameters

from

string

to

string

Returns

this

Inherited from

NativeBindingMagicString.replaceAll


reset()

  • Type: (start: number, end: number) => this
Defined in: binding.d.cts:1534

Resets the portion of the string from start to end to its original content. This undoes any modifications made to that range. Supports negative indices (counting from the end).

Parameters

start

number

end

number

Returns

this

Inherited from

NativeBindingMagicString.reset


slice()

  • Type: (start?: number | null, end?: number | null) => string
Defined in: binding.d.cts:1539

Returns the content between the specified original character positions. Supports negative indices (counting from the end).

Parameters

start?

number | null

end?

number | null

Returns

string

Inherited from

NativeBindingMagicString.slice


snip()

  • Type: (start: number, end: number) => BindingMagicString
Defined in: binding.d.cts:1528

Returns a clone with content outside the specified range removed.

Parameters

start

number

end

number

Returns

BindingMagicString

Inherited from

NativeBindingMagicString.snip


toString()

  • Type: () => string
Defined in: binding.d.cts:1494

Returns

string

Inherited from

NativeBindingMagicString.toString


trim()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1509

Trims whitespace or specified characters from the start and end.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trim


trimEnd()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1513

Trims whitespace or specified characters from the end.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trimEnd


trimLines()

  • Type: () => this
Defined in: binding.d.cts:1515

Trims newlines from the start and end.

Returns

this

Inherited from

NativeBindingMagicString.trimLines


trimStart()

  • Type: (charType?: string | null) => this
Defined in: binding.d.cts:1511

Trims whitespace or specified characters from the start.

Parameters

charType?

string | null

Returns

this

Inherited from

NativeBindingMagicString.trimStart


update()

  • Type: (start: number, end: number, content: string) => this
Defined in: binding.d.cts:1499

Parameters

start

number

end

number

content

string

Returns

this

Inherited from

NativeBindingMagicString.update