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

feat(mf): 新增remoteHash参数控制mf的产物是否启用hash(#11711) #11714

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

consistent-k
Copy link
Contributor

新增remoteHash参数来控制mf的产物是否启用hash

@vercel
Copy link

vercel bot commented Oct 9, 2023

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

Name Status Preview Comments Updated (UTC)
umi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 11, 2023 11:06am

packages/plugins/src/mf.ts Outdated Show resolved Hide resolved
docs/docs/docs/max/mf.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (fb0a75f) 28.93% compared to head (fd5efdc) 28.94%.
Report is 11 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11714   +/-   ##
=======================================
  Coverage   28.93%   28.94%           
=======================================
  Files         485      485           
  Lines       14771    14775    +4     
  Branches     3498     3501    +3     
=======================================
+ Hits         4274     4276    +2     
- Misses       9737     9739    +2     
  Partials      760      760           
Files Coverage Δ
packages/plugins/src/mf.ts 49.26% <66.66%> (+0.01%) ⬆️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stormslowly
Copy link
Member

stormslowly commented Oct 11, 2023

@consistent-k PR 本身 没有问题,
你是什么场景下会这么使用呀?

没有了 hash 的风险在于,如果一次初始加载和异步加载之间有一次发布的话,构建产物不是同一批的可能会有问题。(比如 module id 和实际 module 的对应关系是不同的; treeshake 导致一个模块内的代码也是不同的)

@stormslowly
Copy link
Member

stormslowly commented Oct 11, 2023

推荐的做法 还是有一个配置中心,下发一个当前使用的 remote 的 url,这样产物始终用都是同一次构建的内容。

参考 : https://umijs.org/docs/max/mf#rawmfimport

@consistent-k
Copy link
Contributor Author

推荐的做法 还是有一个配置中心,下发一个当前使用的 remote 的 url,这样产物始终用都是同一次构建的内容。

参考 : https://umijs.org/docs/max/mf#rawmfimport

这么做的原因就是因为我们还没有这个配置中心,但是又想让其他子项目快速的使用MF的功能,配置中心的建设可能需要先跑通MF给领导看了之后才能提下一步计划。

@consistent-k
Copy link
Contributor Author

@consistent-k PR 本身 没有问题, 你是什么场景下会这么使用呀?

没有了 hash 的风险在于,如果一次初始加载和异步加载之间有一次发布的话,构建产物不是同一批的可能会有问题。(比如 module id 和实际 module 的对应关系是不同的; treeshake 导致一个模块内的代码也是不同的)

嗯 这个风险已知,我们刚开始在项目上尝试MF,可能需要一步一步来,已知的缓存问题我会按照你的建议和领导提建设配置中心的想法。

@fz6m
Copy link
Contributor

fz6m commented Oct 11, 2023

因为这个需求之前也有好几个人在 issue 中穿插提到过,对于小公司,小范围场景使用的话,一般只需要承担 remote.js 缓存头配置的风险,其他的情况一般不会发生,另外统一配置下发需要涉及到基建,如果应用很多,每次都要更新 hash url 重新发布的话,就和使用 MF 集中管理的优点相背了。

所以我认为这个 PR 虽然有风险,但是更适合于相当一部分人的需求,是有意义的。

@stormslowly stormslowly merged commit aea020f into umijs:master Oct 11, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants