@duhongwei/parser
v3.0.2
Published
A es6 module parser
Downloads
3
Readme
@duhongwei/parser
A es6 module parser
examples
const parser=require('@duhongwei/parser')
let es6Parser=new parser.Es6('import a from "a.js";let a=1;export {a};')
let {importInfo,exportInfo,code}=es6Parser.parse()
//importInfo [{key:'a.js',tokens:[{from:'default',to:'a'}] }]
//exportInfo [{from:'a',to:'a'}]
//dynamicImportInfo:[]
//code let a=1;
//dynamic Import,simply repalce 'import' with a function name
es6Parser=new parser.Es6('import("a.js")',{dynamicImportReplacer: `load`,convertKey: (key) => {return `views/${key}`}})
let {importInfo}=parser.parse()
//importInfo:[],
//exportInfo:[],
//dynamicImportInfo [{file:'a.js',tokens:[]}]
//code load("views/a.js")
welcome to my blog https://www.duhongwei.site