guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
917 stars 48 forks source link

feat: support stringify? #99

Closed imcuttle closed 2 years ago

imcuttle commented 2 years ago

In my screen, I need to stringify the result of parse.

const [import] = parse(`
import a from 'a'
`)

stringify(import[0]) // => import a from 'a'
guybedford commented 2 years ago

Because this project is not a parser, stringification is a non-goal.

You can use a system like magic-string for source range rewriting though. See eg https://github.com/rich-harris/magic-string, which is used as the basis of source rewriting in RollupJS.