Skip to content

Commit

Permalink
fix(webpack-runner): 解决esnextModules匹配不准确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Mar 15, 2019
1 parent 3c1af2f commit 555e82d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/taro-webpack-runner/src/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const getModule = ({
fontUrlLoaderOption,
imageUrlLoaderOption,
mediaUrlLoaderOption,
esnextModules = [] as string[],
esnextModules = [] as (string | RegExp)[],

module,
plugins
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 555e82d

Please sign in to comment.