Skip to content

Commit ea6402a

Browse files
xusd320fireairforce
authored andcommitted
feat(turbopack): apply utoo patches to canary
1 parent 7240c74 commit ea6402a

115 files changed

Lines changed: 6638 additions & 926 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: 561 additions & 255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ napi-derive = "2"
304304
napi-build = "2"
305305
nohash-hasher = "0.2.0"
306306
notify = "8.1.0"
307+
notify-types = "2.0.0"
307308
owo-colors = "4.2.2"
308309
parcel_selectors = "0.28.2"
309310
parking_lot = "0.12.1"
@@ -317,6 +318,7 @@ qstring = "0.7.2"
317318
quick_cache = { version = "0.6.14" }
318319
quote = "1.0.45"
319320
rand = "0.10.1"
321+
getrandom = "0.3"
320322
rayon = "1.10.0"
321323
regex = "1.12.3"
322324
regress = "0.10.4"
@@ -347,7 +349,7 @@ tempfile = "3.20.0"
347349
terminal_size = "0.3.0"
348350
thiserror = "1.0.48"
349351
thread_local = "1.1.8"
350-
tokio = "1.52.1"
352+
tokio = "=1.51.0"
351353
tokio-util = { version = "0.7.18", features = ["io", "rt"] }
352354
tracing = "0.1.44"
353355
tracing-subscriber = "0.3.16"
@@ -369,3 +371,7 @@ virtue = { git = "https://github.com/bgw/virtue.git", branch = "bgw/fix-generic-
369371
mdxjs = { git = "https://github.com/vercel-labs/mdxjs-rs-turbopack.git", branch = "turbopack" }
370372
# Doesn't compile on recent nightly versions because of https://github.com/Michael-F-Bryan/include_dir/pull/117
371373
include_dir = { git = "https://github.com/vercel-labs/include_dir", branch = "turbopack" }
374+
libmimalloc-sys = { git = "https://github.com/utooland/mimalloc_rust.git" }
375+
mimalloc = { git = "https://github.com/utooland/mimalloc_rust.git" }
376+
tokio = { git = "https://github.com/utooland/tokio.git", package = "tokio" }
377+
tokio-util = { git = "https://github.com/utooland/tokio.git", package = "tokio-util" }

apps/docs/.source/index.ts

Lines changed: 426 additions & 0 deletions
Large diffs are not rendered by default.
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' })

test/production/escheck-output/index.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,39 @@ describe('escheck-output', () => {
9797
expect(esCheckOutput).toContain('info: ✓ ES-Check passed!')
9898
})
9999
})
100+
101+
// Chrome 50 does not support async/await (added in Chrome 55).
102+
// This validates that TLA and async functions in app/tla.js and app/foo/page.js
103+
// are properly transpiled by SWC preset-env.
104+
// Webpack doesn't properly downlevel
105+
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
106+
'pre-async browsers',
107+
() => {
108+
let browserslist = ['chrome 50']
109+
110+
const { next } = nextTestSetup({
111+
files: __dirname,
112+
dependencies,
113+
packageJson: {
114+
browserslist,
115+
},
116+
})
117+
118+
it('should downlevel async/await', () => {
119+
let esCheckOutput = execSync(
120+
`node_modules/.bin/es-check checkBrowser ".next/static/**/*.js" --browserslistQuery="${browserslist.join(', ')}" --noCache`,
121+
{ cwd: next.testDir, encoding: 'utf8' }
122+
)
123+
124+
expect(esCheckOutput).toContain('info: ✓ ES-Check passed!')
125+
})
126+
127+
it('should render TLA page correctly', async () => {
128+
const res = await next.fetch('/tla-page')
129+
expect(res.status).toBe(200)
130+
const html = await res.text()
131+
expect(html).toContain('loaded')
132+
})
133+
}
134+
)
100135
})

turbopack/crates/turbo-persistence/src/static_sorted_file_builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ impl<E: Entry> StreamingSstWriter<E> {
951951
qfilter::Filter::new(actual_count.max(1), AMQF_FALSE_POSITIVE_RATE)
952952
.expect("Filter can't be constructed"),
953953
);
954-
955954
let fp_size = builder.fingerprint_size();
956955
assert!(fp_size < 32, "fp_size {fp_size} exceeds u32");
957956
let fp_mask = (1u32 << fp_size) - 1;

turbopack/crates/turbo-tasks-backend/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ smallvec = { workspace = true }
5656
tokio = { workspace = true }
5757
tracing = { workspace = true }
5858
turbo-bincode = { workspace = true }
59-
turbo-persistence = { workspace = true }
6059
turbo-rcstr = { workspace = true }
6160
turbo-tasks = { workspace = true }
6261
turbo-tasks-hash = { workspace = true }
6362
thread_local = { workspace = true }
6463

64+
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
65+
turbo-persistence = { workspace = true }
66+
6567
[dev-dependencies]
6668
criterion = { workspace = true, features = ["async_tokio"] }
6769
futures = { workspace = true }

turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
num::NonZeroU32,
77
ops::{ControlFlow, Deref},
88
thread::yield_now,
9-
time::{Duration, Instant},
9+
time::Duration,
1010
};
1111

1212
use anyhow::Result;
@@ -15,6 +15,7 @@ use indexmap::map::Entry;
1515
use ringmap::RingSet;
1616
use rustc_hash::{FxBuildHasher, FxHashMap};
1717
use smallvec::{SmallVec, smallvec};
18+
use tokio::time::Instant;
1819
#[cfg(feature = "trace_aggregation_update_queue")]
1920
use tracing::span::Span;
2021
#[cfg(any(

0 commit comments

Comments
 (0)