Skip to content

Commit

Permalink
fix: add mainKey in processJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherso1a committed Sep 27, 2023
1 parent 824e04d commit a93bcad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/webpack-plugin/lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ module.exports = function (content) {
},
(callback) => {
processJSON(parts.json, {
ctorType,
loaderContext,
pagesMap,
componentsMap
Expand Down
10 changes: 8 additions & 2 deletions packages/webpack-plugin/lib/web/processJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDe
const RecordGlobalComponentsDependency = require('../dependencies/RecordGlobalComponentsDependency')

module.exports = function (json, {
ctorType,
loaderContext,
pagesMap,
componentsMap
Expand Down Expand Up @@ -79,6 +78,9 @@ module.exports = function (json, {
})
}

const { resourcePath } = parseRequest(loaderContext.resource)
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])

if (!json) {
return callback()
}
Expand All @@ -99,12 +101,16 @@ module.exports = function (json, {
}
}

if (!isApp) {
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
}

const rulesRunner = getRulesRunner(rulesRunnerOptions)

if (rulesRunner) {
rulesRunner(jsonObj)
}
if (ctorType === 'app') {
if (isApp) {
// 收集全局组件
Object.assign(mpx.usingComponents, jsonObj.usingComponents)
// 在 rulesRunner 运行后保存全局注册组件
Expand Down

0 comments on commit a93bcad

Please sign in to comment.