Skip to content

Conversation

@fireairforce
Copy link

utoopack issue: utooland/utoo#2526

Turbopack 提供一个 chunk_loading_global 的方法挂在 BrowserChunkingContextBuilder 上,在 turbopack 这一侧默认保持使用 globalThis.TURBOPACK,utoopack 可以通过调用这个方法来定义 utoopack 需要的 global variables。

这个改动不影响 Turbopack 本身的逻辑,这个配置目前只会影响以下两个 global variables:

  • globalThis.TURBOPACK
  • globalThis.TURBOPACK_CHUNK_LISTS

//`x || (x = default)` is better than `x = x || default` simply because we avoid _writing_ the property in the common case.
r#"
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([
(globalThis.{chunk_loading_global} || (globalThis.{chunk_loading_global} = [])).push([
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样就别用 globalThis. 了 , 如果 chunk_loading_globala.b 就挂了

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 了

@fireairforce fireairforce changed the title feat(turbopack): chunkingContext support chunkingLoadingGlobal feat(turbopack): chunkingContext support chunkLoadingGlobal Jan 20, 2026
// `||=` would be better but we need to be es2020 compatible
//`x || (x = default)` is better than `x = x || default` simply because we avoid _writing_ the property in the common case.
"(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([{script_or_path},"
"(globalThis[\"{chunk_loading_global}\"] || (globalThis[\"{chunk_loading_global}\"] = \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r#

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 了

@fireairforce fireairforce merged commit 10e63ec into utoo Jan 20, 2026
13 of 26 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