Skip to content
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

Merged
merged 4 commits into from
Feb 7, 2023
Merged

Conversation

fz6m
Copy link
Member

@fz6m fz6m commented Feb 3, 2023

fix #10393

prepare 处理扩展名要反向思维,因为不清楚用户用了什么自定义文件 ext ,可能有自己的 loader 等,所以我们只处理 tsx 、ts 、jsx 、js 、没有扩展名 几种

@vercel
Copy link

vercel bot commented Feb 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
umi ⬜️ Ignored (Inspect) Feb 6, 2023 at 8:20AM (UTC)

@codecov
Copy link

codecov bot commented Feb 3, 2023

Codecov Report

Base: 29.29% // Head: 29.26% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (e831fdb) compared to base (3c78dbe).
Patch coverage: 5.88% of modified lines in pull request are covered.

❗ Current head e831fdb differs from pull request most recent head f7408c2. Consider uploading reports for the commit f7408c2 to get more accurate results

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     
Impacted Files Coverage Δ
...eset-umi/src/features/clientLoader/clientLoader.ts 0.00% <ø> (ø)
...ages/preset-umi/src/features/mpa/extractExports.ts 0.00% <ø> (ø)
...es/prepare/esbuildPlugins/esbuildExternalPlugin.ts 0.00% <0.00%> (ø)
...ges/preset-umi/src/features/ssr/builder/builder.ts 28.12% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

const SOURCE_REG = /\.(t|j)sx?$/;
function isSource(file: string) {
// perf optimization
if (SOURCE_REG.test(file)) {
Copy link
Member

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' 的场景?

Copy link
Member Author

@fz6m fz6m Feb 3, 2023

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 也可以的。

相当于代替了手动维护扩展名过滤的逻辑,因为哪些是源码我们是已知的,但用户用了什么扩展名是未知的。

@sorrycc
Copy link
Member

sorrycc commented Feb 3, 2023

@PeachScript 在 father doctor 里有做过类似的,帮忙看下。

Copy link
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@sorrycc sorrycc merged commit 3dcfc85 into umijs:master Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants