Skip to content

Commit

Permalink
fix(plugin-compiler): 修复全局组件注入可能不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyfeyaj committed Apr 21, 2023
1 parent 18a000f commit 3fda777
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/plugin-compiler/src/parsers/configParserPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ export class ConfigParserPlugin implements Plugin {

if (referencePath) config.usingComponents[key] = referencePath
}
}

// 为页面和组件注入全局组件
// 为节约编译性能,目前的全局组件注入比较粗暴
// 直接为每个页面和组件添加全局组件
// 没有分析页面的 template 中是否实际有引用
if (shouldInjectGlobalComponents && isPageOrComponent) {
const entry = entryBuilder.getEntryByFilePath(fileInfo.path)
for (const name of globalComponentNames) {
// 如果已存在同名组件, 则跳过
if (config.usingComponents[name]) continue

const referencePath =
entryBuilder.getGlobalComponentRelativePath(entry, name)
if (referencePath)
config.usingComponents[name] = referencePath
}
// 为页面和组件注入全局组件
// 为节约编译性能,目前的全局组件注入比较粗暴
// 直接为每个页面和组件添加全局组件
// 没有分析页面的 template 中是否实际有引用
if (shouldInjectGlobalComponents && isPageOrComponent) {
if (!config.usingComponents) config.usingComponents = {}
const entry = entryBuilder.getEntryByFilePath(fileInfo.path)
for (const name of globalComponentNames) {
// 如果已存在同名组件, 则跳过
if (config.usingComponents[name]) continue

const referencePath =
entryBuilder.getGlobalComponentRelativePath(entry, name)
if (referencePath) config.usingComponents[name] = referencePath
}
}

Expand Down

0 comments on commit 3fda777

Please sign in to comment.