From 95e46f73e4cccbfc5aab25245bdc6e8fce85e11f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 6 Apr 2023 19:23:37 +0200 Subject: [PATCH] report error when using "use server" on module level (#47967) ### What? Add a error message when using "use server". * https://github.com/vercel/turbo/pull/4477 ### Why? Turbopack doesn't support "use server" yet. ### Other turbopack updates * https://github.com/vercel/turbo/pull/4464 * https://github.com/vercel/turbo/pull/4485 --- packages/next-swc/Cargo.lock | 60 +++++++++---------- packages/next-swc/Cargo.toml | 6 +- .../next-core/src/next_client/context.rs | 4 ++ .../next-core/src/next_server/context.rs | 19 +++++- .../next-dev-tests/tests/integration.rs | 3 +- ...tly not supported in Turbopack-9116b0.txt} | 0 .../next/app/use-server/input/app/action.tsx | 5 ++ .../next/app/use-server/input/app/layout.tsx | 7 +++ .../next/app/use-server/input/app/page.tsx | 15 +++++ .../next/app/use-server/input/app/test.tsx | 23 +++++++ .../next/app/use-server/input/next.config.js | 5 ++ ... not yet supported in Turbopack-1510a7.txt | 21 +++++++ ...ar__0__star__) is very dynamic-396b87.txt} | 0 ..._utf-8__quo__) is very dynamic-d45237.txt} | 0 ...ar__0__star__) is very dynamic-cd6d71.txt} | 0 ... => Issue while running loader-1c0742.txt} | 0 ... => Issue while running loader-8866d2.txt} | 0 ... => Issue while running loader-8f2bda.txt} | 0 ... => Issue while running loader-c22815.txt} | 0 ...ror resolving commonjs request-3ad478.txt} | 0 ...ing EcmaScript Modules request-9ffa01.txt} | 0 ...ing EcmaScript Modules request-daf185.txt} | 0 ...ing EcmaScript Modules request-fa478b.txt} | 0 ...ror resolving commonjs request-e2b9f3.txt} | 0 ...ror resolving commonjs request-6f1be7.txt} | 0 ..._.__b__quo__]) is very dynamic-38cc9a.txt} | 0 ...ror resolving commonjs request-35f347.txt} | 0 ..._.__c__quo__]) is very dynamic-0e3fb5.txt} | 0 28 files changed, 131 insertions(+), 37 deletions(-) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/{Implicit metadata from filesystem is currently not supported in Turbopack-968612.txt => Implicit metadata from filesystem is currently not supported in Turbopack-9116b0.txt} (100%) create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/next.config.js create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not yet supported in Turbopack-1510a7.txt rename packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/{lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-1df3b6.txt => lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-396b87.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/{lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-5d83f1.txt => lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-d45237.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/{lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-567257.txt => lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-cd6d71.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/{Issue while running loader-39f95f.txt => Issue while running loader-1c0742.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/{Issue while running loader-b3d9de.txt => Issue while running loader-8866d2.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/{Issue while running loader-3768ab.txt => Issue while running loader-8f2bda.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/{Issue while running loader-cf2285.txt => Issue while running loader-c22815.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/comptime/issues/{Error resolving commonjs request-7b7db2.txt => Error resolving commonjs request-3ad478.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/{Error resolving EcmaScript Modules request-34a231.txt => Error resolving EcmaScript Modules request-9ffa01.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/{Error resolving EcmaScript Modules request-51a61a.txt => Error resolving EcmaScript Modules request-daf185.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/{Error resolving EcmaScript Modules request-1b7727.txt => Error resolving EcmaScript Modules request-fa478b.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/parsing/issues/{Error resolving commonjs request-91c1b7.txt => Error resolving commonjs request-e2b9f3.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/{Error resolving commonjs request-87cea7.txt => Error resolving commonjs request-6f1be7.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/{lint TP1002 require([__quo__.__b__quo__]) is very dynamic-a5a1a8.txt => lint TP1002 require([__quo__.__b__quo__]) is very dynamic-38cc9a.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/{Error resolving commonjs request-edde7e.txt => Error resolving commonjs request-35f347.txt} (100%) rename packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/{lint TP1002 require([__quo__.__c__quo__]) is very dynamic-e2c065.txt => lint TP1002 require([__quo__.__c__quo__]) is very dynamic-0e3fb5.txt} (100%) diff --git a/packages/next-swc/Cargo.lock b/packages/next-swc/Cargo.lock index e49912ade4780..678fe0d3fe3e6 100644 --- a/packages/next-swc/Cargo.lock +++ b/packages/next-swc/Cargo.lock @@ -386,7 +386,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "serde", ] @@ -3302,7 +3302,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "serde", @@ -6687,7 +6687,7 @@ dependencies = [ [[package]] name = "turbo-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "auto-hash-map", "mdxjs", @@ -6724,7 +6724,7 @@ dependencies = [ [[package]] name = "turbo-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "mimalloc", ] @@ -6732,7 +6732,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "auto-hash-map", @@ -6762,7 +6762,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "cargo-lock", @@ -6774,7 +6774,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "bytes", @@ -6789,7 +6789,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "dotenvy", @@ -6803,7 +6803,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "indexmap", @@ -6820,7 +6820,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "auto-hash-map", @@ -6849,7 +6849,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "base16", "hex", @@ -6861,7 +6861,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -6875,7 +6875,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "proc-macro2", "quote", @@ -6885,7 +6885,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "auto-hash-map", @@ -6907,7 +6907,7 @@ dependencies = [ [[package]] name = "turbo-tasks-testing" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "auto-hash-map", @@ -6919,7 +6919,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-recursion", @@ -6945,7 +6945,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "clap 4.1.11", @@ -6961,7 +6961,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-trait", @@ -6988,7 +6988,7 @@ dependencies = [ [[package]] name = "turbopack-create-test-app" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "clap 4.1.11", @@ -7001,7 +7001,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-trait", @@ -7023,7 +7023,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "indexmap", @@ -7042,7 +7042,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-compression", @@ -7075,7 +7075,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-trait", @@ -7111,7 +7111,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "serde", @@ -7126,7 +7126,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "serde", @@ -7141,7 +7141,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "mdxjs", @@ -7156,7 +7156,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "async-stream", @@ -7190,7 +7190,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "serde", @@ -7206,7 +7206,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "swc_core", "turbo-tasks", @@ -7217,7 +7217,7 @@ dependencies = [ [[package]] name = "turbopack-test-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230405.4#6695841d11380db7f6b3a6e10644a83345643443" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230406.2#8d14e7091619884b271c69d9e9a7fc404c874132" dependencies = [ "anyhow", "once_cell", diff --git a/packages/next-swc/Cargo.toml b/packages/next-swc/Cargo.toml index 36be4be4cf0f6..dedeb7bf37ac0 100644 --- a/packages/next-swc/Cargo.toml +++ b/packages/next-swc/Cargo.toml @@ -47,11 +47,11 @@ swc_emotion = { version = "0.29.10" } testing = { version = "0.31.31" } # Turbo crates -turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230405.4" } +turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230406.2" } # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. -turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230405.4" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230406.2" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230405.4" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230406.2" } # General Deps diff --git a/packages/next-swc/crates/next-core/src/next_client/context.rs b/packages/next-swc/crates/next-core/src/next_client/context.rs index c60e88ee87ad2..dacbc5b36af90 100644 --- a/packages/next-swc/crates/next-core/src/next_client/context.rs +++ b/packages/next-swc/crates/next-core/src/next_client/context.rs @@ -19,6 +19,7 @@ use turbo_binding::{ free_var_references, }, dev::DevChunkingContextVc, + ecmascript::EcmascriptInputTransform, env::ProcessEnvAssetVc, node::execution_context::ExecutionContextVc, turbopack::{ @@ -175,6 +176,9 @@ pub async fn get_client_module_options_context( }; let module_options_context = ModuleOptionsContext { + custom_ecmascript_transforms: vec![EcmascriptInputTransform::ServerDirective( + StringVc::cell("TODO".to_string()), + )], preset_env_versions: Some(env), execution_context: Some(execution_context), ..Default::default() diff --git a/packages/next-swc/crates/next-core/src/next_server/context.rs b/packages/next-swc/crates/next-core/src/next_server/context.rs index 0eb7bba03dbf7..75f427eee4f33 100644 --- a/packages/next-swc/crates/next-core/src/next_server/context.rs +++ b/packages/next-swc/crates/next-core/src/next_server/context.rs @@ -259,6 +259,11 @@ pub async fn get_server_module_options_context( } ServerContextType::AppSSR { .. } => { let module_options_context = ModuleOptionsContext { + custom_ecmascript_transforms: vec![EcmascriptInputTransform::ServerDirective( + // ServerDirective is not implemented yet and always reports an issue. + // We don't have to pass a valid transition name yet, but the API is prepared. + StringVc::cell("TODO".to_string()), + )], execution_context: Some(execution_context), ..Default::default() }; @@ -279,9 +284,17 @@ pub async fn get_server_module_options_context( } ServerContextType::AppRSC { .. } => { let module_options_context = ModuleOptionsContext { - custom_ecmascript_transforms: vec![EcmascriptInputTransform::ClientDirective( - StringVc::cell("server-to-client".to_string()), - )], + custom_ecmascript_transforms: vec![ + EcmascriptInputTransform::ClientDirective(StringVc::cell( + "server-to-client".to_string(), + )), + EcmascriptInputTransform::ServerDirective( + // ServerDirective is not implemented yet and always reports an issue. + // We don't have to pass a valid transition name yet, but the API is + // prepared. + StringVc::cell("TODO".to_string()), + ), + ], execution_context: Some(execution_context), ..Default::default() }; diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration.rs b/packages/next-swc/crates/next-dev-tests/tests/integration.rs index 14a6256964a4a..0ec030ba4aeef 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration.rs +++ b/packages/next-swc/crates/next-dev-tests/tests/integration.rs @@ -108,8 +108,9 @@ fn run_async_test<'a, T>(future: impl Future + Send + 'a) -> T { } } -#[testing::fixture("tests/integration/*/*/*")] +#[testing::fixture("tests/integration/*/*/*/input")] fn test(resource: PathBuf) { + let resource = resource.parent().unwrap().to_path_buf(); if resource.ends_with("__skipped__") || resource.ends_with("__flakey__") { // "Skip" directories named `__skipped__`, which include test directories to // skip. These tests are not considered truly skipped by `cargo test`, but they diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/Implicit metadata from filesystem is currently not supported in Turbopack-968612.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/Implicit metadata from filesystem is currently not supported in Turbopack-9116b0.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/Implicit metadata from filesystem is currently not supported in Turbopack-968612.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/Implicit metadata from filesystem is currently not supported in Turbopack-9116b0.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx new file mode 100644 index 0000000000000..41a47cf25dfde --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx @@ -0,0 +1,5 @@ +'use server' + +export default async function Action() { + return 42 +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx new file mode 100644 index 0000000000000..7f4de05aba9b3 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx @@ -0,0 +1,7 @@ +export default function RootLayout({ children }: { children: any }) { + return ( + + {children} + + ); +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx new file mode 100644 index 0000000000000..1ebdc1d7496c3 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx @@ -0,0 +1,15 @@ +import Test from './test' + +export default async function Page() { + let action + try { + await import('./action') + } catch (e) { + action = e.toString() + } + return ( +
+ +
+ ) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.tsx new file mode 100644 index 0000000000000..fd5964c6add81 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.tsx @@ -0,0 +1,23 @@ +'use client' + +import { useEffect } from 'react' + +export default function Test({ action }) { + useEffect(() => { + import('@turbo/pack-test-harness').then(() => { + it('should run', () => {}) + it('should throw an error when importing server action in client component', async () => { + await expect(import('./action')).rejects.toMatchObject({ + message: + /Server actions \("use server"\) are not yet supported in Turbopack/, + }) + }) + it('should throw an error when importing server action in server component', () => { + expect(action).toMatch( + /Server actions \("use server"\) are not yet supported in Turbopack/ + ) + }) + }) + return () => {} + }, [action]) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/next.config.js new file mode 100644 index 0000000000000..ed0e87891f9e8 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/next.config.js @@ -0,0 +1,5 @@ +module.exports = { + experimental: { + appDir: true, + }, +}; diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not yet supported in Turbopack-1510a7.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not yet supported in Turbopack-1510a7.txt new file mode 100644 index 0000000000000..4d6c5a7afce7f --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not yet supported in Turbopack-1510a7.txt @@ -0,0 +1,21 @@ +PlainIssue { + severity: Error, + context: "[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx", + category: "unsupported", + title: "Server actions (\"use server\") are not yet supported in Turbopack", + description: "", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [ + PlainIssueProcessingPathItem { + context: Some( + "[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app", + ), + description: "Next.js App Page Route /", + }, + ], + ), +} \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-1df3b6.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-396b87.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-1df3b6.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0__star__) is very dynamic-396b87.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-5d83f1.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-d45237.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-5d83f1.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star__0__star__, __quo__utf-8__quo__) is very dynamic-d45237.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-567257.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-cd6d71.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-567257.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0__star__) is very dynamic-cd6d71.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-39f95f.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-1c0742.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-39f95f.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-1c0742.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-b3d9de.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-8866d2.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-b3d9de.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-8866d2.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-3768ab.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-8f2bda.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-3768ab.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-8f2bda.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-cf2285.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-c22815.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-cf2285.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-c22815.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/comptime/issues/Error resolving commonjs request-7b7db2.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/comptime/issues/Error resolving commonjs request-3ad478.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/comptime/issues/Error resolving commonjs request-7b7db2.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/comptime/issues/Error resolving commonjs request-3ad478.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-34a231.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-9ffa01.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-34a231.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-9ffa01.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-51a61a.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-daf185.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-51a61a.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-daf185.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-1b7727.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-fa478b.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-1b7727.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/named-chunks/issues/Error resolving EcmaScript Modules request-fa478b.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/parsing/issues/Error resolving commonjs request-91c1b7.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/parsing/issues/Error resolving commonjs request-e2b9f3.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/parsing/issues/Error resolving commonjs request-91c1b7.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/parsing/issues/Error resolving commonjs request-e2b9f3.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/Error resolving commonjs request-87cea7.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/Error resolving commonjs request-6f1be7.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/Error resolving commonjs request-87cea7.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/Error resolving commonjs request-6f1be7.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/lint TP1002 require([__quo__.__b__quo__]) is very dynamic-a5a1a8.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/lint TP1002 require([__quo__.__b__quo__]) is very dynamic-38cc9a.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/lint TP1002 require([__quo__.__b__quo__]) is very dynamic-a5a1a8.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies-context/issues/lint TP1002 require([__quo__.__b__quo__]) is very dynamic-38cc9a.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/Error resolving commonjs request-edde7e.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/Error resolving commonjs request-35f347.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/Error resolving commonjs request-edde7e.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/Error resolving commonjs request-35f347.txt diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/lint TP1002 require([__quo__.__c__quo__]) is very dynamic-e2c065.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/lint TP1002 require([__quo__.__c__quo__]) is very dynamic-0e3fb5.txt similarity index 100% rename from packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/lint TP1002 require([__quo__.__c__quo__]) is very dynamic-e2c065.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/webpack/chunks/__skipped__/weak-dependencies/issues/lint TP1002 require([__quo__.__c__quo__]) is very dynamic-0e3fb5.txt