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

分包能力统一 #5839

Closed
ClarkXia opened this issue Jan 30, 2023 · 1 comment · Fixed by #5950
Closed

分包能力统一 #5839

ClarkXia opened this issue Jan 30, 2023 · 1 comment · Fixed by #5950
Labels

Comments

@ClarkXia
Copy link
Collaborator

ClarkXia commented Jan 30, 2023

Summary | 概述

No response

Motivation | 背景

目前支持 splitChunks: false 禁止多余 chunks 的生成,但是框架默认进行了路由级别的 lazy import,导致依旧产出多个 bundle,期望支持 bundle 级别的定制

Usage example | 使用示例

No response

Detailed design | 方案设计

统一分包概念,增加 codeSpiliting 的配置,支持以下预置配置:

  • vendors 策略:将异步 chunks 里的三方依赖统一打入到 vendor.js 中,避免重复,在依赖不变的情况下有效利用缓存。缺陷是如果项目过大会导致单文件尺寸过大。
  • page 策略:所有路由级别组件按需加载,效果同 splitChunks: false
  • chunks 策略:在路由级别组件按需加载的基础上,根据模块体积大小自动拆分 chunks,为框架默认推荐策略。

暂时不在 userConfig 上开放 webpack 的 splitChunks,根据用户使用场景逐步优化或增加内置策略

@ClarkXia ClarkXia added the rfc label Jan 30, 2023
@wssgcg1213
Copy link
Collaborator

wssgcg1213 commented Jan 31, 2023

方案设计

入参类型:Boolean | Enum | Function

  • false 表示单 bundle
  • 枚举值
    • "all"
    • "page"
    • "xxx"
  • 函数参考下 webpack splitChunk 的处理策略

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.

2 participants