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

[RFC] 缓存样式资源 #373

Closed
maoxiaoke opened this issue Aug 26, 2021 · 3 comments · Fixed by #468
Closed

[RFC] 缓存样式资源 #373

maoxiaoke opened this issue Aug 26, 2021 · 3 comments · Fixed by #468
Labels

Comments

@maoxiaoke
Copy link
Collaborator

maoxiaoke commented Aug 26, 2021

背景

  1. 在 icestark 加载微应用过程中,样式资源均是通过 <link /> 标签进行加载,降低了应用的加载速度。
  2. 在应用开启 sandbox 或 loadScriptMode: fetch 的场景下,第二次加载应用时,脚本资源充分利用缓存。对于 jquery 或 angular 1.x 的应用可能产生脚本先执行,样式后加载,导致样式闪动

方案

当微应用配置为:

  • 开启沙箱 sandbox: true
  • loadScriptMode 为 'fetch'、'import'
  • umd 为 true (兼容场景)

开启样式资源缓存。

备注:若脚本资源可通过 fetch 来加载,则样式资源跨域的问题可认为是大几率不存在

@maoxiaoke
Copy link
Collaborator Author

timeline

因此,对于包含 icestark 生命周期的应用。并行加载不会出现问题。而可能影响不包含 icestark 生命周期的函数,比如 Angular 1.x 的应用

@maoxiaoke
Copy link
Collaborator Author

maoxiaoke commented Nov 15, 2021

可能存在的问题:

  1. 跨域问题
    上面分析过,由于脚本资源也是通过 fetch 加载的,样式资源加载是否可以认为存在跨域的问题微乎其微

  2. shouldAssetsRemove 的问题

虽然我们建议 shouldAssetsRemove 仅在应用在主应用的资源,但实际可能存在对子应用样式处理的失败

@maoxiaoke
Copy link
Collaborator Author

兼容场景,对 shouldAssetsRemove 的应用暂不提供该能力

@maoxiaoke maoxiaoke mentioned this issue Dec 3, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant