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

[Task] codeSplitting shared 分组出现重复的报错问题 #12036

Open
fz6m opened this issue Jan 6, 2024 · 2 comments
Open

[Task] codeSplitting shared 分组出现重复的报错问题 #12036

fz6m opened this issue Jan 6, 2024 · 2 comments

Comments

@fz6m
Copy link
Member

fz6m commented Jan 6, 2024

说明

codeSplitting 的 js 分包策略采用 granularChunks 时,由于 shared 分组没有任何 test 限制条件,可能会发生 chunk 重复的问题:

shared: {
name(_module: any, chunks: any) {
const cryptoName = crypto
.createHash('sha1')
.update(
chunks.reduce((acc: any, chunk: any) => {
return acc + chunk.name;
}, ''),
)
.digest('base64')
// replace `+=/` that may be escaped in the url
// https://github.com/umijs/umi/issues/9845
.replace(/\//g, '')
.replace(/\+/g, '-')
.replace(/=/g, '_');
return `shared-${cryptoName}`;
},

目前得知会报错的情况:

  1. chunknull 导致 shared-nullnullnull 命名重复,出现冲突的情况 from @xierenyuan

  2. 之前我在哪个 issue 还是 discussion 看到过有人反馈会报错,找不到了

目前期望的解决方案:

  1. 去掉 shared 分组,因为它没有任何限制,难免出现无法定位的情况(如 chunk 为空)。(此方案 @xierenyuan 认为会大幅影响 CDN 覆盖率,因为产物结构有很大变化)。

  2. shared 添加 test 限制。

  3. 找到 chunknull 会出现问题的最小复现,尝试对 null 的使用文件路径作为 id 计算 hash 继续弥补此方案。

@fz6m
Copy link
Member Author

fz6m commented Jan 6, 2024

@xierenyuan 关于文中提到的 chunk 为 null 的情况,有办法手动去创建一个最小复现来排查么,比如之前为 null 那种情况的文件路径不是可以从 _module 拿到吗,这些文件有什么特征可以以此创建一个复现么。

有时间了辛苦可以看下 🌹

@xierenyuan
Copy link
Member

@xierenyuan 关于文中提到的 chunk 为 null 的情况,有办法手动去创建一个最小复现来排查么,比如之前为 null 那种情况的文件路径不是可以从 _module 拿到吗,这些文件有什么特征可以以此创建一个复现么。

有时间了辛苦可以看下 🌹

  • -还没有找到复现规律、现在有几个业务项目复现了、但是没有看出来规律

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

No branches or pull requests

2 participants