From 555e82d78cd8f1bdc438be7788444530439ba8a5 Mon Sep 17 00:00:00 2001 From: littly <544028951@qq.com> Date: Thu, 14 Mar 2019 15:18:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(webpack-runner):=20=E8=A7=A3=E5=86=B3esnext?= =?UTF-8?q?Modules=E5=8C=B9=E9=85=8D=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-webpack-runner/src/util/chain.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/taro-webpack-runner/src/util/chain.ts b/packages/taro-webpack-runner/src/util/chain.ts index 0bfbe5d362ae..dbf5e64b59ac 100644 --- a/packages/taro-webpack-runner/src/util/chain.ts +++ b/packages/taro-webpack-runner/src/util/chain.ts @@ -150,7 +150,7 @@ const getModule = ({ fontUrlLoaderOption, imageUrlLoaderOption, mediaUrlLoaderOption, - esnextModules = [] as string[], + esnextModules = [] as (string | RegExp)[], module, plugins @@ -346,7 +346,15 @@ const getModule = ({ ] if (Array.isArray(esnextModules) && esnextModules.length) { /* cnpm 安装的模块名前带下划线 `_` */ - esnextModuleRegs = esnextModuleRegs.concat([...esnextModules.map(v => new RegExp(`node_modules[\\\\/]_?${v}`))]) + esnextModuleRegs = esnextModuleRegs.concat([ + ...esnextModules.map(v => { + if (typeof v === 'string') { + return new RegExp(`\b${v}\b`) + } else { + return v + } + }) + ]) } /** * isEsnextModule