Skip to content

Commit a233c7f

Browse files
committed
feat(turbopack): apply utoo patches to canary
Squash the 16 utoo-specific commits into one integration commit while preserving the existing tree.
1 parent 9dfbc93 commit a233c7f

159 files changed

Lines changed: 8253 additions & 986 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 156 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ hashbrown = "0.14.5"
283283
image = { version = "0.25.8", default-features = false }
284284
indexmap = "2.13.0"
285285
indoc = "2.0.0"
286+
inventory = "0.3.21"
286287
itertools = "0.10.5"
287288
lightningcss = { version = "1.0.0-alpha.72", features = [
288289
"serde",
@@ -307,8 +308,9 @@ napi-derive = "3.5.8"
307308
napi-build = "2.3.2"
308309
nohash-hasher = "0.2.0"
309310
notify = "8.1.0"
311+
notify-types = "2.0.0"
310312
owo-colors = "4.2.2"
311-
parcel_selectors = "0.28.2"
313+
parcel_selectors = "0.28.3"
312314
parking_lot = "0.12.1"
313315
pathdiff = "0.2.1"
314316
phf = { version = "0.11", features = ["macros"] }
@@ -320,6 +322,7 @@ qstring = "0.7.2"
320322
quick_cache = { version = "0.6.14" }
321323
quote = "1.0.45"
322324
rand = "0.10.1"
325+
getrandom = "0.3"
323326
rayon = "1.10.0"
324327
regex = "1.12.3"
325328
regress = "0.10.4"
@@ -351,7 +354,7 @@ tempfile = "3.20.0"
351354
terminal_size = "0.3.0"
352355
thiserror = "1.0.48"
353356
thread_local = "1.1.8"
354-
tokio = "1.52.1"
357+
tokio = "=1.51.0"
355358
tokio-util = { version = "0.7.18", features = ["io", "rt"] }
356359
tracing = "0.1.44"
357360
tracing-subscriber = "0.3.16"
@@ -373,3 +376,9 @@ virtue = { git = "https://github.com/bgw/virtue.git", branch = "bgw/fix-generic-
373376
mdxjs = { git = "https://github.com/vercel-labs/mdxjs-rs-turbopack.git", branch = "turbopack" }
374377
# Doesn't compile on recent nightly versions because of https://github.com/Michael-F-Bryan/include_dir/pull/117
375378
include_dir = { git = "https://github.com/vercel-labs/include_dir", branch = "turbopack" }
379+
libmimalloc-sys = { git = "https://github.com/utooland/mimalloc_rust.git" }
380+
lightningcss = { git = "https://github.com/utooland/lightningcss", branch = "support-css-module-global" }
381+
mimalloc = { git = "https://github.com/utooland/mimalloc_rust.git" }
382+
parcel_selectors = { git = "https://github.com/utooland/lightningcss", branch = "support-css-module-global" }
383+
tokio = { git = "https://github.com/utooland/tokio.git", package = "tokio" }
384+
tokio-util = { git = "https://github.com/utooland/tokio.git", package = "tokio-util" }

‎crates/next-core/src/next_client/context.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use turbopack_browser::{
1414
};
1515
use turbopack_core::{
1616
chunk::{
17-
AssetSuffix, ChunkLoadRetry, ChunkingConfig, ChunkingContext, ContentHashing, CrossOrigin,
18-
MangleType, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior,
19-
chunk_id_strategy::ModuleIdStrategy,
17+
AssetSuffix, ChunkLoadRetry, ChunkingConfig, ChunkingContext, CompressType, ContentHashing,
18+
CrossOrigin, MangleType, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences,
19+
UrlBehavior, chunk_id_strategy::ModuleIdStrategy,
2020
},
2121
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences},
2222
environment::{BrowserEnvironment, Environment, ExecutionEnvironment},
@@ -577,6 +577,7 @@ pub async fn get_client_chunking_context(
577577
.minify_type(if *minify.await? {
578578
MinifyType::Minify {
579579
mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize),
580+
compress: Some(CompressType::Default),
580581
}
581582
} else {
582583
MinifyType::NoMinify
@@ -693,6 +694,7 @@ pub async fn get_service_worker_chunking_context(
693694
.minify_type(if *minify.await? {
694695
MinifyType::Minify {
695696
mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize),
697+
compress: Some(CompressType::Default),
696698
}
697699
} else {
698700
MinifyType::NoMinify

‎crates/next-core/src/next_edge/context.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use turbo_tasks_fs::FileSystemPath;
66
use turbopack_browser::BrowserChunkingContext;
77
use turbopack_core::{
88
chunk::{
9-
AssetSuffix, ChunkingConfig, ChunkingContext, CrossOrigin, MangleType, MinifyType,
10-
SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior,
9+
AssetSuffix, ChunkingConfig, ChunkingContext, CompressType, CrossOrigin, MangleType,
10+
MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior,
1111
chunk_id_strategy::ModuleIdStrategy,
1212
},
1313
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences},
@@ -245,6 +245,7 @@ pub async fn get_edge_chunking_context_with_client_assets(
245245
MinifyType::Minify {
246246
// React needs deterministic function names to work correctly.
247247
mangle: (!*no_mangling.await?).then_some(MangleType::Deterministic),
248+
compress: Some(CompressType::Default),
248249
}
249250
} else {
250251
MinifyType::NoMinify
@@ -358,6 +359,7 @@ pub async fn get_edge_chunking_context(
358359
.minify_type(if *turbo_minify.await? {
359360
MinifyType::Minify {
360361
mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize),
362+
compress: Some(CompressType::Default),
361363
}
362364
} else {
363365
MinifyType::NoMinify

‎crates/next-core/src/next_server/context.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use turbopack::{
1515
};
1616
use turbopack_core::{
1717
chunk::{
18-
AssetSuffix, ChunkingConfig, MangleType, MinifyType, SourceMapSourceType, SourceMapsType,
19-
UnusedReferences, UrlBehavior, chunk_id_strategy::ModuleIdStrategy,
18+
AssetSuffix, ChunkingConfig, CompressType, MangleType, MinifyType, SourceMapSourceType,
19+
SourceMapsType, UnusedReferences, UrlBehavior, chunk_id_strategy::ModuleIdStrategy,
2020
},
2121
compile_time_defines,
2222
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReferences},
@@ -1086,6 +1086,7 @@ pub async fn get_server_chunking_context_with_client_assets(
10861086
MinifyType::Minify {
10871087
// React needs deterministic function names to work correctly.
10881088
mangle: (!*no_mangling.await?).then_some(MangleType::Deterministic),
1089+
compress: Some(CompressType::Default),
10891090
}
10901091
} else {
10911092
MinifyType::NoMinify
@@ -1197,6 +1198,7 @@ pub async fn get_server_chunking_context(
11971198
.minify_type(if *minify.await? {
11981199
MinifyType::Minify {
11991200
mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize),
1201+
compress: Some(CompressType::Default),
12001202
}
12011203
} else {
12021204
MinifyType::NoMinify

‎packages/next/src/client/dev/hot-reloader/app/web-socket.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function createProcessTurbopackMessage(
188188
import(
189189
// @ts-expect-error requires "moduleResolution": "node16" in tsconfig.json and not .ts extension
190190
'@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/hmr-client.ts'
191-
).then(({ connect }) => {
191+
).then(({ connect, TURBOPACK_CHUNK_UPDATE_LISTENERS_GLOBAL }) => {
192192
connect({
193193
addMessageListener(cb: (msg: TurbopackMessageSentToBrowser) => void) {
194194
callback = cb
@@ -201,6 +201,7 @@ export function createProcessTurbopackMessage(
201201
},
202202
sendMessage,
203203
onUpdateError: (err: unknown) => performFullReload(err, sendMessage),
204+
chunkUpdateListenersGlobal: TURBOPACK_CHUNK_UPDATE_LISTENERS_GLOBAL,
204205
})
205206
})
206207

‎packages/next/src/client/next-dev-turbopack.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { initialize, version, router, emitter } from './'
44
import initHMR from './dev/hot-middleware-client'
55

66
import { pageBootstrap } from './page-bootstrap'
7+
// prettier-ignore
78
//@ts-expect-error requires "moduleResolution": "node16" in tsconfig.json and not .ts extension
8-
import { connect } from '@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/hmr-client.ts'
9+
import { connect, TURBOPACK_CHUNK_UPDATE_LISTENERS_GLOBAL } from '@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/hmr-client.ts'
910
import type { TurbopackMessageSentToBrowser } from '../server/dev/hot-reloader-types'
1011

1112
window.next = {
@@ -48,6 +49,7 @@ initialize({
4849
},
4950
sendMessage: devClient.sendTurbopackMessage,
5051
onUpdateError: devClient.handleUpdateError,
52+
chunkUpdateListenersGlobal: TURBOPACK_CHUNK_UPDATE_LISTENERS_GLOBAL,
5153
})
5254

5355
return pageBootstrap(assetPrefix)
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
'use client'
22

3+
async function fetchMore() {
4+
const res = await Promise.resolve('more data')
5+
return res
6+
}
7+
38
export default function Page() {
4-
return <button>Client</button>
9+
return (
10+
<div>
11+
<button onClick={() => fetchMore().then(console.log)}>Client</button>
12+
</div>
13+
)
514
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Server component page that uses top-level await (TLA).
2+
// Tests that TLA is properly transpiled for older browser targets.
3+
import { data } from '../tla'
4+
5+
export default function TlaPage() {
6+
return <div>{data.message}</div>
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This module uses top-level await (TLA) to test that Turbopack/SWC
2+
// properly transpiles async/await for older browser targets.
3+
export const data = await Promise.resolve({ message: 'loaded' })

0 commit comments

Comments
 (0)