Skip to content

Commit

Permalink
fix tt subpackages async
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Aug 12, 2024
1 parent 973791a commit 6fe0bdf
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ class MpxWebpackPlugin {
}
}

const checkDynamicEntryInfo = (compilation) => {
for (const packageName in mpx.dynamicEntryInfo) {
const entryMap = mpx.dynamicEntryInfo[packageName]
if (packageName !== 'main' && !entryMap.hasPage) {
// 引用未注册分包的所有资源
const resources = entryMap.entries.map(info => info.resource).join(',')
compilation.errors.push(new Error(`资源${resources}通过分包异步声明为${packageName}分包, 但${packageName}分包未注册或不存在相关页面!`))
}
}
}
// 构建分包队列,在finishMake钩子当中最先执行,stage传递-1000
compiler.hooks.finishMake.tapAsync({
name: 'MpxWebpackPlugin',
Expand All @@ -549,17 +559,10 @@ class MpxWebpackPlugin {
}
], (err) => {
if (err) return callback(err)
const checkDynamicEntryInfo = () => {
for (const packageName in mpx.dynamicEntryInfo) {
const entryMap = mpx.dynamicEntryInfo[packageName]
if (packageName !== 'main' && !entryMap.hasPage) {
// 引用未注册分包的所有资源
const resources = entryMap.entries.map(info => info.resource).join(',')
compilation.errors.push(new Error(`资源${resources}通过分包异步声明为${packageName}分包, 但${packageName}分包未注册或不存在相关页面!`))
}
}
if (mpx.supportRequireAsync && mpx.mode !== 'tt') {
// 字节小程序异步分包中不能包含page,忽略该检查
checkDynamicEntryInfo(compilation)
}
checkDynamicEntryInfo()
callback()
})
})
Expand Down

0 comments on commit 6fe0bdf

Please sign in to comment.