From ad12433785b404fe444d7984148b76c557a36ae3 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 18 May 2023 15:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9export=20xx=20from=20yy=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compile-vue.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/compile-vue.js b/lib/compile-vue.js index 833bee3..c37f410 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -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) {