兼容export xx from yy 语法

pull/1/head
yutent 2023-05-18 15:50:29 +08:00
parent 27afea8649
commit ad12433785
1 changed files with 5 additions and 3 deletions

View File

@ -157,8 +157,8 @@ export function parseJs(
.replace(/\r\n/g, '\n')
.replace(/process\.env\.NODE_ENV/g, `'${process.env.NODE_ENV}'`)
.replace(
/import ([\w\W]*?) from (["'])(.*?)\2/g,
function (m, alias, q, name) {
/(import|export) ([\w\W]*?) from (["'])(.*?)\3/g,
function (m, t, alias, q, name) {
if (name.startsWith('@/')) {
name = name.replace('@/', urlJoin(DEPLOY_PATH, ASSETS_DIR))
}
@ -190,7 +190,9 @@ export function parseJs(
if (isBuild) {
name = name.replace(/\.vue$/, '.js')
}
return `import ${alias} from '${name}'`
return `import ${alias} from '${name}'${
t === 'export' ? `\nexport ${alias}` : ''
}`
}
)
.replace(/import\((['"])(.*?)\1\)/g, function (m, q, name) {