兼容export xx from yy 语法
parent
27afea8649
commit
ad12433785
|
@ -157,8 +157,8 @@ export function parseJs(
|
||||||
.replace(/\r\n/g, '\n')
|
.replace(/\r\n/g, '\n')
|
||||||
.replace(/process\.env\.NODE_ENV/g, `'${process.env.NODE_ENV}'`)
|
.replace(/process\.env\.NODE_ENV/g, `'${process.env.NODE_ENV}'`)
|
||||||
.replace(
|
.replace(
|
||||||
/import ([\w\W]*?) from (["'])(.*?)\2/g,
|
/(import|export) ([\w\W]*?) from (["'])(.*?)\3/g,
|
||||||
function (m, alias, q, name) {
|
function (m, t, alias, q, name) {
|
||||||
if (name.startsWith('@/')) {
|
if (name.startsWith('@/')) {
|
||||||
name = name.replace('@/', urlJoin(DEPLOY_PATH, ASSETS_DIR))
|
name = name.replace('@/', urlJoin(DEPLOY_PATH, ASSETS_DIR))
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,9 @@ export function parseJs(
|
||||||
if (isBuild) {
|
if (isBuild) {
|
||||||
name = name.replace(/\.vue$/, '.js')
|
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) {
|
.replace(/import\((['"])(.*?)\1\)/g, function (m, q, name) {
|
||||||
|
|
Loading…
Reference in New Issue