![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | dist/ | 9 months ago | - | |
![]() | README.md | 9 months ago | 1.1K | |
![]() | LICENSE | 9 months ago | 1.1K | |
![]() | package.json | 9 months ago | 1.5K |
Extend Babel AST for magic-string.
npm i magic-string-ast
import { MagicString } from 'magic-string-ast'
const offset = 0
const node = {
// ...
// AST node from @babel/parser
}
const s = new MagicString('const a = 1')
s.removeNode(node)
s.moveNode(node, 0)
console.log(s.sliceNode(node, { offset }))
s.overwriteNode(node, 'const b = 2')
For more APIs, see magic-string.