-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: optimize runtime when build #5082
Conversation
Codecov Report
@@ Coverage Diff @@
## release/2.5.0 #5082 +/- ##
=================================================
+ Coverage 28.81% 30.18% +1.37%
=================================================
Files 196 197 +1
Lines 5067 5211 +144
Branches 1222 1271 +49
=================================================
+ Hits 1460 1573 +113
- Misses 3325 3352 +27
- Partials 282 286 +4
|
|
||
const prodConfig = wp2vite(context); | ||
if (!configArr.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是什么情况?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前 vite 模式下的配置均是基于 webpack 配置转化的,如果没有 webpack 配置的情况下,是不需要执行构建的,start 阶段已有这个判断,修正了下 build 模式下的逻辑
packages/plugin-mpa/src/index.ts
Outdated
mode = 'vite'; | ||
} else if (webpackConfig) { | ||
alias = webpackConfig?.[0].chainConfig?.toConfig?.()?.resolve?.alias; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种代码看着有点头疼的,未来还是得想办法统一掉。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯 这里本质原因是 vite 和 webpack 配置的 alias 内容是不一致的,vite 下是通过 {find: string, replacement: string}[] 的方式,而 webpack 是 k-v
@@ -13,19 +13,30 @@ function generatePageFiles(api: IPluginAPI, options: IGeneratorOptions): IGenera | |||
} | |||
|
|||
const { context: { userConfig } } = api; | |||
generator.generateRunAppFile(userConfig); | |||
// 在分析运行时依赖的场景下,不能直接执行 generator | |||
// 需要在分析完成并执行 disableRuntimePlugins 逻辑后,再执行生成 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个时序控制太难受了,执行顺序有点乱,有没有可能把 analyzeRuntime 前置掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为 analyzeRuntime 依赖完整的 webpack 配置,所有分析的行为必须发生在 before.${command}.load
阶段,分析完成后才能进行 generator
Resolve #5048