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: let async imports bundled into separate chunks #940

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

xusd320
Copy link
Contributor

@xusd320 xusd320 commented Mar 11, 2024

  1. 解决形如 import(./i18n/${lang}) 这类动态 import 会将 i18n/ 目录下所有文件打包进一个 async chunk 的问题;
    • 问题原因:ContextModule 里对于 import(./i18n/${lang}) 这类语句,是通过 glob/**/* 扫描 i18n 目录下的所有文件,并将这些文件包裹在一句 cjs require 里, 导致所有文件达成了一个 chunk
    • 解法:对与 import(./i18n/${lang}) 语句,在虚拟模块 params 上添加 "async" 标记,文件扫描规则为 glob=**/*.json&async。对带 "async" 标记的模块,会转成独立的 import 语句,打进独立 chunk;
  2. 增加相应 e2e 用例。

@xusd320 xusd320 requested a review from PeachScript March 11, 2024 09:19
@sorrycc
Copy link
Member

sorrycc commented Mar 11, 2024

补充说明下问题和方案?

1、之前为啥会被打到一起
2、解的方案是啥

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 9dd2edb into refact/build Mar 11, 2024
8 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix/async-import-split-chunks branch March 11, 2024 10:19
@sorrycc sorrycc mentioned this pull request Mar 11, 2024
10 tasks
sorrycc added a commit that referenced this pull request Mar 12, 2024
* refact: build

* update

* update

* runnable

* remove files

* remove task.rs

* remove build.rs

* remove load.rs

* remove parse.rs

* remove transform.rs

* remove md.rs

* remove css.rs

* remove _2 affix

* refact plugins/runtime

* remove meta.rs

* code style

* fix find_export_source test cases

* fix clappy

* fix: bundler-okam don't exit

* fix: build won't end when last module build failed

* fix: css modules support

* fix: css modules

* chore: update

* fix config.platform.node case

* refactor: treats ignore module as normal module (#935)

* refactor: treats ignore module as normal module

* refactor: update LoadError

* fix: typo

* refact: no need to mark ignored on File

* chore: code style

* chore: code style

* fix: optimize.full-helpers testcase

* fix: error.resolve.module-not-found test case

* fix: config.react.runtime.classic testcase

* fix: javascript.require-dynamic testcase

* fix: minifish testcases

* fix: raw_hash calculate when watch is on

* fix: entry with ?hmr

* fix: css modules

* code style

* fix missing related test cases

* code style

* remove missing_deps in module.info

* remove props under module.info

* add inject testcase back

* code style

* add testcases

* update pnpm-lock.yaml

* code style

* code style

* fix: let async imports bundled into separate chunks (#940)

* fix: let async imports bundled into separate chunks

* fix: e2e javascript.require-dynamic

* refact: thread pool (#936)

* refactor: minimum tokio thread pool

* refact: use a static rayon thread pool

* refact: import style

* refact: code style

* refact: import style

---------

Co-authored-by: xusd320 <xusd320@gmail.com>
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