-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(prepare): only hande source file #10400
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Codecov ReportBase: 29.29% // Head: 29.26% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #10400 +/- ##
==========================================
- Coverage 29.29% 29.26% -0.03%
==========================================
Files 445 445
Lines 13006 13017 +11
Branches 3178 3183 +5
==========================================
Hits 3810 3810
- Misses 8592 8600 +8
- Partials 604 607 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
packages/preset-umi/src/features/prepare/esbuildPlugins/esbuildExternalPlugin.ts
Outdated
Show resolved
Hide resolved
const SOURCE_REG = /\.(t|j)sx?$/; | ||
function isSource(file: string) { | ||
// perf optimization | ||
if (SOURCE_REG.test(file)) { |
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.
为啥 x.tsx 就是源码,会不会有 import 'foo/bar.js'
的场景?
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.
这个地方就是把不符合 ts
/ tsx
/ jsx
/ js
/ 无扩展名
的文件过滤掉(他们不需要被 prepare 分析内容)。至于具体的处理交给下面,即使是 foo/bar.js
也可以的。
相当于代替了手动维护扩展名过滤的逻辑,因为哪些是源码我们是已知的,但用户用了什么扩展名是未知的。
@PeachScript 在 father doctor 里有做过类似的,帮忙看下。 |
packages/preset-umi/src/features/prepare/esbuildPlugins/esbuildExternalPlugin.ts
Outdated
Show resolved
Hide resolved
packages/preset-umi/src/features/prepare/esbuildPlugins/esbuildExternalPlugin.ts
Outdated
Show resolved
Hide resolved
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.
+1
fix #10393
prepare 处理扩展名要反向思维,因为不清楚用户用了什么自定义文件 ext ,可能有自己的 loader 等,所以我们只处理 tsx 、ts 、jsx 、js 、没有扩展名 几种