Skip to content

Commit 946ccb0

Browse files

File tree

8 files changed

+428
-312
lines changed

8 files changed

+428
-312
lines changed

packages/next-swc/Cargo.lock

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

packages/next-swc/crates/core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ serde = "1"
1919
serde_json = "1"
2020
tracing = { version = "0.1.37", features = ["release_max_level_info"] }
2121

22-
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230201.1", features = [
22+
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02", features = [
2323
"__swc_core",
2424
"__swc_core_next_core",
2525
"__swc_transform_styled_jsx",
@@ -29,7 +29,7 @@ next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-2
2929
] }
3030

3131
[dev-dependencies]
32-
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230201.1", features = [
32+
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02", features = [
3333
"__swc_core_testing_transform",
3434
"__swc_testing",
3535
] }

packages/next-swc/crates/core/tests/full.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ fn test(input: &Path, minify: bool) {
3636
output_path: Some(output.clone()),
3737

3838
config: next_binding::swc::core::base::config::Config {
39-
is_module: next_binding::swc::core::base::config::IsModule::Bool(true),
39+
is_module: Some(next_binding::swc::core::base::config::IsModule::Bool(
40+
true,
41+
)),
4042

4143
jsc: next_binding::swc::core::base::config::JscConfig {
4244
minify: if minify {

packages/next-swc/crates/napi/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ tracing = { version = "0.1.37", features = ["release_max_level_info"] }
3939
tracing-futures = "0.2.5"
4040
tracing-subscriber = "0.3.9"
4141
tracing-chrome = "0.5.0"
42-
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230201.1", features = [
42+
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02" }
43+
turbo-tasks-memory = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02" }
44+
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02", features = [
4345
"__swc_core_binding_napi",
4446
"__turbo_next_dev_server",
4547
"__turbo_node_file_trace",

packages/next-swc/crates/napi/src/turbotrace.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@ use std::sync::Arc;
22

33
use napi::bindgen_prelude::*;
44
use next_binding::turbo::node_file_trace::{start, Args};
5+
use turbo_tasks::TurboTasks;
6+
use turbo_tasks_memory::MemoryBackend;
57

68
#[napi]
7-
pub async fn run_turbo_tracing(options: Buffer) -> napi::Result<Vec<String>> {
9+
pub fn create_turbo_tasks(memory_limit: Option<u32>) -> External<Arc<TurboTasks<MemoryBackend>>> {
10+
let turbo_tasks = TurboTasks::new(MemoryBackend::new(
11+
memory_limit.map(|m| m as usize).unwrap_or(usize::MAX),
12+
));
13+
External::new_with_size_hint(
14+
turbo_tasks,
15+
memory_limit
16+
.map(|m| (m as usize) * 1024 * 1024)
17+
.unwrap_or(usize::MAX),
18+
)
19+
}
20+
21+
#[napi]
22+
pub async fn run_turbo_tracing(
23+
options: Buffer,
24+
turbo_tasks: Option<External<Arc<TurboTasks<MemoryBackend>>>>,
25+
) -> napi::Result<Vec<String>> {
826
let args: Args = serde_json::from_slice(options.as_ref())?;
9-
let files = start(Arc::new(args)).await?;
27+
let turbo_tasks = turbo_tasks.map(|t| t.clone());
28+
let files = start(Arc::new(args), turbo_tasks.as_ref()).await?;
1029
Ok(files)
1130
}

packages/next-swc/crates/wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ wasm-bindgen-futures = "0.4.8"
3131
getrandom = { version = "0.2.5", optional = true, default-features = false }
3232
js-sys = "0.3.59"
3333
serde-wasm-bindgen = "0.4.3"
34-
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230201.1", features = [
34+
next-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230209.02", features = [
3535
"__swc_core_binding_wasm",
3636
"__feature_mdx_rs",
3737
] }

packages/next/src/build/swc/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,13 @@ function loadNative(isCustomTurbopack = false) {
441441
require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS).startDev(devOptions)
442442
}
443443
},
444-
startTrace: (options = {}) =>
445-
bindings.runTurboTracing(toBuffer({ exact: true, ...options })),
444+
startTrace: (options = {}, turboTasks: unknown) =>
445+
bindings.runTurboTracing(
446+
toBuffer({ exact: true, ...options }),
447+
turboTasks
448+
),
449+
createTurboTasks: (memoryLimit?: number): unknown =>
450+
bindings.createTurboTasks(memoryLimit),
446451
},
447452
mdx: {
448453
compile: (src: string, options: any) =>

test/development/acceptance/__snapshots__/ReactRefreshLogBox.test.ts.snap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ Error:
157157
\`----
158158
159159
Caused by:
160-
0: error was recoverable, but proceeding would result in wrong codegen
161-
1: Syntax Error
160+
Syntax Error
162161
163162
Import trace for requested module:
164163
./index.js"
@@ -177,8 +176,7 @@ Error:
177176
\`----
178177
179178
Caused by:
180-
0: error was recoverable, but proceeding would result in wrong codegen
181-
1: Syntax Error
179+
Syntax Error
182180
183181
Import trace for requested module:
184182
./index.js"

0 commit comments

Comments
 (0)