-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: ✨ mfsu code loader use new config with esbuild #12440
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Warning Rate limit exceeded@stormslowly has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 35 minutes and 12 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Walkthrough此次更改主要涉及 Umi 项目中的多个文件,重点是引入 Changes
Sequence Diagram(s) (Beta)(此处无需生成时序图) Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Size Change: +414 B (0%) Total Size: 9.9 MB
ℹ️ View Unchanged
|
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (4)
packages/preset-umi/src/libs/folderCache/LazySourceCodeCache.ts (1)
Line range hint
175-176
: 建议使用for...of
循环替换forEach
方法,以提高处理大数组时的性能。- this.listeners.forEach((l) => l(info)); + for (const l of this.listeners) { + l(info); + }packages/preset-umi/src/commands/dev/dev.ts (3)
Line range hint
120-131
: 建议使用for...of
循环替换forEach
方法,以提高处理大数组时的性能。- lodash.uniq<string>(watcherPaths.map(winPath)).forEach((p: string) => { - watch({ - path: p, - addToUnWatches: true, - onChange: createDebouncedHandler({ - timeout: 2000, - async onChange(opts) { - await generate({ files: opts.files, isFirstTime: false }); - }, - }), - }); - }); + for (const p of lodash.uniq<string>(watcherPaths.map(winPath))) { + watch({ + path: p, + addToUnWatches: true, + onChange: createDebouncedHandler({ + timeout: 2000, + async onChange(opts) { + await generate({ files: opts.files, isFirstTime: false }); + }, + }), + }); + }
Line range hint
208-217
: 建议使用for...of
循环替换forEach
方法,以提高处理大数组时的性能。- pluginFiles.forEach((filePath: string) => { - watch({ - path: filePath, - addToUnWatches: true, - onChange() { - logger.event(`${basename(filePath)} changed, restart server...`); - api.restartServer(); - }, - }); - }); + for (const filePath of pluginFiles) { + watch({ + path: filePath, + addToUnWatches: true, + onChange() { + logger.event(`${basename(filePath)} changed, restart server...`); + api.restartServer(); + }, + }); + }
Line range hint
279-279
: 避免使用 'Object' 作为类型。建议明确定义对象的形状,以提高类型安全性和代码可读性。- const chainWebpack = async (memo: any, args: Object) => { + const chainWebpack = async (memo: any, args: { [key: string]: any }) => { - const modifyWebpackConfig = async (memo: any, args: Object) => { + const modifyWebpackConfig = async (memo: any, args: { [key: string]: any }) => { - const modifyViteConfig = async (memo: any, args: Object) => { + const modifyViteConfig = async (memo: any, args: { [key: string]: any }) => {Also applies to: 287-287, 294-294
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- packages/preset-umi/src/commands/dev/dev.ts (2 hunks)
- packages/preset-umi/src/features/prepare/build.ts (2 hunks)
- packages/preset-umi/src/libs/folderCache/LazySourceCodeCache.ts (6 hunks)
- packages/preset-umi/src/libs/folderCache/constant.ts (1 hunks)
Additional context used
Biome
packages/preset-umi/src/libs/folderCache/LazySourceCodeCache.ts
[error] 175-176: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
packages/preset-umi/src/commands/dev/dev.ts
[error] 120-131: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 208-217: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 279-279: Don't use 'Object' as a type. (lint/complexity/noBannedTypes)
Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type.
[error] 287-287: Don't use 'Object' as a type. (lint/complexity/noBannedTypes)
Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type.
[error] 294-294: Don't use 'Object' as a type. (lint/complexity/noBannedTypes)
Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type.
Additional comments not posted (4)
packages/preset-umi/src/libs/folderCache/constant.ts (1)
15-44
: 新增了一个常量possibleExtUsingEmptyLoader
,用于映射文件扩展名到 'empty'。这有助于简化和统一文件扩展名的处理逻辑。packages/preset-umi/src/features/prepare/build.ts (1)
9-9
: 通过从../../libs/folderCache/constant
引入possibleExtUsingEmptyLoader
,优化了文件扩展名的处理。这有助于减少代码重复并提高代码的可维护性。packages/preset-umi/src/libs/folderCache/LazySourceCodeCache.ts (2)
Line range hint
33-60
: 在构造函数中添加了root
和tsConfigRaw
属性,并尝试从root
路径读取tsconfig.json
。这有助于提高配置的灵活性和适应性。
185-185
: 在esbuildTransform
函数调用中传递了tsConfigRaw
,确保 TypeScript 配置的正确性和一致性。
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
packages/preset-umi/src/commands/mfsu/util.ts (2)
Line range hint
59-59
: 避免使用 'Object' 作为类型。建议明确定义对象的形状。- chainWebpack = async (memo: Object, args: Object) => { + chainWebpack = async (memo: any, args: any) => {
Line range hint
67-67
: 避免使用 'Object' 作为类型。建议明确定义对象的形状。- modifyWebpackConfig = async (memo: Object, args: Object) => { + modifyWebpackConfig = async (memo: any, args: any) => {
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/preset-umi/src/commands/mfsu/util.ts (1 hunks)
Additional context used
Biome
packages/preset-umi/src/commands/mfsu/util.ts
[error] 210-211: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 59-59: Don't use 'Object' as a type. (lint/complexity/noBannedTypes)
Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type.
[error] 67-67: Don't use 'Object' as a type. (lint/complexity/noBannedTypes)
Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type.
Additional comments not posted (1)
packages/preset-umi/src/commands/mfsu/util.ts (1)
80-80
: 请确保所有对LazySourceCodeCache
的调用都已更新为新的构造函数签名。Verification successful
对
LazySourceCodeCache
的所有调用都已更新为新的构造函数签名。
packages/preset-umi/src/commands/mfsu/util.ts
中的调用已更新。packages/preset-umi/src/commands/dev/dev.ts
中的调用已更新。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `LazySourceCodeCache` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type typescript $'LazySourceCodeCache'Length of output: 77
Script:
#!/bin/bash # Description: Verify all function calls to `LazySourceCodeCache` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts 'LazySourceCodeCache'Length of output: 775
Script:
#!/bin/bash # Description: Extract lines where `LazySourceCodeCache` is instantiated to verify the constructor signature. # Extract lines from util.ts rg --type ts 'new LazySourceCodeCache' packages/preset-umi/src/commands/mfsu/util.ts # Extract lines from dev.ts rg --type ts 'new LazySourceCodeCache' packages/preset-umi/src/commands/dev/dev.tsLength of output: 267
Script:
#!/bin/bash # Description: Extract full constructor calls of `LazySourceCodeCache` to verify the signature. # Extract lines around the instantiation in util.ts rg --type ts -A 3 -B 3 'new LazySourceCodeCache' packages/preset-umi/src/commands/mfsu/util.ts # Extract lines around the instantiation in dev.ts rg --type ts -A 3 -B 3 'new LazySourceCodeCache' packages/preset-umi/src/commands/dev/dev.tsLength of output: 717
Script:
#!/bin/bash # Description: Extract the constructor definition of `LazySourceCodeCache` to verify the signature. # Extract the constructor definition from LazySourceCodeCache.ts rg --type ts 'constructor' packages/preset-umi/src/libs/folderCache/LazySourceCodeCache.tsLength of output: 162
@@ -304,6 +305,7 @@ PORT=8888 umi dev | |||
|
|||
if (api.config.mfsu?.strategy === 'eager') { | |||
srcCodeCache = new LazySourceCodeCache({ | |||
root: api.paths.cwd, |
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.
每次涉及到 cwd
的时候,就必须考虑 APP_ROOT
的问题吗,这一点我一直没特别清楚。
据我所知,使用 APP_ROOT
的项目好像大概是 electron 项目,web 资源放在一个子文件夹下面,但是从根目录启动。
#12431 在 mfsu 上的延续。
Summary by CodeRabbit
MFSUUtilBase
类中,当mfsu
策略设置为 'eager' 时,新增了LazySourceCodeCache
的root
属性。