diff --git a/.config/nextest.toml b/.config/nextest.toml deleted file mode 100644 index 0cf785bf47865..0000000000000 --- a/.config/nextest.toml +++ /dev/null @@ -1,9 +0,0 @@ -[[profile.default.overrides]] -filter = "package(next-dev-tests)" -# Default is 100ms. Extending this addresses false positives in the -# next-dev integration tests. -leak-timeout = "500ms" -retries = 2 -slow-timeout = "60s" -threads-required = 4 -failure-output = "immediate-final" \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 8b9986c612630..14d25ae4ed4d7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -22,9 +22,6 @@ packages/next/src/bundles/webpack/packages/lazy-compilation-*.js packages/next-swc/crates/**/tests/**/output* packages/next-swc/crates/core/tests/loader/issue-32553/input.js -packages/next-swc/crates/next-dev-tests/tests/integration/turbopack/basic/error/input/broken.js -packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.js -packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/raw/hello.js packages/next-swc/native/**/* packages/next-codemod/transforms/__testfixtures__/** diff --git a/Cargo.lock b/Cargo.lock index 8f3479aaf5be0..c7e086c604fbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,12 +124,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -234,16 +228,6 @@ dependencies = [ "serde", ] -[[package]] -name = "assert-json-diff" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "ast_node" version = "0.9.5" @@ -257,17 +241,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "async-channel" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - [[package]] name = "async-compression" version = "0.3.15" @@ -281,91 +254,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "async-executor" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand 1.9.0", - "futures-lite", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-lock", - "blocking", - "futures-lite", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix 0.37.23", - "slab", - "socket2 0.4.9", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-object-pool" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb901c30ebc2fc4ab46395bbfbdba9542c16559d853645d75190c3056caf3bc" -dependencies = [ - "async-std", -] - -[[package]] -name = "async-process" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6381ead98388605d0d9ff86371043b5aa922a3905824244de40dc263a14fcba4" -dependencies = [ - "async-io", - "async-lock", - "autocfg", - "blocking", - "cfg-if 1.0.0", - "event-listener", - "futures-lite", - "libc", - "signal-hook", - "windows-sys 0.42.0", -] - [[package]] name = "async-recursion" version = "1.0.4" @@ -377,33 +265,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "async-std" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" -dependencies = [ - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - [[package]] name = "async-stream" version = "0.3.4" @@ -426,12 +287,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "async-task" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" - [[package]] name = "async-trait" version = "0.1.68" @@ -443,20 +298,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "async-tungstenite" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6acf7e4a267eecbb127ed696bb2d50572c22ba7f586a646321e1798d8336a1" -dependencies = [ - "futures-io", - "futures-util", - "log", - "pin-project-lite", - "tokio", - "tungstenite", -] - [[package]] name = "atomic-polyfill" version = "0.1.11" @@ -466,12 +307,6 @@ dependencies = [ "critical-section", ] -[[package]] -name = "atomic-waker" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" - [[package]] name = "atty" version = "0.2.14" @@ -766,20 +601,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "atomic-waker", - "fastrand 1.9.0", - "futures-lite", -] - [[package]] name = "brotli-decompressor" version = "2.3.4" @@ -918,18 +739,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "castaway" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" - [[package]] name = "cc" version = "1.0.83" @@ -940,12 +749,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - [[package]] name = "cexpr" version = "0.6.0" @@ -977,71 +780,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chromiumoxide" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbef58698a487c253c55c3d17bb1efbe268d2961a2c8278e3f86fff721355fc" -dependencies = [ - "async-tungstenite", - "base64 0.21.4", - "cfg-if 1.0.0", - "chromiumoxide_cdp", - "chromiumoxide_types", - "dunce", - "fnv", - "futures", - "futures-timer", - "pin-project-lite", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "url", - "which", - "winreg", -] - -[[package]] -name = "chromiumoxide_cdp" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902b90e019dff479bf5a36ed3961e955afa48c35fb2d4245d0b193e7746d50b9" -dependencies = [ - "chromiumoxide_pdl", - "chromiumoxide_types", - "serde", - "serde_json", -] - -[[package]] -name = "chromiumoxide_pdl" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9319fb29ecce08ac90dd5a798c391f6a8ae1d7c90aff71f3fa27cb3cdfc3ec" -dependencies = [ - "chromiumoxide_types", - "either", - "heck 0.4.1", - "once_cell", - "proc-macro2", - "quote", - "regex", - "serde", - "serde_json", -] - -[[package]] -name = "chromiumoxide_types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9187058637b8e555690935a6d25a1f7af1d71b377fc45b4257712efb34551f" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "chrono" version = "0.4.30" @@ -1057,33 +795,6 @@ dependencies = [ "windows-targets 0.48.1", ] -[[package]] -name = "ciborium" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" - -[[package]] -name = "ciborium-ll" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "clang-sys" version = "1.6.1" @@ -1110,18 +821,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "bitflags 1.3.2", - "clap_lex 0.2.4", - "indexmap 1.9.3", - "textwrap 0.16.0", -] - [[package]] name = "clap" version = "4.4.2" @@ -1140,7 +839,7 @@ checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", + "clap_lex", "strsim 0.10.0", "terminal_size 0.2.6", ] @@ -1166,15 +865,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.5.1" @@ -1218,16 +908,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "combine" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" -dependencies = [ - "bytes", - "memchr", -] - [[package]] name = "concurrent-queue" version = "2.1.0" @@ -1520,44 +1200,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "criterion" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" -dependencies = [ - "anes", - "atty", - "cast", - "ciborium", - "clap 3.2.23", - "criterion-plot", - "futures", - "itertools", - "lazy_static", - "num-traits", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools", -] - [[package]] name = "critical-section" version = "1.1.1" @@ -1703,37 +1345,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "curl" -version = "0.4.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2 0.4.9", - "winapi 0.3.9", -] - -[[package]] -name = "curl-sys" -version = "0.4.60+curl-7.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "717abe2cb465a5da6ce06617388a3980c9a2844196734bec8ccb8e575250f13f" -dependencies = [ - "cc", - "libc", - "libnghttp2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi 0.3.9", -] - [[package]] name = "cxx" version = "1.0.94" @@ -2143,19 +1754,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -2213,15 +1811,6 @@ dependencies = [ "hashbrown 0.13.2", ] -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.0.0" @@ -2341,12 +1930,6 @@ dependencies = [ "libc", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -2417,21 +2000,6 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.28" @@ -2466,12 +2034,6 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - [[package]] name = "futures-util" version = "0.3.28" @@ -2580,18 +2142,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "glyph-names" version = "0.2.0" @@ -2778,36 +2328,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "httpmock" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b02e044d3b4c2f94936fb05f9649efa658ca788f44eb6b87554e2033fc8ce93" -dependencies = [ - "assert-json-diff", - "async-object-pool", - "async-trait", - "base64 0.21.4", - "clap 4.4.2", - "crossbeam-utils", - "env_logger 0.10.0", - "form_urlencoded", - "futures-util", - "hyper", - "isahc", - "lazy_static", - "levenshtein", - "log", - "regex", - "serde", - "serde_json", - "serde_regex", - "serde_yaml 0.9.19", - "similar", - "tokio", - "url", -] - [[package]] name = "humantime" version = "2.1.0" @@ -3095,17 +2615,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.3", - "windows-sys 0.48.0", -] - [[package]] name = "is_ci" version = "1.1.1" @@ -3118,33 +2627,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89" -[[package]] -name = "isahc" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "334e04b4d781f436dc315cb1e7515bd96826426345d498149e4bde36b67f8ee9" -dependencies = [ - "async-channel", - "castaway", - "crossbeam-utils", - "curl", - "curl-sys", - "encoding_rs", - "event-listener", - "futures-lite", - "http", - "log", - "mime", - "once_cell", - "polling", - "slab", - "sluice", - "tracing", - "tracing-futures", - "url", - "waker-fn", -] - [[package]] name = "itertools" version = "0.10.5" @@ -3169,28 +2651,6 @@ dependencies = [ "bitstream-io", ] -[[package]] -name = "jni" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" -dependencies = [ - "cesu8", - "cfg-if 1.0.0", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", - "windows-sys 0.45.0", -] - -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - [[package]] name = "jobserver" version = "0.1.26" @@ -3240,15 +2700,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - [[package]] name = "lab" version = "0.11.0" @@ -3296,12 +2747,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" -[[package]] -name = "levenshtein" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" - [[package]] name = "lexical" version = "6.1.1" @@ -3432,16 +2877,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libnghttp2-sys" -version = "0.1.7+1.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libwebp-sys" version = "0.9.2" @@ -3550,9 +2985,6 @@ name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -dependencies = [ - "value-bag", -] [[package]] name = "loop9" @@ -3581,15 +3013,6 @@ dependencies = [ "libc", ] -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - [[package]] name = "markdown" version = "1.0.0-alpha.13" @@ -3680,15 +3103,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.8.0" @@ -3984,12 +3398,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - [[package]] name = "net2" version = "0.2.38" @@ -4038,113 +3446,48 @@ dependencies = [ "dunce", "indexmap 1.9.3", "indoc", - "mime_guess", - "next-core", - "serde", - "serde_json", - "tokio", - "tracing", - "tracing-subscriber", - "turbo-tasks", - "turbopack-binding", - "vergen", -] - -[[package]] -name = "next-core" -version = "0.1.0" -dependencies = [ - "allsorts", - "anyhow", - "async-recursion", - "async-trait", - "base64 0.21.4", - "const_format", - "futures", - "indexmap 1.9.3", - "indoc", - "lazy-regex", - "lazy_static", - "mime", - "mime_guess", - "next-transform-dynamic", - "next-transform-font", - "next-transform-strip-page-exports", - "once_cell", - "qstring", - "regex", - "serde", - "serde_json", - "swc_core", - "thiserror", - "turbo-tasks", - "turbo-tasks-fs", - "turbopack-binding", -] - -[[package]] -name = "next-dev" -version = "0.1.0" -dependencies = [ - "anyhow", - "chromiumoxide", - "clap 4.4.2", - "console-subscriber", - "criterion", - "dunce", - "futures", - "indexmap 1.9.3", - "mime", + "mime_guess", "next-core", - "nix", - "once_cell", - "owo-colors", - "parking_lot", - "portpicker", - "rand 0.8.5", - "regex", "serde", "serde_json", - "tempfile", "tokio", "tracing", "tracing-subscriber", - "tungstenite", "turbo-tasks", "turbopack-binding", - "url", "vergen", - "webbrowser", ] [[package]] -name = "next-dev-tests" +name = "next-core" version = "0.1.0" dependencies = [ + "allsorts", "anyhow", - "chromiumoxide", - "console-subscriber", - "dunce", + "async-recursion", + "async-trait", + "base64 0.21.4", + "const_format", "futures", - "httpmock", + "indexmap 1.9.3", + "indoc", + "lazy-regex", "lazy_static", "mime", - "next-core", - "next-dev", - "owo-colors", - "parking_lot", - "rand 0.8.5", + "mime_guess", + "next-transform-dynamic", + "next-transform-font", + "next-transform-strip-page-exports", + "once_cell", + "qstring", "regex", "serde", "serde_json", - "tempdir", - "testing", - "tokio", - "tungstenite", + "swc_core", + "thiserror", "turbo-tasks", + "turbo-tasks-fs", "turbopack-binding", - "url", - "webbrowser", ] [[package]] @@ -4184,7 +3527,6 @@ dependencies = [ "next-api", "next-build", "next-core", - "next-dev", "next-swc", "once_cell", "sentry", @@ -4229,20 +3571,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", - "memoffset 0.7.1", - "pin-utils", - "static_assertions", -] - [[package]] name = "node-file-trace" version = "0.1.0" @@ -4425,15 +3753,6 @@ dependencies = [ "libc", ] -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - [[package]] name = "object" version = "0.31.1" @@ -4449,12 +3768,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "openssl" version = "0.10.47" @@ -4500,12 +3813,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "os_str_bytes" -version = "6.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" - [[package]] name = "ouroboros" version = "0.17.2" @@ -4578,12 +3885,6 @@ dependencies = [ "vlq", ] -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.12.1" @@ -4763,7 +4064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared", - "rand 0.8.5", + "rand", ] [[package]] @@ -4827,34 +4128,6 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" -[[package]] -name = "plotters" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" - -[[package]] -name = "plotters-svg" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" -dependencies = [ - "plotters-backend", -] - [[package]] name = "pmutil" version = "0.6.1" @@ -4879,31 +4152,6 @@ dependencies = [ "miniz_oxide 0.7.1", ] -[[package]] -name = "polling" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if 1.0.0", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.45.0", -] - -[[package]] -name = "portpicker" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9" -dependencies = [ - "rand 0.8.5", -] - [[package]] name = "postcard" version = "1.0.4" @@ -5122,19 +4370,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce082a9940a7ace2ad4a8b7d0b1eac6aa378895f18be598230c5f2284ac05426" -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.8.5" @@ -5143,7 +4378,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -5153,24 +4388,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -5215,7 +4435,7 @@ dependencies = [ "num-traits", "once_cell", "paste", - "rand 0.8.5", + "rand", "rand_chacha", "rust_hawktracer", "rustc_version 0.4.0", @@ -5244,12 +4464,6 @@ dependencies = [ "rgb", ] -[[package]] -name = "raw-window-handle" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f851a03551ceefd30132e447f07f96cb7011d6b658374f3aed847333adb5559" - [[package]] name = "rayon" version = "1.7.0" @@ -5272,15 +4486,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.1.57" @@ -5390,15 +4595,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "rend" version = "0.4.0" @@ -5787,7 +4983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a4591a2d128af73b1b819ab95f143bc6a2fbe48cd23a4c45e1ee32177e66ae6" dependencies = [ "once_cell", - "rand 0.8.5", + "rand", "sentry-types", "serde", "serde_json", @@ -5973,19 +5169,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "serde_yaml" -version = "0.9.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82e6c8c047aa50a7328632d067bcae6ef38772a79e28daf32f735e0e4f3dd10" -dependencies = [ - "indexmap 1.9.3", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "sha-1" version = "0.10.0" @@ -6140,12 +5323,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" -[[package]] -name = "similar" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" - [[package]] name = "siphasher" version = "0.3.11" @@ -6167,17 +5344,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" -[[package]] -name = "sluice" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7400c0eff44aa2fcb5e31a5f24ba9716ed90138769e4977a2ba6014ae63eb5" -dependencies = [ - "async-channel", - "futures-core", - "futures-io", -] - [[package]] name = "smallvec" version = "1.11.0" @@ -7637,16 +6803,6 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - [[package]] name = "tempfile" version = "3.8.0" @@ -7654,7 +6810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if 1.0.0", - "fastrand 2.0.0", + "fastrand", "redox_syscall 0.3.5", "rustix 0.38.3", "windows-sys 0.48.0", @@ -7765,12 +6921,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.48" @@ -7875,16 +7025,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -8085,7 +7225,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand 0.8.5", + "rand", "slab", "tokio", "tokio-util", @@ -8231,7 +7371,7 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", + "rand", "sha1 0.10.5", "thiserror", "url", @@ -8425,19 +7565,6 @@ dependencies = [ "turbo-tasks-malloc", ] -[[package]] -name = "turbo-tasks-testing" -version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230922.3#ad585d32fed92986a4458fd47db2f50f1a3cba75" -dependencies = [ - "anyhow", - "auto-hash-map", - "futures", - "lazy_static", - "tokio", - "turbo-tasks", -] - [[package]] name = "turbopack" version = "0.1.0" @@ -8469,36 +7596,6 @@ dependencies = [ "turbopack-wasm", ] -[[package]] -name = "turbopack-bench" -version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230922.3#ad585d32fed92986a4458fd47db2f50f1a3cba75" -dependencies = [ - "anyhow", - "chromiumoxide", - "criterion", - "dunce", - "futures", - "mime", - "nix", - "once_cell", - "owo-colors", - "parking_lot", - "portpicker", - "rand 0.8.5", - "regex", - "serde", - "serde_json", - "tempfile", - "tokio", - "tungstenite", - "turbo-tasks", - "turbo-tasks-testing", - "turbopack-create-test-app", - "url", - "webbrowser", -] - [[package]] name = "turbopack-binding" version = "0.1.0" @@ -8523,9 +7620,7 @@ dependencies = [ "turbo-tasks-hash", "turbo-tasks-malloc", "turbo-tasks-memory", - "turbo-tasks-testing", "turbopack", - "turbopack-bench", "turbopack-build", "turbopack-cli-utils", "turbopack-core", @@ -8539,7 +7634,6 @@ dependencies = [ "turbopack-image", "turbopack-node", "turbopack-static", - "turbopack-test-utils", ] [[package]] @@ -8617,19 +7711,6 @@ dependencies = [ "turbo-tasks-hash", ] -[[package]] -name = "turbopack-create-test-app" -version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230922.3#ad585d32fed92986a4458fd47db2f50f1a3cba75" -dependencies = [ - "anyhow", - "clap 4.4.2", - "indoc", - "pathdiff", - "serde_json", - "tempfile", -] - [[package]] name = "turbopack-css" version = "0.1.0" @@ -8926,24 +8007,6 @@ dependencies = [ "turbopack-core", ] -[[package]] -name = "turbopack-test-utils" -version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230922.3#ad585d32fed92986a4458fd47db2f50f1a3cba75" -dependencies = [ - "anyhow", - "once_cell", - "regex", - "serde", - "similar", - "turbo-tasks", - "turbo-tasks-build", - "turbo-tasks-fs", - "turbo-tasks-hash", - "turbopack-cli-utils", - "turbopack-core", -] - [[package]] name = "turbopack-wasm" version = "0.1.0" @@ -8970,7 +8033,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if 1.0.0", - "rand 0.8.5", + "rand", "static_assertions", ] @@ -9098,12 +8161,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "unsafe-libyaml" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2024452afd3874bf539695e04af6732ba06517424dbf958fdb16a01f3bef6c" - [[package]] name = "untrusted" version = "0.7.1" @@ -9169,12 +8226,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "value-bag" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4d330786735ea358f3bc09eea4caa098569c1c93f342d9aca0514915022fe7e" - [[package]] name = "vcpkg" version = "0.2.15" @@ -9680,13 +8731,13 @@ dependencies = [ "once_cell", "petgraph", "pin-project", - "rand 0.8.5", + "rand", "semver 1.0.18", "serde", "serde_cbor", "serde_derive", "serde_json", - "serde_yaml 0.8.26", + "serde_yaml", "sha2", "shellexpand", "tempfile", @@ -9790,23 +8841,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webbrowser" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579cc485bd5ce5bfa0d738e4921dd0b956eca9800be1fd2e5257ebe95bc4617e" -dependencies = [ - "core-foundation", - "dirs", - "jni", - "log", - "ndk-context", - "objc", - "raw-window-handle", - "url", - "web-sys", -] - [[package]] name = "webc" version = "5.0.4" @@ -9822,7 +8856,7 @@ dependencies = [ "lexical-sort", "once_cell", "path-clean", - "rand 0.8.5", + "rand", "serde", "serde_cbor", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index f870ee65118a1..0e915ed219bcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,6 @@ members = [ "packages/next-swc/crates/next-api", "packages/next-swc/crates/next-build", "packages/next-swc/crates/next-core", - "packages/next-swc/crates/next-dev", - "packages/next-swc/crates/next-dev-tests", "packages/next-swc/crates/next-transform-font", "packages/next-swc/crates/next-transform-dynamic", "packages/next-swc/crates/next-transform-strip-page-exports", @@ -29,10 +27,6 @@ opt-level = 3 next-api = { path = "packages/next-swc/crates/next-api", default-features = false } next-build = { path = "packages/next-swc/crates/next-build", default-features = false } next-core = { path = "packages/next-swc/crates/next-core", default-features = false } -next-dev = { path = "packages/next-swc/crates/next-dev", default-features = false, features = [ - "serializable", -] } -next-dev-tests = { path = "packages/next-swc/crates/next-dev-tests" } next-transform-font = { path = "packages/next-swc/crates/next-transform-font" } next-transform-dynamic = { path = "packages/next-swc/crates/next-transform-dynamic" } next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-transform-strip-page-exports" } diff --git a/packages/next-swc/crates/napi/Cargo.toml b/packages/next-swc/crates/napi/Cargo.toml index 8bf6bac4f4f00..a92e0953ca0cc 100644 --- a/packages/next-swc/crates/napi/Cargo.toml +++ b/packages/next-swc/crates/napi/Cargo.toml @@ -17,9 +17,8 @@ plugin = ["turbopack-binding/__swc_core_binding_napi_plugin", "turbopack-binding sentry_native_tls = ["sentry", "sentry/native-tls", "native-tls"] sentry_rustls = ["sentry", "sentry/rustls", "rustls-tls"] -native-tls = ["next-dev/native-tls"] -rustls-tls = ["next-dev/rustls-tls"] -serializable = ["next-dev/serializable"] +native-tls = ["next-core/native-tls"] +rustls-tls = ["next-core/rustls-tls"] image-webp = ["next-core/image-webp"] image-avif = ["next-core/image-avif"] # Enable all the available image codec support. @@ -49,7 +48,6 @@ napi = { version = "2", default-features = false, features = [ ] } napi-derive = "2" next-swc = { version = "0.0.0", path = "../core" } -next-dev = { workspace = true } next-api = { workspace = true } next-build = { workspace = true } next-core = { workspace = true } diff --git a/packages/next-swc/crates/next-api/Cargo.toml b/packages/next-swc/crates/next-api/Cargo.toml index 9774503411c51..868f1eaeb9c91 100644 --- a/packages/next-swc/crates/next-api/Cargo.toml +++ b/packages/next-swc/crates/next-api/Cargo.toml @@ -10,10 +10,8 @@ autobenches = false bench = false [features] -default = ["custom_allocator", "native-tls"] +default = ["custom_allocator"] custom_allocator = ["turbopack-binding/__turbo_tasks_malloc", "turbopack-binding/__turbo_tasks_malloc_custom_allocator"] -native-tls = ["next-core/native-tls"] -rustls-tls = ["next-core/rustls-tls"] [dependencies] anyhow = { workspace = true, features = ["backtrace"] } @@ -47,4 +45,4 @@ tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } shadow-rs = { workspace = true } turbopack-binding = { workspace = true, features = [ "__turbo_tasks_build" -]} \ No newline at end of file +]} diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs deleted file mode 100644 index 72b376e2ec681..0000000000000 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ /dev/null @@ -1,1221 +0,0 @@ -use std::{collections::HashMap, io::Write as _}; - -use anyhow::{bail, Result}; -use indexmap::indexmap; -use indoc::formatdoc; -use serde::{Deserialize, Serialize}; -use serde_json::Value as JsonValue; -use turbo_tasks::{trace::TraceRawVcs, TaskInput, Vc}; -use turbopack_binding::{ - turbo::{ - tasks::Value, - tasks_env::{CustomProcessEnv, EnvMap, ProcessEnv}, - tasks_fs::{rope::RopeBuilder, File, FileSystemPath}, - }, - turbopack::{ - core::{ - asset::AssetContent, - chunk::{ChunkingContext, EvaluatableAsset, EvaluatableAssetExt}, - compile_time_info::CompileTimeInfo, - context::AssetContext, - environment::ServerAddr, - file_source::FileSource, - reference_type::{ - EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType, - }, - source::Sources, - virtual_source::VirtualSource, - }, - dev::DevChunkingContext, - dev_server::{ - html::DevHtmlAsset, - source::{ - combined::CombinedContentSource, - route_tree::{BaseSegment, RouteType}, - ContentSource, ContentSourceData, ContentSourceExt, NoContentSource, - }, - }, - ecmascript::chunk::EcmascriptChunkingContext, - env::ProcessEnvAsset, - node::{ - debug::should_debug, - execution_context::ExecutionContext, - render::{ - node_api_source::create_node_api_source, - rendered_source::create_node_rendered_source, - }, - NodeEntry, NodeRenderingEntry, - }, - turbopack::{transition::Transition, ModuleAssetContext}, - }, -}; - -use crate::{ - app_render::next_server_component_transition::NextServerComponentTransition, - app_segment_config::{parse_segment_config_from_loader_tree, parse_segment_config_from_source}, - app_structure::{get_entrypoints, Entrypoint, LoaderTree, MetadataItem, OptionAppDir}, - bootstrap::{route_bootstrap, BootstrapConfig}, - embed_js::{next_asset, next_js_file_path}, - env::env_for_js, - fallback::get_fallback_page, - loader_tree::{LoaderTreeModule, ServerComponentTransition}, - mode::NextMode, - next_app::{metadata::route::get_app_metadata_route_source, AppPage, AppPath, PathSegment}, - next_client::{ - context::{ - get_client_assets_path, get_client_module_options_context, - get_client_resolve_options_context, get_client_runtime_entries, ClientContextType, - }, - transition::NextClientTransition, - }, - next_client_chunks::client_chunks_transition::NextClientChunksTransition, - next_client_component::{ - server_to_client_transition::NextServerToClientTransition, - ssr_client_module_transition::NextSSRClientModuleTransition, - }, - next_config::NextConfig, - next_edge::{ - context::{get_edge_compile_time_info, get_edge_resolve_options_context}, - page_transition::NextEdgePageTransition, - route_transition::NextEdgeRouteTransition, - }, - next_route_matcher::{NextFallbackMatcher, NextParamsMatcher}, - next_server::{ - context::{ - get_server_compile_time_info, get_server_module_options_context, - get_server_resolve_options_context, ServerContextType, - }, - route_transition::NextRouteTransition, - }, - util::{render_data, NextRuntime}, -}; - -fn app_path_to_segments(path: &AppPath) -> Result<(Vec, RouteType)> { - let mut segments = Vec::new(); - let mut iter = path.iter().peekable(); - - while let Some(segment) = iter.next() { - match segment { - PathSegment::Static(s) => { - segments.push(BaseSegment::Static(s.to_string())); - } - PathSegment::Dynamic(_) => { - segments.push(BaseSegment::Dynamic); - } - PathSegment::CatchAll(_) | PathSegment::OptionalCatchAll(_) => { - if iter.peek().is_some() { - bail!( - "Invalid route {}, catch all segment must be the last segment", - path - ) - } - - return Ok((segments, RouteType::CatchAll)); - } - } - } - Ok((segments, RouteType::Exact)) -} - -#[turbo_tasks::function] -async fn next_client_transition( - project_path: Vc, - execution_context: Vc, - app_dir: Vc, - env: Vc>, - client_chunking_context: Vc>, - client_compile_time_info: Vc, - next_config: Vc, -) -> Result>> { - let ty: Value = Value::new(ClientContextType::App { app_dir }); - let mode = NextMode::DevServer; - let client_module_options_context = get_client_module_options_context( - project_path, - execution_context, - client_compile_time_info.environment(), - ty, - mode, - next_config, - ); - let client_runtime_entries = - get_client_runtime_entries(project_path, env, ty, mode, next_config, execution_context); - let client_resolve_options_context = - get_client_resolve_options_context(project_path, ty, mode, next_config, execution_context); - - Ok(Vc::upcast( - NextClientTransition { - is_app: true, - client_chunking_context, - client_module_options_context, - client_resolve_options_context, - client_compile_time_info, - runtime_entries: client_runtime_entries, - } - .cell(), - )) -} - -#[turbo_tasks::function] -fn next_ssr_client_module_transition( - project_path: Vc, - execution_context: Vc, - app_dir: Vc, - process_env: Vc>, - next_config: Vc, - server_addr: Vc, -) -> Vc> { - let ty = Value::new(ServerContextType::AppSSR { app_dir }); - let mode = NextMode::DevServer; - Vc::upcast( - NextSSRClientModuleTransition { - ssr_module_options_context: get_server_module_options_context( - project_path, - execution_context, - ty, - mode, - next_config, - ), - ssr_resolve_options_context: get_server_resolve_options_context( - project_path, - ty, - mode, - next_config, - execution_context, - ), - ssr_environment: get_server_compile_time_info(mode, process_env, server_addr), - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_edge_ssr_client_module_transition( - project_path: Vc, - dist_root: Vc, - execution_context: Vc, - app_dir: Vc, - next_config: Vc, - server_addr: Vc, -) -> Vc> { - let ty = Value::new(ServerContextType::AppSSR { app_dir }); - let mode = NextMode::DevServer; - Vc::upcast( - NextSSRClientModuleTransition { - ssr_module_options_context: get_server_module_options_context( - project_path, - execution_context, - ty, - mode, - next_config, - ), - ssr_resolve_options_context: get_edge_resolve_options_context( - project_path, - ty, - mode, - next_config, - execution_context, - ), - ssr_environment: get_edge_compile_time_info(project_path, server_addr, dist_root), - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_server_component_transition( - project_path: Vc, - execution_context: Vc, - app_dir: Vc, - server_root: Vc, - process_env: Vc>, - next_config: Vc, - server_addr: Vc, - ecmascript_client_reference_transition_name: Vc, -) -> Vc> { - let mode = NextMode::DevServer; - let ty = Value::new(ServerContextType::AppRSC { - app_dir, - client_transition: None, - ecmascript_client_reference_transition_name: Some( - ecmascript_client_reference_transition_name, - ), - }); - let rsc_compile_time_info = get_server_compile_time_info(mode, process_env, server_addr); - let rsc_resolve_options_context = - get_server_resolve_options_context(project_path, ty, mode, next_config, execution_context); - let rsc_module_options_context = - get_server_module_options_context(project_path, execution_context, ty, mode, next_config); - - Vc::upcast( - NextServerComponentTransition { - rsc_compile_time_info, - rsc_module_options_context, - rsc_resolve_options_context, - server_root, - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_route_transition( - project_path: Vc, - app_dir: Vc, - process_env: Vc>, - next_config: Vc, - server_addr: Vc, - execution_context: Vc, -) -> Vc> { - let mode = NextMode::DevServer; - let server_ty = Value::new(ServerContextType::AppRoute { app_dir }); - - let server_compile_time_info = get_server_compile_time_info(mode, process_env, server_addr); - - let server_resolve_options_context = get_server_resolve_options_context( - project_path, - server_ty, - mode, - next_config, - execution_context, - ); - - Vc::upcast( - NextRouteTransition { - server_compile_time_info, - server_resolve_options_context, - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_edge_server_component_transition( - project_path: Vc, - dist_root: Vc, - execution_context: Vc, - app_dir: Vc, - server_root: Vc, - mode: NextMode, - next_config: Vc, - server_addr: Vc, - ecmascript_client_reference_transition_name: Vc, -) -> Vc> { - let ty = Value::new(ServerContextType::AppRSC { - app_dir, - client_transition: None, - ecmascript_client_reference_transition_name: Some( - ecmascript_client_reference_transition_name, - ), - }); - let rsc_compile_time_info = get_edge_compile_time_info(project_path, server_addr, dist_root); - let rsc_resolve_options_context = - get_edge_resolve_options_context(project_path, ty, mode, next_config, execution_context); - let rsc_module_options_context = - get_server_module_options_context(project_path, execution_context, ty, mode, next_config); - - Vc::upcast( - NextServerComponentTransition { - rsc_compile_time_info, - rsc_module_options_context, - rsc_resolve_options_context, - server_root, - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_edge_route_transition( - project_path: Vc, - dist_root: Vc, - app_dir: Vc, - server_root: Vc, - next_config: Vc, - server_addr: Vc, - output_path: Vc, - execution_context: Vc, -) -> Vc> { - let mode = NextMode::DevServer; - let server_ty = Value::new(ServerContextType::AppRoute { app_dir }); - - let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr, dist_root); - - let edge_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - output_path.join("edge".to_string()), - output_path.join("edge/chunks".to_string()), - get_client_assets_path(server_root), - edge_compile_time_info.environment(), - ) - .reference_chunk_source_maps(should_debug("app_source")) - .build(), - ); - let edge_resolve_options_context = get_edge_resolve_options_context( - project_path, - server_ty, - mode, - next_config, - execution_context, - ); - - Vc::upcast( - NextEdgeRouteTransition { - edge_compile_time_info, - edge_chunking_context, - edge_module_options_context: None, - edge_resolve_options_context, - output_path, - base_path: app_dir, - bootstrap_asset: next_asset("entry/app/edge-route-bootstrap.ts".to_string()), - entry_name: "edge".to_string(), - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn next_edge_page_transition( - project_path: Vc, - dist_root: Vc, - app_dir: Vc, - server_root: Vc, - mode: NextMode, - next_config: Vc, - server_addr: Vc, - output_path: Vc, - execution_context: Vc, -) -> Vc> { - let server_ty = Value::new(ServerContextType::AppSSR { app_dir }); - - let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr, dist_root); - - let edge_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - output_path.join("edge-pages".to_string()), - output_path.join("edge-pages/chunks".to_string()), - get_client_assets_path(server_root), - edge_compile_time_info.environment(), - ) - .layer("ssr") - .reference_chunk_source_maps(should_debug("app_source")) - .build(), - ); - let edge_resolve_options_context = get_edge_resolve_options_context( - project_path, - server_ty, - mode, - next_config, - execution_context, - ); - - Vc::upcast( - NextEdgePageTransition { - edge_compile_time_info, - edge_chunking_context, - edge_module_options_context: None, - edge_resolve_options_context, - output_path, - bootstrap_asset: next_asset("entry/app/edge-page-bootstrap.ts".to_string()), - } - .cell(), - ) -} - -#[turbo_tasks::function] -fn app_context( - project_path: Vc, - dist_root: Vc, - execution_context: Vc, - server_root: Vc, - app_dir: Vc, - env: Vc>, - client_chunking_context: Vc>, - client_compile_time_info: Vc, - ssr: bool, - mode: NextMode, - next_config: Vc, - server_addr: Vc, - output_path: Vc, -) -> Vc { - let mut transitions = HashMap::new(); - transitions.insert( - "next-edge-route".to_string(), - next_edge_route_transition( - project_path, - dist_root, - app_dir, - server_root, - next_config, - server_addr, - output_path, - execution_context, - ), - ); - transitions.insert( - "next-route".to_string(), - next_route_transition( - project_path, - app_dir, - env, - next_config, - server_addr, - execution_context, - ), - ); - transitions.insert( - "next-edge-page".to_string(), - next_edge_page_transition( - project_path, - dist_root, - app_dir, - server_root, - mode, - next_config, - server_addr, - output_path, - execution_context, - ), - ); - let ecmacscript_client_reference_transition_name = "server-to-client".to_string(); - transitions.insert( - "next-server-component".to_string(), - next_server_component_transition( - project_path, - execution_context, - app_dir, - server_root, - env, - next_config, - server_addr, - Vc::cell(ecmacscript_client_reference_transition_name.clone()), - ), - ); - transitions.insert( - ecmacscript_client_reference_transition_name, - Vc::upcast(NextServerToClientTransition { ssr, edge: false }.cell()), - ); - let ecmacscript_edge_client_reference_transition_name = "edge-server-to-client".to_string(); - transitions.insert( - "next-edge-server-component".to_string(), - next_edge_server_component_transition( - project_path, - dist_root, - execution_context, - app_dir, - server_root, - mode, - next_config, - server_addr, - Vc::cell(ecmacscript_edge_client_reference_transition_name.clone()), - ), - ); - transitions.insert( - ecmacscript_edge_client_reference_transition_name, - Vc::upcast(NextServerToClientTransition { ssr, edge: true }.cell()), - ); - transitions.insert( - "next-client".to_string(), - next_client_transition( - project_path, - execution_context, - app_dir, - env, - Vc::upcast(client_chunking_context), - client_compile_time_info, - next_config, - ), - ); - let client_ty = Value::new(ClientContextType::App { app_dir }); - transitions.insert( - "next-client-chunks".to_string(), - Vc::upcast(NextClientChunksTransition::new( - project_path, - execution_context, - client_ty, - mode, - client_chunking_context, - client_compile_time_info, - next_config, - )), - ); - transitions.insert( - "next-ssr-client-module".to_string(), - next_ssr_client_module_transition( - project_path, - execution_context, - app_dir, - env, - next_config, - server_addr, - ), - ); - transitions.insert( - "next-edge-ssr-client-module".to_string(), - next_edge_ssr_client_module_transition( - project_path, - dist_root, - execution_context, - app_dir, - next_config, - server_addr, - ), - ); - - let ssr_ty = Value::new(ServerContextType::AppSSR { app_dir }); - ModuleAssetContext::new( - Vc::cell(transitions), - get_server_compile_time_info(mode, env, server_addr), - get_server_module_options_context( - project_path, - execution_context, - ssr_ty, - mode, - next_config, - ), - get_server_resolve_options_context( - project_path, - ssr_ty, - mode, - next_config, - execution_context, - ), - ) -} - -/// Create a content source serving the `app` or `src/app` directory as -/// Next.js app folder. -#[turbo_tasks::function] -pub async fn create_app_source( - app_dir: Vc, - dist_root: Vc, - project_path: Vc, - execution_context: Vc, - output_path: Vc, - server_root: Vc, - env: Vc>, - client_chunking_context: Vc>, - client_compile_time_info: Vc, - next_config: Vc, - server_addr: Vc, -) -> Result>> { - let Some(app_dir) = *app_dir.await? else { - return Ok(Vc::upcast(NoContentSource::new())); - }; - let entrypoints = get_entrypoints(app_dir, next_config.page_extensions()); - - let mode = NextMode::DevServer; - - let context_ssr = app_context( - project_path, - dist_root, - execution_context, - server_root, - app_dir, - env, - client_chunking_context, - client_compile_time_info, - true, - mode, - next_config, - server_addr, - output_path, - ); - let context = app_context( - project_path, - dist_root, - execution_context, - server_root, - app_dir, - env, - client_chunking_context, - client_compile_time_info, - false, - mode, - next_config, - server_addr, - output_path, - ); - - let injected_env = env_for_js(Vc::upcast(EnvMap::empty()), false, next_config); - let env = Vc::upcast(CustomProcessEnv::new(env, next_config.env())); - - let server_runtime_entries = Vc::cell(vec![Vc::upcast(ProcessEnvAsset::new( - project_path, - injected_env, - ))]); - - let fallback_page = get_fallback_page( - project_path, - execution_context, - server_root, - env, - client_compile_time_info, - next_config, - ); - let render_data = render_data(next_config, server_addr); - - let entrypoints = entrypoints.await?; - let mut sources: Vec<_> = entrypoints - .iter() - .map(|(_, entrypoint)| match *entrypoint { - Entrypoint::AppPage { - ref page, - loader_tree, - } => create_app_page_source_for_route( - page.clone(), - loader_tree, - context_ssr, - context, - project_path, - app_dir, - env, - server_root, - server_runtime_entries, - fallback_page, - output_path, - render_data, - ), - Entrypoint::AppRoute { ref page, path } => create_app_route_source_for_route( - page.clone(), - mode, - path, - context_ssr, - project_path, - app_dir, - env, - server_root, - server_runtime_entries, - output_path, - render_data, - ), - Entrypoint::AppMetadata { ref page, metadata } => create_app_route_source_for_metadata( - page.clone(), - mode, - context_ssr, - project_path, - app_dir, - env, - server_root, - server_runtime_entries, - output_path, - render_data, - metadata, - ), - }) - .collect(); - - if let Some(&Entrypoint::AppPage { - page: _, - loader_tree, - }) = entrypoints.get("/_not-found") - { - if loader_tree.await?.components.await?.not_found.is_some() { - // Only add a source for the app 404 page if a top-level not-found page is - // defined. Otherwise, the 404 page is handled by the pages logic. - let not_found_page_source = create_app_not_found_page_source( - loader_tree, - context_ssr, - context, - project_path, - app_dir, - env, - server_root, - server_runtime_entries, - fallback_page, - output_path, - render_data, - ); - sources.push(not_found_page_source); - } - } - - Ok(Vc::upcast(CombinedContentSource { sources }.cell())) -} - -#[turbo_tasks::function] -async fn create_app_page_source_for_route( - page: AppPage, - loader_tree: Vc, - context_ssr: Vc, - context: Vc, - project_path: Vc, - app_dir: Vc, - env: Vc>, - server_root: Vc, - runtime_entries: Vc, - fallback_page: Vc, - intermediate_output_path_root: Vc, - render_data: Vc, -) -> Result>> { - let app_path = AppPath::from(page.clone()); - let pathname_vc = Vc::cell(app_path.to_string()); - - let params_matcher = NextParamsMatcher::new(pathname_vc); - - let (base_segments, route_type) = app_path_to_segments(&app_path)?; - - let source = create_node_rendered_source( - project_path, - env, - base_segments, - route_type, - server_root, - Vc::upcast(params_matcher), - pathname_vc, - Vc::upcast( - AppRenderer { - runtime_entries, - context_ssr, - context, - server_root, - project_path, - intermediate_output_path: intermediate_output_path_root, - loader_tree, - } - .cell(), - ), - fallback_page, - render_data, - should_debug("app_source"), - ); - - Ok(source.issue_file_path(app_dir, format!("Next.js App Page Route {app_path}"))) -} - -#[turbo_tasks::function] -async fn create_app_not_found_page_source( - loader_tree: Vc, - context_ssr: Vc, - context: Vc, - project_path: Vc, - app_dir: Vc, - env: Vc>, - server_root: Vc, - runtime_entries: Vc, - fallback_page: Vc, - intermediate_output_path_root: Vc, - render_data: Vc, -) -> Result>> { - let pathname_vc = Vc::cell("/404".to_string()); - - let source = create_node_rendered_source( - project_path, - env, - Vec::new(), - RouteType::NotFound, - server_root, - Vc::upcast(NextFallbackMatcher::new()), - pathname_vc, - Vc::upcast( - AppRenderer { - runtime_entries, - context_ssr, - context, - server_root, - project_path, - intermediate_output_path: intermediate_output_path_root, - loader_tree, - } - .cell(), - ), - fallback_page, - render_data, - should_debug("app_source"), - ); - - Ok(source.issue_file_path(app_dir, "Next.js App Page Route /404".to_string())) -} - -#[turbo_tasks::function] -async fn create_app_route_source_for_route( - page: AppPage, - mode: NextMode, - entry_path: Vc, - context_ssr: Vc, - project_path: Vc, - app_dir: Vc, - env: Vc>, - server_root: Vc, - runtime_entries: Vc, - intermediate_output_path_root: Vc, - render_data: Vc, -) -> Result>> { - let app_path = AppPath::from(page.clone()); - let pathname_vc = Vc::cell(app_path.to_string()); - - let params_matcher = NextParamsMatcher::new(pathname_vc); - - let (base_segments, route_type) = app_path_to_segments(&app_path)?; - - let source = create_node_api_source( - project_path, - env, - base_segments, - route_type, - server_root, - Vc::upcast(params_matcher), - pathname_vc, - Vc::upcast( - AppRoute { - context: context_ssr, - runtime_entries, - server_root, - entry: AppRouteEntry::Path(entry_path), - mode, - project_path, - intermediate_output_path: intermediate_output_path_root, - output_root: intermediate_output_path_root, - app_dir, - } - .cell(), - ), - render_data, - should_debug("app_source"), - ); - - Ok(source.issue_file_path(app_dir, format!("Next.js App Route {app_path}"))) -} - -#[turbo_tasks::function] -async fn create_app_route_source_for_metadata( - page: AppPage, - mode: NextMode, - context_ssr: Vc, - project_path: Vc, - app_dir: Vc, - env: Vc>, - server_root: Vc, - runtime_entries: Vc, - intermediate_output_path_root: Vc, - render_data: Vc, - metadata: MetadataItem, -) -> Result>> { - let app_path = AppPath::from(page.clone()); - let pathname_vc = Vc::cell(app_path.to_string()); - - let params_matcher = NextParamsMatcher::new(pathname_vc); - - let (base_segments, route_type) = app_path_to_segments(&app_path)?; - - let source = create_node_api_source( - project_path, - env, - base_segments, - route_type, - server_root, - Vc::upcast(params_matcher), - pathname_vc, - Vc::upcast( - AppRoute { - context: context_ssr, - runtime_entries, - server_root, - entry: AppRouteEntry::Metadata { metadata, page }, - mode, - project_path, - intermediate_output_path: intermediate_output_path_root, - output_root: intermediate_output_path_root, - app_dir, - } - .cell(), - ), - render_data, - should_debug("app_source"), - ); - - Ok(source.issue_file_path(app_dir, format!("Next.js App Route {app_path}"))) -} - -/// The renderer for pages in app directory -#[turbo_tasks::value] -struct AppRenderer { - runtime_entries: Vc, - context_ssr: Vc, - context: Vc, - project_path: Vc, - server_root: Vc, - intermediate_output_path: Vc, - loader_tree: Vc, -} - -#[turbo_tasks::value_impl] -impl AppRenderer { - #[turbo_tasks::function] - async fn entry(self: Vc, with_ssr: bool) -> Result> { - let AppRenderer { - runtime_entries, - context_ssr, - context, - project_path, - server_root, - intermediate_output_path, - loader_tree, - } = *self.await?; - - let (context, intermediate_output_path) = if with_ssr { - (context_ssr, intermediate_output_path) - } else { - (context, intermediate_output_path.join("rsc".to_string())) - }; - - let config = parse_segment_config_from_loader_tree(loader_tree, Vc::upcast(context)); - - let runtime = config.await?.runtime; - let rsc_transition = match runtime { - Some(NextRuntime::NodeJs) | None => "next-server-component", - Some(NextRuntime::Edge) => "next-edge-server-component", - }; - - let loader_tree_module = LoaderTreeModule::build( - loader_tree, - context, - ServerComponentTransition::TransitionName(rsc_transition.to_string()), - NextMode::DevServer, - ) - .await?; - - let mut result = RopeBuilder::from( - formatdoc!( - " - \"TURBOPACK {{ chunking-type: isolatedParallel; transition: {rsc_transition} }}\"; - import GlobalErrorMod from \"next/dist/client/components/error-boundary\" - const {{ GlobalError }} = GlobalErrorMod; - \"TURBOPACK {{ chunking-type: isolatedParallel; transition: {rsc_transition} }}\"; - import base from \"next/dist/server/app-render/entry-base\"\n - " - ) - .into_bytes(), - ); - - for import in loader_tree_module.imports { - writeln!(result, "{import}")?; - } - - writeln!( - result, - "const tree = {loader_tree_code};\n", - loader_tree_code = loader_tree_module.loader_tree_code - )?; - writeln!(result, "const pathname = '';\n")?; - writeln!( - result, - // Need this hack because "export *" from CommonJS will trigger a warning - // otherwise - "__turbopack_export_value__({{ tree, GlobalError, pathname, ...base }});\n" - )?; - - let file = File::from(result.build()); - let asset = VirtualSource::new( - next_js_file_path("entry/app-entry.tsx".to_string()), - AssetContent::file(file.into()), - ); - - let chunking_context = DevChunkingContext::builder( - project_path, - intermediate_output_path, - intermediate_output_path.join("chunks".to_string()), - get_client_assets_path(server_root), - context.compile_time_info().environment(), - ) - .layer("ssr") - .reference_chunk_source_maps(should_debug("app_source")) - .build(); - - let renderer_module = match runtime { - Some(NextRuntime::NodeJs) | None => context.process( - Vc::upcast(FileSource::new(next_js_file_path("entry/app-renderer.tsx".to_string()))), - Value::new(ReferenceType::Internal(Vc::cell(indexmap! { - "APP_ENTRY".to_string() => context.with_transition(rsc_transition.to_string()).process( - Vc::upcast(asset), - Value::new(ReferenceType::Internal(Vc::cell(loader_tree_module.inner_assets))), - ), - "APP_BOOTSTRAP".to_string() =>context.with_transition("next-client".to_string()).process( - Vc::upcast(FileSource::new(next_js_file_path("entry/app/hydrate.tsx".to_string()))), - Value::new(ReferenceType::EcmaScriptModules( - EcmaScriptModulesReferenceSubType::Undefined, - )), - ), - }))), - ), - Some(NextRuntime::Edge) => - context.process( - Vc::upcast(FileSource::new(next_js_file_path("entry/app-edge-renderer.tsx".to_string()))), - Value::new(ReferenceType::Internal(Vc::cell(indexmap! { - "INNER_EDGE_CHUNK_GROUP".to_string() => context.with_transition("next-edge-page".to_string()).process( - Vc::upcast(asset), - Value::new(ReferenceType::Internal(Vc::cell(loader_tree_module.inner_assets))), - ), - }))), - ) - }; - - let Some(module) = - Vc::try_resolve_sidecast::>(renderer_module).await? - else { - bail!("internal module must be evaluatable"); - }; - - Ok(NodeRenderingEntry { - runtime_entries: Vc::cell( - runtime_entries - .await? - .iter() - .map(|entry| entry.to_evaluatable(Vc::upcast(context))) - .collect(), - ), - module, - chunking_context: Vc::upcast(chunking_context), - intermediate_output_path, - output_root: intermediate_output_path.root(), - project_dir: project_path, - } - .cell()) - } -} - -#[turbo_tasks::value_impl] -impl NodeEntry for AppRenderer { - #[turbo_tasks::function] - fn entry(self: Vc, data: Value) -> Vc { - let data = data.into_value(); - let with_ssr = if let Some(headers) = data.headers { - !headers.contains_key("rsc") - } else { - true - }; - // Call with only with_ssr as key - self.entry(with_ssr) - } -} - -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, TaskInput, TraceRawVcs)] -pub enum AppRouteEntry { - Path(Vc), - Metadata { - metadata: MetadataItem, - page: AppPage, - }, -} - -/// The node.js renderer api routes in the app directory -#[turbo_tasks::value] -struct AppRoute { - runtime_entries: Vc, - context: Vc, - entry: AppRouteEntry, - mode: NextMode, - intermediate_output_path: Vc, - project_path: Vc, - server_root: Vc, - output_root: Vc, - app_dir: Vc, -} - -#[turbo_tasks::value_impl] -impl AppRoute { - #[turbo_tasks::function] - async fn entry(self: Vc) -> Result> { - let this = self.await?; - - let chunking_context = Vc::upcast( - DevChunkingContext::builder( - this.project_path, - this.intermediate_output_path, - this.intermediate_output_path.join("chunks".to_string()), - get_client_assets_path(this.server_root), - this.context.compile_time_info().environment(), - ) - .layer("ssr") - .reference_chunk_source_maps(should_debug("app_source")) - .build(), - ); - - let entry_file_source = match this.entry { - AppRouteEntry::Path(path) => Vc::upcast(FileSource::new(path)), - AppRouteEntry::Metadata { metadata, ref page } => { - get_app_metadata_route_source(page.clone(), this.mode, metadata) - } - }; - - let entry_asset = this.context.process( - entry_file_source, - Value::new(ReferenceType::Entry(EntryReferenceSubType::AppRoute)), - ); - - let config = parse_segment_config_from_source(entry_asset, entry_file_source); - let module = match config.await?.runtime { - Some(NextRuntime::NodeJs) | None => { - let bootstrap_asset = next_asset("entry/app/route.ts".to_string()); - - let entry_asset = this - .context - .with_transition("next-route".to_string()) - .process( - entry_file_source, - Value::new(ReferenceType::Entry(EntryReferenceSubType::AppRoute)), - ); - - route_bootstrap( - entry_asset, - Vc::upcast(this.context), - this.project_path, - bootstrap_asset, - BootstrapConfig::empty(), - ) - } - Some(NextRuntime::Edge) => { - let internal_asset = next_asset("entry/app/edge-route.ts".to_string()); - - let entry = this - .context - .with_transition("next-edge-route".to_string()) - .process( - entry_file_source, - Value::new(ReferenceType::Entry(EntryReferenceSubType::AppRoute)), - ); - - let module = this.context.process( - internal_asset, - Value::new(ReferenceType::Internal(Vc::cell(indexmap! { - "ROUTE_CHUNK_GROUP".to_string() => entry - }))), - ); - - let Some(module) = - Vc::try_resolve_sidecast::>(module).await? - else { - bail!("internal module must be evaluatable"); - }; - - module - } - }; - - Ok(NodeRenderingEntry { - runtime_entries: Vc::cell( - this.runtime_entries - .await? - .iter() - .map(|entry| entry.to_evaluatable(Vc::upcast(this.context))) - .collect(), - ), - module, - chunking_context, - intermediate_output_path: this.intermediate_output_path, - output_root: this.output_root, - project_dir: this.project_path, - } - .cell()) - } -} - -#[turbo_tasks::value_impl] -impl NodeEntry for AppRoute { - #[turbo_tasks::function] - fn entry(self: Vc, _data: Value) -> Vc { - // Call without being keyed by data - self.entry() - } -} diff --git a/packages/next-swc/crates/next-core/src/dev_manifest.rs b/packages/next-swc/crates/next-core/src/dev_manifest.rs deleted file mode 100644 index 4e1f60312f513..0000000000000 --- a/packages/next-swc/crates/next-core/src/dev_manifest.rs +++ /dev/null @@ -1,255 +0,0 @@ -use anyhow::{bail, Context, Result}; -use indexmap::IndexMap; -use mime::{APPLICATION_JAVASCRIPT_UTF_8, APPLICATION_JSON}; -use serde::Serialize; -use turbo_tasks::{ - graph::{GraphTraversal, NonDeterministic}, - ReadRef, Vc, -}; -use turbopack_binding::{ - turbo::{tasks::TryJoinIterExt, tasks_fs::File}, - turbopack::{ - core::{asset::AssetContent, introspect::Introspectable, version::VersionedContentExt}, - dev_server::source::{ - route_tree::{BaseSegment, RouteTree, RouteTrees, RouteType}, - ContentSource, ContentSourceContent, ContentSourceData, GetContentSourceContent, - }, - node::render::{ - node_api_source::NodeApiContentSource, rendered_source::NodeRenderContentSource, - }, - }, -}; - -use crate::{embed_js::next_js_file, next_config::Rewrites, util::get_asset_path_from_pathname}; - -/// A content source which creates the next.js `_devPagesManifest.json` and -/// `_devMiddlewareManifest.json` which are used for client side navigation. -#[turbo_tasks::value(shared)] -pub struct DevManifestContentSource { - pub page_roots: Vec>>, - pub rewrites: Vc, -} - -#[turbo_tasks::value_impl] -impl DevManifestContentSource { - /// Recursively find all routes in the `page_roots` content sources. - #[turbo_tasks::function] - async fn find_routes(self: Vc) -> Result>> { - let this = &*self.await?; - - async fn content_source_to_pathname( - content_source: Vc>, - ) -> Result>> { - // TODO This shouldn't use casts but an public api instead - if let Some(api_source) = - Vc::try_resolve_downcast_type::(content_source).await? - { - return Ok(Some(api_source.get_pathname().await?)); - } - - if let Some(page_source) = - Vc::try_resolve_downcast_type::(content_source).await? - { - return Ok(Some(page_source.get_pathname().await?)); - } - - Ok(None) - } - - async fn get_content_source_children( - content_source: Vc>, - ) -> Result>>> { - Ok(content_source.get_children().await?.clone_value()) - } - - let routes = NonDeterministic::new() - .visit(this.page_roots.iter().copied(), get_content_source_children) - .await - .completed()? - .into_iter() - .map(content_source_to_pathname) - .try_join() - .await?; - let mut routes = routes - .into_iter() - .flatten() - .map(|route| route.clone_value()) - .collect::>(); - - routes.sort_by_cached_key(|s| s.split('/').map(PageSortKey::from).collect::>()); - routes.dedup(); - - Ok(Vc::cell(routes)) - } - - /// Recursively find all pages in the `page_roots` content sources - /// (excluding api routes). - #[turbo_tasks::function] - async fn find_pages(self: Vc) -> Result>> { - let routes = &*self.find_routes().await?; - - // we don't need to sort as it's already sorted by `find_routes` - let pages = routes - .iter() - .filter(|s| !s.starts_with("/api")) - .cloned() - .collect(); - - Ok(Vc::cell(pages)) - } - - /// Create a build manifest with all pages. - #[turbo_tasks::function] - async fn create_build_manifest(self: Vc) -> Result> { - let this = &*self.await?; - - let sorted_pages = &*self.find_pages().await?; - let routes = sorted_pages - .iter() - .map(|pathname| { - ( - pathname, - vec![format!( - "_next/static/chunks/pages{}", - get_asset_path_from_pathname(pathname, ".js") - )], - ) - }) - .collect(); - - let manifest = BuildManifest { - rewrites: this.rewrites.await?, - sorted_pages, - routes, - }; - - let manifest = next_js_file("entry/manifest/buildManifest.js".to_string()) - .await? - .as_content() - .context("embedded buildManifest file missing")? - .content() - .to_str()? - .replace("$$MANIFEST$$", &serde_json::to_string(&manifest)?); - - Ok(Vc::cell(manifest)) - } -} - -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -struct BuildManifest<'a> { - #[serde(rename = "__rewrites")] - rewrites: ReadRef, - sorted_pages: &'a Vec, - - #[serde(flatten)] - routes: IndexMap<&'a String, Vec>, -} - -const DEV_MANIFEST_PATHNAME: &str = "_next/static/development/_devPagesManifest.json"; -const BUILD_MANIFEST_PATHNAME: &str = "_next/static/development/_buildManifest.js"; -const DEV_MIDDLEWARE_MANIFEST_PATHNAME: &str = - "_next/static/development/_devMiddlewareManifest.json"; - -#[turbo_tasks::value_impl] -impl ContentSource for DevManifestContentSource { - #[turbo_tasks::function] - fn get_routes(self: Vc) -> Vc { - Vc::::cell(vec![ - RouteTree::new_route( - BaseSegment::from_static_pathname(DEV_MANIFEST_PATHNAME).collect(), - RouteType::Exact, - Vc::upcast(self), - ), - RouteTree::new_route( - BaseSegment::from_static_pathname(BUILD_MANIFEST_PATHNAME).collect(), - RouteType::Exact, - Vc::upcast(self), - ), - RouteTree::new_route( - BaseSegment::from_static_pathname(DEV_MIDDLEWARE_MANIFEST_PATHNAME).collect(), - RouteType::Exact, - Vc::upcast(self), - ), - ]) - .merge() - } -} - -#[turbo_tasks::value_impl] -impl GetContentSourceContent for DevManifestContentSource { - #[turbo_tasks::function] - async fn get( - self: Vc, - path: String, - _data: turbo_tasks::Value, - ) -> Result> { - let manifest_file = match path.as_str() { - DEV_MANIFEST_PATHNAME => { - let pages = &*self.find_routes().await?; - - File::from(serde_json::to_string(&serde_json::json!({ - "pages": pages, - }))?) - .with_content_type(APPLICATION_JSON) - } - BUILD_MANIFEST_PATHNAME => { - let build_manifest = &*self.create_build_manifest().await?; - - File::from(build_manifest.as_str()).with_content_type(APPLICATION_JAVASCRIPT_UTF_8) - } - DEV_MIDDLEWARE_MANIFEST_PATHNAME => { - // If there is actual middleware, this request will have been handled by the - // node router in next-core/js/src/entry/router.ts and - // next/src/server/lib/route-resolver.ts. - // If we've reached this point, then there is no middleware and we need to - // respond with an empty `MiddlewareMatcher[]`. - File::from("[]").with_content_type(APPLICATION_JSON) - } - _ => bail!("unknown path: {}", path), - }; - - Ok(ContentSourceContent::static_content( - AssetContent::file(manifest_file.into()).versioned(), - )) - } -} - -#[turbo_tasks::value_impl] -impl Introspectable for DevManifestContentSource { - #[turbo_tasks::function] - fn ty(&self) -> Vc { - Vc::cell("dev manifest source".to_string()) - } - - #[turbo_tasks::function] - fn details(&self) -> Vc { - Vc::cell( - "provides _devPagesManifest.json, _buildManifest.js and _devMiddlewareManifest.json." - .to_string(), - ) - } -} - -/// PageSortKey is necessary because the next.js client code looks for matches -/// in the order the pages are sent in the manifest,if they're sorted -/// alphabetically this means \[slug] and \[\[catchall]] routes are prioritized -/// over fixed paths, so we have to override the ordering with this. -#[derive(Ord, PartialOrd, Eq, PartialEq)] -enum PageSortKey { - Static(String), - Slug, - CatchAll, -} - -impl From<&str> for PageSortKey { - fn from(value: &str) -> Self { - if value.starts_with("[[") && value.ends_with("]]") { - PageSortKey::CatchAll - } else if value.starts_with('[') && value.ends_with(']') { - PageSortKey::Slug - } else { - PageSortKey::Static(value.to_string()) - } - } -} diff --git a/packages/next-swc/crates/next-core/src/lib.rs b/packages/next-swc/crates/next-core/src/lib.rs index 14d6609880298..ae271ff86ac87 100644 --- a/packages/next-swc/crates/next-core/src/lib.rs +++ b/packages/next-swc/crates/next-core/src/lib.rs @@ -8,54 +8,46 @@ mod app_render; mod app_segment_config; -mod app_source; pub mod app_structure; mod babel; mod bootstrap; -pub mod dev_manifest; mod embed_js; mod emit; -pub mod env; +mod env; mod fallback; -pub mod loader_tree; +mod loader_tree; pub mod middleware; pub mod mode; pub mod next_app; mod next_build; pub mod next_client; -pub mod next_client_chunks; mod next_client_component; pub mod next_client_reference; pub mod next_config; pub mod next_dynamic; pub mod next_edge; mod next_font; -pub mod next_image; +mod next_image; mod next_import_map; pub mod next_manifests; pub mod next_pages; mod next_route_matcher; pub mod next_server; -pub mod next_server_component; -pub mod next_shared; +mod next_server_component; +mod next_shared; pub mod next_telemetry; mod page_loader; -mod page_source; pub mod pages_structure; -pub mod router; -pub mod router_source; mod runtime; mod sass; pub mod tracing_presets; mod transform_options; pub mod url_node; pub mod util; -mod web_entry_source; pub use app_segment_config::{ parse_segment_config_from_loader_tree, parse_segment_config_from_source, }; -pub use app_source::create_app_source; pub use emit::{ all_assets_from_entries, all_server_paths, emit_all_assets, emit_assets, emit_client_assets, }; @@ -63,10 +55,8 @@ pub use next_edge::context::{ get_edge_chunking_context, get_edge_compile_time_info, get_edge_resolve_options_context, }; pub use page_loader::{create_page_loader_entry_module, PageLoaderAsset}; -pub use page_source::create_page_source; pub use turbopack_binding::{turbopack::node::source_map, *}; pub use util::{get_asset_path_from_pathname, pathname_for_path, PathType}; -pub use web_entry_source::create_web_entry_source; pub fn register() { turbo_tasks::register(); diff --git a/packages/next-swc/crates/next-core/src/loader_tree.rs b/packages/next-swc/crates/next-core/src/loader_tree.rs index 2aba5241c5d2d..1026bf24c6c16 100644 --- a/packages/next-swc/crates/next-core/src/loader_tree.rs +++ b/packages/next-swc/crates/next-core/src/loader_tree.rs @@ -37,16 +37,10 @@ pub struct LoaderTreeBuilder { loader_tree_code: String, context: Vc, mode: NextMode, - server_component_transition: ServerComponentTransition, + server_component_transition: Vc>, pages: Vec>, } -#[derive(Clone, Debug)] -pub enum ServerComponentTransition { - Transition(Vc>), - TransitionName(String), -} - #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum ComponentType { Page, @@ -75,7 +69,7 @@ impl ComponentType { impl LoaderTreeBuilder { fn new( context: Vc, - server_component_transition: ServerComponentTransition, + server_component_transition: Vc>, mode: NextMode, ) -> Self { LoaderTreeBuilder { @@ -153,15 +147,9 @@ impl LoaderTreeBuilder { EcmaScriptModulesReferenceSubType::Undefined, )); - let module = match &self.server_component_transition { - ServerComponentTransition::Transition(transition) => { - transition.process(source, self.context, reference_ty) - } - ServerComponentTransition::TransitionName(transition_name) => self - .context - .with_transition(transition_name.clone()) - .process(source, reference_ty), - }; + let module = + self.server_component_transition + .process(source, self.context, reference_ty); self.inner_assets.insert(format!("COMPONENT_{i}"), module); } @@ -434,7 +422,7 @@ impl LoaderTreeModule { pub async fn build( loader_tree: Vc, context: Vc, - server_component_transition: ServerComponentTransition, + server_component_transition: Vc>, mode: NextMode, ) -> Result { LoaderTreeBuilder::new(context, server_component_transition, mode) diff --git a/packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs b/packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs index a20c5f84f3db5..73982bb4c2805 100644 --- a/packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs +++ b/packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs @@ -17,7 +17,7 @@ use turbopack_binding::{ use super::app_entry::AppEntry; use crate::{ app_structure::LoaderTree, - loader_tree::{LoaderTreeModule, ServerComponentTransition}, + loader_tree::LoaderTreeModule, mode::NextMode, next_app::{AppPage, AppPath}, next_server_component::NextServerComponentTransition, @@ -47,7 +47,7 @@ pub async fn get_app_page_entry( let loader_tree = LoaderTreeModule::build( loader_tree, context, - ServerComponentTransition::Transition(server_component_transition), + server_component_transition, NextMode::Build, ) .await?; diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/client_chunks_transition.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/client_chunks_transition.rs deleted file mode 100644 index 54369d887374c..0000000000000 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/client_chunks_transition.rs +++ /dev/null @@ -1,115 +0,0 @@ -use anyhow::Result; -use turbo_tasks::{Value, Vc}; -use turbopack_binding::{ - turbo::tasks_fs::FileSystemPath, - turbopack::{ - core::{compile_time_info::CompileTimeInfo, module::Module}, - ecmascript::chunk::EcmascriptChunkingContext, - node::execution_context::ExecutionContext, - turbopack::{ - ecmascript::chunk::EcmascriptChunkPlaceable, module_options::ModuleOptionsContext, - resolve_options_context::ResolveOptionsContext, transition::Transition, - ModuleAssetContext, - }, - }, -}; - -use super::with_chunks::WithChunksAsset; -use crate::{ - mode::NextMode, - next_client::context::{ - get_client_module_options_context, get_client_resolve_options_context, ClientContextType, - }, - next_config::NextConfig, -}; - -#[turbo_tasks::value(shared)] -pub struct NextClientChunksTransition { - pub client_compile_time_info: Vc, - pub client_module_options_context: Vc, - pub client_resolve_options_context: Vc, - pub client_chunking_context: Vc>, -} - -#[turbo_tasks::value_impl] -impl NextClientChunksTransition { - #[turbo_tasks::function] - pub fn new( - project_path: Vc, - execution_context: Vc, - ty: Value, - mode: NextMode, - client_chunking_context: Vc>, - client_compile_time_info: Vc, - next_config: Vc, - ) -> Vc { - let client_module_options_context = get_client_module_options_context( - project_path, - execution_context, - client_compile_time_info.environment(), - ty, - mode, - next_config, - ); - NextClientChunksTransition { - client_chunking_context, - client_module_options_context, - client_resolve_options_context: get_client_resolve_options_context( - project_path, - ty, - mode, - next_config, - execution_context, - ), - client_compile_time_info, - } - .cell() - } -} - -#[turbo_tasks::value_impl] -impl Transition for NextClientChunksTransition { - #[turbo_tasks::function] - fn process_compile_time_info( - &self, - _compile_time_info: Vc, - ) -> Vc { - self.client_compile_time_info - } - - #[turbo_tasks::function] - fn process_module_options_context( - &self, - _context: Vc, - ) -> Vc { - self.client_module_options_context - } - - #[turbo_tasks::function] - fn process_resolve_options_context( - &self, - _context: Vc, - ) -> Vc { - self.client_resolve_options_context - } - - #[turbo_tasks::function] - async fn process_module( - &self, - asset: Vc>, - _context: Vc, - ) -> Result>> { - Ok( - if let Some(placeable) = - Vc::try_resolve_sidecast::>(asset).await? - { - Vc::upcast(WithChunksAsset::new( - placeable, - self.client_chunking_context, - )) - } else { - asset - }, - ) - } -} diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs deleted file mode 100644 index 380f26b1481e5..0000000000000 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/in_chunking_context_asset.rs +++ /dev/null @@ -1,85 +0,0 @@ -use anyhow::{bail, Result}; -use turbo_tasks::{Value, Vc}; -use turbopack_binding::turbopack::{ - core::{ - asset::{Asset, AssetContent}, - chunk::{availability_info::AvailabilityInfo, Chunk, ChunkableModule, ChunkingContext}, - ident::AssetIdent, - module::Module, - reference::ModuleReferences, - }, - ecmascript::chunk::EcmascriptChunkingContext, - turbopack::ecmascript::chunk::{ - EcmascriptChunk, EcmascriptChunkItem, EcmascriptChunkPlaceable, EcmascriptExports, - }, -}; - -#[turbo_tasks::function] -fn modifier() -> Vc { - Vc::cell("in chunking context".to_string()) -} - -#[turbo_tasks::value(shared)] -pub struct InChunkingContextAsset { - pub asset: Vc>, - pub chunking_context: Vc>, -} - -#[turbo_tasks::value_impl] -impl Module for InChunkingContextAsset { - #[turbo_tasks::function] - fn ident(&self) -> Vc { - self.asset.ident().with_modifier(modifier()) - } - - #[turbo_tasks::function] - fn references(&self) -> Vc { - self.asset.references() - } -} - -#[turbo_tasks::value_impl] -impl Asset for InChunkingContextAsset { - #[turbo_tasks::function] - fn content(&self) -> Vc { - self.asset.content() - } -} - -#[turbo_tasks::value_impl] -impl ChunkableModule for InChunkingContextAsset { - #[turbo_tasks::function] - fn as_chunk( - &self, - _context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - self.chunking_context, - self.asset, - availability_info, - )) - } -} - -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceable for InChunkingContextAsset { - #[turbo_tasks::function] - async fn as_chunk_item( - &self, - _context: Vc>, - ) -> Result>> { - let Some(chunking_context) = - Vc::try_resolve_sidecast::>(self.chunking_context) - .await? - else { - bail!("chunking context is not an EcmascriptChunkingContext") - }; - Ok(self.asset.as_chunk_item(chunking_context)) - } - - #[turbo_tasks::function] - fn get_exports(&self) -> Vc { - self.asset.get_exports() - } -} diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/mod.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/mod.rs deleted file mode 100644 index 4504cf7fe8120..0000000000000 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub(crate) mod client_chunks_transition; -pub(crate) mod in_chunking_context_asset; -pub(crate) mod with_chunks; - -pub use client_chunks_transition::NextClientChunksTransition; diff --git a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs deleted file mode 100644 index d68cef31f0bba..0000000000000 --- a/packages/next-swc/crates/next-core/src/next_client_chunks/with_chunks.rs +++ /dev/null @@ -1,233 +0,0 @@ -use std::io::Write; - -use anyhow::Result; -use indoc::writedoc; -use turbo_tasks::Vc; -use turbopack_binding::{ - turbo::{ - tasks::{TryJoinIterExt, Value}, - tasks_fs::rope::RopeBuilder, - }, - turbopack::{ - core::{ - asset::{Asset, AssetContent}, - chunk::{ - availability_info::AvailabilityInfo, Chunk, ChunkData, ChunkGroupReference, - ChunkItem, ChunkableModule, ChunkingContext, ChunksData, - }, - ident::AssetIdent, - module::Module, - output::OutputAssets, - reference::{ModuleReferences, SingleOutputAssetReference}, - }, - ecmascript::{ - chunk::{ - EcmascriptChunk, EcmascriptChunkData, EcmascriptChunkItem, - EcmascriptChunkItemContent, EcmascriptChunkItemExt, EcmascriptChunkPlaceable, - EcmascriptChunkingContext, EcmascriptExports, - }, - utils::StringifyJs, - }, - }, -}; - -#[turbo_tasks::function] -fn modifier() -> Vc { - Vc::cell("chunks".to_string()) -} - -#[turbo_tasks::value] -pub struct WithChunksAsset { - asset: Vc>, - chunking_context: Vc>, -} - -#[turbo_tasks::value_impl] -impl WithChunksAsset { - /// Create a new [`WithChunksAsset`]. - /// - /// # Arguments - /// - /// * `asset` - The asset to wrap. - /// * `chunking_context` - The chunking context of the asset. - #[turbo_tasks::function] - pub fn new( - asset: Vc>, - chunking_context: Vc>, - ) -> Vc { - WithChunksAsset::cell(WithChunksAsset { - asset, - chunking_context, - }) - } - - #[turbo_tasks::function] - async fn entry_chunk(self: Vc) -> Result>> { - let this = self.await?; - Ok(this.asset.as_root_chunk(Vc::upcast(this.chunking_context))) - } - - #[turbo_tasks::function] - async fn chunks(self: Vc) -> Result> { - let this = self.await?; - Ok(this.chunking_context.chunk_group(self.entry_chunk())) - } -} - -#[turbo_tasks::value_impl] -impl Module for WithChunksAsset { - #[turbo_tasks::function] - fn ident(&self) -> Vc { - self.asset.ident().with_modifier(modifier()) - } - - #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { - let this = self.await?; - let entry_chunk = self.entry_chunk(); - - Ok(Vc::cell(vec![Vc::upcast(ChunkGroupReference::new( - Vc::upcast(this.chunking_context), - entry_chunk, - ))])) - } -} - -#[turbo_tasks::value_impl] -impl Asset for WithChunksAsset { - #[turbo_tasks::function] - fn content(&self) -> Vc { - unimplemented!() - } -} - -#[turbo_tasks::value_impl] -impl ChunkableModule for WithChunksAsset { - #[turbo_tasks::function] - fn as_chunk( - self: Vc, - context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - context, - Vc::upcast(self), - availability_info, - )) - } -} - -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceable for WithChunksAsset { - #[turbo_tasks::function] - async fn as_chunk_item( - self: Vc, - context: Vc>, - ) -> Result>> { - Ok(Vc::upcast( - WithChunksChunkItem { - context, - inner: self, - } - .cell(), - )) - } - - #[turbo_tasks::function] - fn get_exports(&self) -> Vc { - // TODO This should be EsmExports - EcmascriptExports::Value.cell() - } -} - -#[turbo_tasks::value] -struct WithChunksChunkItem { - context: Vc>, - inner: Vc, -} - -#[turbo_tasks::value_impl] -impl WithChunksChunkItem { - #[turbo_tasks::function] - async fn chunks_data(self: Vc) -> Result> { - let this = self.await?; - let inner = this.inner.await?; - Ok(ChunkData::from_assets( - inner.chunking_context.output_root(), - this.inner.chunks(), - )) - } -} - -#[turbo_tasks::value_impl] -impl EcmascriptChunkItem for WithChunksChunkItem { - #[turbo_tasks::function] - fn chunking_context(&self) -> Vc> { - self.context - } - - #[turbo_tasks::function] - async fn content(self: Vc) -> Result> { - let this = self.await?; - let inner = this.inner.await?; - - let chunks_data = self.chunks_data().await?; - let chunks_data = chunks_data.iter().try_join().await?; - let chunks_data: Vec<_> = chunks_data - .iter() - .map(|chunk_data| EcmascriptChunkData::new(chunk_data)) - .collect(); - - let module_id = &*inner - .asset - .as_chunk_item(inner.chunking_context) - .id() - .await?; - - let mut code = RopeBuilder::default(); - - writedoc!( - code, - r#" - __turbopack_esm__({{ - default: () => {}, - chunks: () => chunks, - }}); - const chunks = {:#}; - "#, - StringifyJs(&module_id), - StringifyJs(&chunks_data), - )?; - - Ok(EcmascriptChunkItemContent { - inner_code: code.build(), - ..Default::default() - } - .cell()) - } -} - -#[turbo_tasks::value_impl] -impl ChunkItem for WithChunksChunkItem { - #[turbo_tasks::function] - fn asset_ident(&self) -> Vc { - self.inner.ident() - } - - #[turbo_tasks::function] - async fn references(self: Vc) -> Result> { - let mut references = self.await?.inner.references().await?.clone_value(); - - let chunk_data_key = Vc::cell("chunk data".to_string()); - for chunk_data in &*self.chunks_data().await? { - references.extend(chunk_data.references().await?.iter().map(|&output_asset| { - Vc::upcast(SingleOutputAssetReference::new( - output_asset, - chunk_data_key, - )) - })); - } - - Ok(Vc::cell(references)) - } -} diff --git a/packages/next-swc/crates/next-core/src/page_source.rs b/packages/next-swc/crates/next-core/src/page_source.rs deleted file mode 100644 index 084d13bf2c6f3..0000000000000 --- a/packages/next-swc/crates/next-core/src/page_source.rs +++ /dev/null @@ -1,895 +0,0 @@ -use anyhow::{bail, Result}; -use indexmap::{indexmap, IndexMap}; -use serde::{Deserialize, Serialize}; -use serde_json::Value as JsonValue; -use turbo_tasks::{trace::TraceRawVcs, Value, Vc}; -use turbo_tasks_fs::FileSystemPathOption; -use turbopack_binding::{ - turbo::{ - tasks_env::{CustomProcessEnv, EnvMap, ProcessEnv}, - tasks_fs::{FileContent, FileSystemPath}, - }, - turbopack::{ - core::{ - chunk::{ChunkingContext, EvaluatableAsset, EvaluatableAssetExt}, - compile_time_info::CompileTimeInfo, - context::AssetContext, - environment::ServerAddr, - file_source::FileSource, - module::Module, - reference_type::{EntryReferenceSubType, ReferenceType}, - source::{Source, Sources}, - }, - dev::DevChunkingContext, - dev_server::{ - html::DevHtmlAsset, - source::{ - asset_graph::AssetGraphContentSource, - combined::CombinedContentSource, - route_tree::{BaseSegment, RouteType}, - ContentSource, ContentSourceData, ContentSourceExt, - }, - }, - ecmascript::chunk::EcmascriptChunkingContext, - env::ProcessEnvAsset, - node::{ - debug::should_debug, - execution_context::ExecutionContext, - render::{ - node_api_source::create_node_api_source, - rendered_source::create_node_rendered_source, - }, - route_matcher::RouteMatcher, - NodeEntry, NodeRenderingEntry, - }, - turbopack::ModuleAssetContext, - }, -}; - -use crate::{ - embed_js::next_asset, - env::env_for_js, - fallback::get_fallback_page, - mode::NextMode, - next_client::{ - context::{ - get_client_assets_path, get_client_chunking_context, get_client_module_options_context, - get_client_resolve_options_context, get_client_runtime_entries, ClientContextType, - }, - transition::NextClientTransition, - }, - next_client_chunks::client_chunks_transition::NextClientChunksTransition, - next_config::NextConfig, - next_edge::{ - context::{get_edge_compile_time_info, get_edge_resolve_options_context}, - route_transition::NextEdgeRouteTransition, - }, - next_route_matcher::{ - NextExactMatcher, NextFallbackMatcher, NextParamsMatcher, NextPrefixSuffixParamsMatcher, - }, - next_server::context::{ - get_server_compile_time_info, get_server_module_options_context, - get_server_resolve_options_context, ServerContextType, - }, - page_loader::create_page_loader, - pages_structure::{PagesDirectoryStructure, PagesStructure, PagesStructureItem}, - util::{parse_config_from_source, pathname_for_path, render_data, NextRuntime, PathType}, -}; - -/// Create a content source serving the `pages` or `src/pages` directory as -/// Next.js pages folder. -#[turbo_tasks::function] -pub async fn create_page_source( - pages_structure: Vc, - project_root: Vc, - dist_root: Vc, - execution_context: Vc, - node_root: Vc, - client_root: Vc, - env: Vc>, - client_chunking_context: Vc>, - client_compile_time_info: Vc, - next_config: Vc, - server_addr: Vc, -) -> Result>> { - let pages_dir = if let Some(pages) = pages_structure.await?.pages { - pages.project_path().resolve().await? - } else { - project_root.join("pages".to_string()) - }; - - let mode = NextMode::DevServer; - let client_ty = Value::new(ClientContextType::Pages { pages_dir }); - let server_ty = Value::new(ServerContextType::Pages { pages_dir }); - let server_data_ty = Value::new(ServerContextType::PagesData { pages_dir }); - - let client_module_options_context = get_client_module_options_context( - project_root, - execution_context, - client_compile_time_info.environment(), - client_ty, - mode, - next_config, - ); - let client_resolve_options_context = get_client_resolve_options_context( - project_root, - client_ty, - mode, - next_config, - execution_context, - ); - - let client_runtime_entries = get_client_runtime_entries( - project_root, - env, - client_ty, - mode, - next_config, - execution_context, - ); - - let next_client_transition = Vc::upcast( - NextClientTransition { - is_app: false, - client_chunking_context: Vc::upcast(client_chunking_context), - client_module_options_context, - client_resolve_options_context, - client_compile_time_info, - runtime_entries: client_runtime_entries, - } - .cell(), - ); - - let edge_compile_time_info = get_edge_compile_time_info(project_root, server_addr, dist_root); - - let edge_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_root, - node_root.join("edge".to_string()), - node_root.join("edge/chunks".to_string()), - get_client_assets_path(client_root), - edge_compile_time_info.environment(), - ) - .reference_chunk_source_maps(should_debug("page_source")) - .build(), - ); - let edge_resolve_options_context = get_edge_resolve_options_context( - project_root, - server_ty, - mode, - next_config, - execution_context, - ); - - let next_edge_transition = Vc::upcast( - NextEdgeRouteTransition { - edge_compile_time_info, - edge_chunking_context, - edge_module_options_context: None, - edge_resolve_options_context, - output_path: node_root, - base_path: project_root, - bootstrap_asset: next_asset("entry/edge-bootstrap.ts".to_string()), - entry_name: "edge".to_string(), - } - .cell(), - ); - - let server_compile_time_info = get_server_compile_time_info(mode, env, server_addr); - let server_resolve_options_context = get_server_resolve_options_context( - project_root, - server_ty, - mode, - next_config, - execution_context, - ); - - let server_module_options_context = get_server_module_options_context( - project_root, - execution_context, - server_ty, - mode, - next_config, - ); - - let server_data_module_options_context = get_server_module_options_context( - project_root, - execution_context, - server_data_ty, - mode, - next_config, - ); - - let transitions = Vc::cell( - [ - ("next-edge".to_string(), next_edge_transition), - ("next-client".to_string(), next_client_transition), - ( - "next-client-chunks".to_string(), - Vc::upcast(NextClientChunksTransition::new( - project_root, - execution_context, - client_ty, - mode, - client_chunking_context, - client_compile_time_info, - next_config, - )), - ), - ] - .into_iter() - .collect(), - ); - - let client_context: Vc> = Vc::upcast(ModuleAssetContext::new( - transitions, - client_compile_time_info, - client_module_options_context, - client_resolve_options_context, - )); - let server_context: Vc> = Vc::upcast(ModuleAssetContext::new( - transitions, - server_compile_time_info, - server_module_options_context, - server_resolve_options_context, - )); - let server_data_context: Vc> = Vc::upcast(ModuleAssetContext::new( - transitions, - server_compile_time_info, - server_data_module_options_context, - server_resolve_options_context, - )); - - let injected_env = env_for_js(Vc::upcast(EnvMap::empty()), false, next_config); - let env = Vc::upcast(CustomProcessEnv::new(env, next_config.env())); - - let server_runtime_entries = Vc::cell(vec![Vc::upcast(ProcessEnvAsset::new( - project_root, - injected_env, - ))]); - let fallback_runtime_entries = Vc::cell(vec![]); - - let fallback_page = get_fallback_page( - project_root, - execution_context, - client_root, - env, - client_compile_time_info, - next_config, - ); - - let render_data = render_data(next_config, server_addr); - let page_extensions = next_config.page_extensions(); - - let sources = vec![ - // Match _next/404 first to ensure rewrites work properly. - create_not_found_page_source( - project_root, - env, - server_context, - client_context, - Vc::upcast(client_chunking_context), - pages_dir, - page_extensions, - fallback_runtime_entries, - fallback_page, - client_root, - node_root.join("force_not_found".to_string()), - BaseSegment::from_static_pathname("_next/404").collect(), - RouteType::Exact, - Vc::upcast(NextExactMatcher::new(Vc::cell("_next/404".to_string()))), - render_data, - ) - .issue_file_path(pages_dir, "Next.js pages directory not found".to_string()), - create_page_source_for_root_directory( - pages_structure, - project_root, - env, - server_context, - server_data_context, - client_context, - pages_dir, - server_runtime_entries, - fallback_page, - client_root, - node_root, - render_data, - ), - Vc::upcast::>(AssetGraphContentSource::new_eager( - client_root, - Vc::upcast(fallback_page), - )) - .issue_file_path(pages_dir, "Next.js pages directory fallback".to_string()), - create_not_found_page_source( - project_root, - env, - server_context, - client_context, - Vc::upcast(client_chunking_context), - pages_dir, - page_extensions, - fallback_runtime_entries, - fallback_page, - client_root, - node_root.join("fallback_not_found".to_string()), - Vec::new(), - RouteType::NotFound, - Vc::upcast(NextFallbackMatcher::new()), - render_data, - ) - .issue_file_path( - pages_dir, - "Next.js pages directory not found fallback".to_string(), - ), - ]; - - let source = Vc::upcast(CombinedContentSource { sources }.cell()); - Ok(source) -} - -/// Handles a single page file in the pages directory -#[turbo_tasks::function] -async fn create_page_source_for_file( - project_path: Vc, - env: Vc>, - server_context: Vc>, - server_data_context: Vc>, - client_context: Vc>, - _pages_dir: Vc, - page_asset: Vc>, - runtime_entries: Vc, - fallback_page: Vc, - client_root: Vc, - client_path: Vc, - is_api_path: bool, - node_path: Vc, - node_root: Vc, - render_data: Vc, -) -> Result>> { - let mode = NextMode::DevServer; - - let server_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - node_path, - node_path.join("chunks".to_string()), - get_client_assets_path(client_root), - server_context.compile_time_info().environment(), - ) - .reference_chunk_source_maps(should_debug("page_source")) - .build(), - ); - - let data_node_path = node_path.join("data".to_string()); - - let server_data_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - data_node_path, - data_node_path.join("chunks".to_string()), - get_client_assets_path(client_root), - server_context.compile_time_info().environment(), - ) - .reference_chunk_source_maps(should_debug("page_source")) - .build(), - ); - - let client_chunking_context = get_client_chunking_context( - project_path, - client_root, - client_context.compile_time_info().environment(), - mode, - ); - - let pathname = pathname_for_path(client_root, client_path, PathType::PagesPage); - let route_matcher = NextParamsMatcher::new(pathname); - - let (base_segments, route_type) = pathname_to_segments(&pathname.await?, "")?; - - Ok(if is_api_path { - create_node_api_source( - project_path, - env, - base_segments, - route_type, - client_root, - Vc::upcast(route_matcher), - pathname, - Vc::upcast( - SsrEntry { - runtime_entries, - context: server_context, - entry_asset: page_asset, - ty: SsrType::AutoApi, - chunking_context: server_chunking_context, - node_path, - node_root, - project_path, - } - .cell(), - ), - render_data, - should_debug("page_source"), - ) - } else { - let data_pathname = pathname_for_path(client_root, client_path, PathType::Data); - let data_route_matcher = NextPrefixSuffixParamsMatcher::new( - data_pathname, - "_next/data/development/".to_string(), - ".json".to_string(), - ); - let (data_base_segments, data_route_type) = pathname_to_segments( - &format!("_next/data/development/{}", data_pathname.await?), - ".json", - )?; - - let ssr_entry = Vc::upcast( - SsrEntry { - runtime_entries, - context: server_context, - entry_asset: page_asset, - ty: SsrType::Html, - chunking_context: server_chunking_context, - node_path, - node_root, - project_path, - } - .cell(), - ); - - let ssr_data_entry = Vc::upcast( - SsrEntry { - runtime_entries, - context: server_data_context, - entry_asset: page_asset, - ty: SsrType::Data, - chunking_context: server_data_chunking_context, - node_path: data_node_path, - node_root, - project_path, - } - .cell(), - ); - - Vc::upcast(CombinedContentSource::new(vec![ - create_node_rendered_source( - project_path, - env, - base_segments.clone(), - route_type.clone(), - client_root, - Vc::upcast(route_matcher), - pathname, - ssr_entry, - fallback_page, - render_data, - should_debug("page_source"), - ), - create_node_rendered_source( - project_path, - env, - data_base_segments, - data_route_type, - client_root, - Vc::upcast(data_route_matcher), - pathname, - ssr_data_entry, - fallback_page, - render_data, - should_debug("page_source"), - ), - create_page_loader( - client_root, - client_context, - Vc::upcast(client_chunking_context), - page_asset, - pathname, - FileSystemPathOption::none(), - ), - ])) - }) -} - -async fn get_not_found_page( - pages_dir: Vc, - page_extensions: Vc>, -) -> Result>>> { - for ext in page_extensions.await?.iter() { - let not_found_path = pages_dir.join(format!("404.{ext}")); - let content = not_found_path.read(); - if let FileContent::Content(_) = &*content.await? { - return Ok(Some(Vc::upcast(FileSource::new(not_found_path)))); - } - } - Ok(None) -} - -/// Handles a single page file in the pages directory -#[turbo_tasks::function] -async fn create_not_found_page_source( - project_path: Vc, - env: Vc>, - server_context: Vc>, - client_context: Vc>, - client_chunking_context: Vc>, - pages_dir: Vc, - page_extensions: Vc>, - runtime_entries: Vc, - fallback_page: Vc, - client_root: Vc, - node_path: Vc, - base_segments: Vec, - route_type: RouteType, - route_matcher: Vc>, - render_data: Vc, -) -> Result>> { - let server_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - node_path, - node_path.join("chunks".to_string()), - get_client_assets_path(client_root), - server_context.compile_time_info().environment(), - ) - .reference_chunk_source_maps(should_debug("page_source")) - .build(), - ); - - let (page_asset, pathname) = - if let Some(not_found_page_asset) = get_not_found_page(pages_dir, page_extensions).await? { - // If a 404 page is defined, the pathname should be 404. - (not_found_page_asset, Vc::cell("/404".to_string())) - } else { - ( - // The error page asset must be within the context path so it can depend on the - // Next.js module. - next_asset("entry/error.tsx".to_string()), - // If no 404 page is defined, the pathname should be _error. - Vc::cell("/_error".to_string()), - ) - }; - - let ssr_entry = Vc::upcast( - SsrEntry { - runtime_entries, - context: server_context, - entry_asset: page_asset, - ty: SsrType::Html, - chunking_context: server_chunking_context, - node_path, - node_root: node_path, - project_path, - } - .cell(), - ); - - let page_loader = create_page_loader( - client_root, - client_context, - client_chunking_context, - page_asset, - pathname, - FileSystemPathOption::none(), - ); - - Ok(Vc::upcast(CombinedContentSource::new(vec![ - create_node_rendered_source( - project_path, - env, - base_segments, - route_type, - client_root, - route_matcher, - pathname, - ssr_entry, - fallback_page, - render_data, - should_debug("page_source"), - ), - page_loader, - ]))) -} - -/// Handles a directory in the pages directory (or the pages directory itself). -/// Calls itself recursively for sub directories or the -/// [create_page_source_for_file] method for files. -#[turbo_tasks::function] -async fn create_page_source_for_root_directory( - pages_structure: Vc, - project_root: Vc, - env: Vc>, - server_context: Vc>, - server_data_context: Vc>, - client_context: Vc>, - pages_dir: Vc, - runtime_entries: Vc, - fallback_page: Vc, - client_root: Vc, - node_root: Vc, - render_data: Vc, -) -> Result>> { - let PagesStructure { - app: _, - document: _, - error: _, - ref api, - ref pages, - } = *pages_structure.await?; - let mut sources = vec![]; - - if let Some(pages) = pages { - sources.push(create_page_source_for_directory( - *pages, - project_root, - env, - server_context, - server_data_context, - client_context, - pages_dir, - runtime_entries, - fallback_page, - client_root, - false, - node_root, - render_data, - )); - } - - if let Some(api) = api { - sources.push(create_page_source_for_directory( - *api, - project_root, - env, - server_context, - server_data_context, - client_context, - pages_dir, - runtime_entries, - fallback_page, - client_root, - true, - node_root, - render_data, - )); - } - - Ok(Vc::upcast(CombinedContentSource { sources }.cell())) -} - -/// Handles a directory in the pages directory (or the pages directory itself). -/// Calls itself recursively for sub directories or the -/// [create_page_source_for_file] method for files. -#[turbo_tasks::function] -async fn create_page_source_for_directory( - pages_structure: Vc, - project_root: Vc, - env: Vc>, - server_context: Vc>, - server_data_context: Vc>, - client_context: Vc>, - pages_dir: Vc, - runtime_entries: Vc, - fallback_page: Vc, - client_root: Vc, - is_api_path: bool, - node_root: Vc, - render_data: Vc, -) -> Result>> { - let PagesDirectoryStructure { - ref items, - ref children, - .. - } = *pages_structure.await?; - let mut sources = vec![]; - - for item in items.iter() { - let PagesStructureItem { - project_path, - next_router_path, - original_path: _, - } = *item.await?; - let source = create_page_source_for_file( - project_root, - env, - server_context, - server_data_context, - client_context, - pages_dir, - Vc::upcast(FileSource::new(project_path)), - runtime_entries, - fallback_page, - client_root, - next_router_path, - is_api_path, - node_root, - node_root, - render_data, - ) - .issue_file_path( - project_path, - if is_api_path { - "Next.js page API file" - } else { - "Next.js page file" - } - .to_string(), - ); - sources.push(source); - } - - for child in children.iter() { - sources.push(create_page_source_for_directory( - *child, - project_root, - env, - server_context, - server_data_context, - client_context, - pages_dir, - runtime_entries, - fallback_page, - client_root, - is_api_path, - node_root, - render_data, - )) - } - - Ok(Vc::upcast(CombinedContentSource { sources }.cell())) -} - -fn pathname_to_segments(pathname: &str, extension: &str) -> Result<(Vec, RouteType)> { - let mut segments = Vec::new(); - let mut split = pathname.split('/'); - while let Some(segment) = split.next() { - if segment.is_empty() { - // ignore - } else if segment.starts_with("[[...") && segment.ends_with("]]") - || segment.starts_with("[...") && segment.ends_with(']') - { - // (optional) catch all segment - if split.remainder().is_some() { - bail!( - "Invalid route {}, catch all segment must be the last segment", - pathname - ) - } - return Ok((segments, RouteType::CatchAll)); - } else if segment.starts_with('[') || segment.ends_with(']') { - // dynamic segment - segments.push(BaseSegment::Dynamic); - } else { - // normal segment - segments.push(BaseSegment::Static(segment.to_string())); - } - } - if let Some(BaseSegment::Static(s)) = segments.last_mut() { - s.push_str(extension); - } - Ok((segments, RouteType::Exact)) -} - -/// The node.js renderer for SSR of pages. -#[turbo_tasks::value] -pub struct SsrEntry { - runtime_entries: Vc, - context: Vc>, - entry_asset: Vc>, - ty: SsrType, - chunking_context: Vc>, - node_path: Vc, - node_root: Vc, - project_path: Vc, -} - -#[derive( - Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord, TraceRawVcs, -)] -pub enum SsrType { - Api, - EdgeApi, - AutoApi, - Html, - Data, -} - -#[turbo_tasks::value_impl] -impl SsrEntry { - #[turbo_tasks::function] - pub async fn entry(self: Vc) -> Result> { - let this = self.await?; - let entry_asset_page = this.context.process( - this.entry_asset, - Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)), - ); - let ty = if this.ty == SsrType::AutoApi { - let page_config = parse_config_from_source(entry_asset_page); - if page_config.await?.runtime == NextRuntime::Edge { - SsrType::EdgeApi - } else { - SsrType::Api - } - } else { - this.ty - }; - let (internal_asset, inner_assets): (_, IndexMap<_, Vc>>) = match ty { - SsrType::AutoApi => unreachable!(), - SsrType::Api => ( - next_asset("entry/server-api.tsx".to_string()), - indexmap! { - "INNER".to_string() => entry_asset_page, - }, - ), - SsrType::EdgeApi => { - let entry_asset_edge_chunk_group = this - .context - .with_transition("next-edge".to_string()) - .process( - this.entry_asset, - Value::new(ReferenceType::Entry(EntryReferenceSubType::PagesApi)), - ); - ( - next_asset("entry/server-edge-api.tsx".to_string()), - indexmap! { - "INNER_EDGE_CHUNK_GROUP".to_string() => entry_asset_edge_chunk_group, - }, - ) - } - SsrType::Data => ( - next_asset("entry/server-data.tsx".to_string()), - indexmap! { - "INNER".to_string() => entry_asset_page, - }, - ), - SsrType::Html => { - let entry_asset_client_chunk_group = this - .context - .with_transition("next-client".to_string()) - .process( - this.entry_asset, - Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)), - ); - ( - next_asset("entry/server-renderer.tsx".to_string()), - indexmap! { - "INNER".to_string() => entry_asset_page, - "INNER_CLIENT_CHUNK_GROUP".to_string() => entry_asset_client_chunk_group, - }, - ) - } - }; - - let module = this.context.process( - internal_asset, - Value::new(ReferenceType::Internal(Vc::cell(inner_assets))), - ); - let Some(module) = Vc::try_resolve_sidecast::>(module).await? - else { - bail!("internal module must be evaluatable"); - }; - Ok(NodeRenderingEntry { - runtime_entries: Vc::cell( - this.runtime_entries - .await? - .iter() - .map(|entry| entry.to_evaluatable(this.context)) - .collect(), - ), - module, - chunking_context: this.chunking_context, - intermediate_output_path: this.node_path, - output_root: this.node_root, - project_dir: this.project_path, - } - .cell()) - } -} - -#[turbo_tasks::value_impl] -impl NodeEntry for SsrEntry { - #[turbo_tasks::function] - fn entry(self: Vc, _data: Value) -> Vc { - // Call without being keyed by data - self.entry() - } -} diff --git a/packages/next-swc/crates/next-core/src/router.rs b/packages/next-swc/crates/next-core/src/router.rs deleted file mode 100644 index 7c89a4481d888..0000000000000 --- a/packages/next-swc/crates/next-core/src/router.rs +++ /dev/null @@ -1,468 +0,0 @@ -use anyhow::{anyhow, bail, Context, Result}; -use futures::StreamExt; -use indexmap::indexmap; -use serde::Deserialize; -use serde_json::json; -use turbo_tasks::{util::SharedError, Completion, Completions, Value, Vc}; -use turbo_tasks_fs::json::parse_json_with_source_context; -use turbopack_binding::{ - turbo::{ - tasks_bytes::{Bytes, Stream}, - tasks_fs::{to_sys_path, File, FileSystemPath}, - }, - turbopack::{ - core::{ - asset::AssetContent, - changed::any_content_changed_of_module, - chunk::ChunkingContext, - context::AssetContext, - environment::{ServerAddr, ServerInfo}, - file_source::FileSource, - ident::AssetIdent, - issue::IssueDescriptionExt, - module::Module, - reference_type::{EcmaScriptModulesReferenceSubType, InnerAssets, ReferenceType}, - resolve::{find_context_file, FindContextFileResult}, - virtual_source::VirtualSource, - }, - dev::DevChunkingContext, - node::{ - debug::should_debug, - evaluate::{evaluate, get_evaluate_pool}, - execution_context::ExecutionContext, - source_map::{trace_stack_with_source_mapping_assets, StructuredError}, - }, - turbopack::{evaluate_context::node_evaluate_asset_context, transition::TransitionsByName}, - }, -}; - -use crate::{ - embed_js::next_asset, - middleware::middleware_files, - mode::NextMode, - next_config::NextConfig, - next_edge::{ - context::{get_edge_compile_time_info, get_edge_resolve_options_context}, - route_transition::NextEdgeRouteTransition, - }, - next_import_map::get_next_build_import_map, - next_server::context::{get_server_module_options_context, ServerContextType}, - util::parse_config_from_source, -}; - -#[turbo_tasks::function] -fn next_configs() -> Vc> { - Vc::cell( - ["next.config.mjs", "next.config.js"] - .into_iter() - .map(ToOwned::to_owned) - .collect(), - ) -} - -#[turbo_tasks::value(shared)] -#[derive(Debug, Clone, Default)] -#[serde(rename_all = "camelCase")] -pub struct RouterRequest { - pub method: String, - pub pathname: String, - pub raw_query: String, - pub raw_headers: Vec<(String, String)>, - pub body: Vec, -} - -#[turbo_tasks::value(shared)] -#[derive(Debug, Clone, Default)] -#[serde(rename_all = "camelCase")] -pub struct RewriteResponse { - pub url: String, - pub headers: Vec<(String, String)>, -} - -#[turbo_tasks::value(shared)] -#[derive(Debug, Clone, Default)] -#[serde(rename_all = "camelCase")] -pub struct MiddlewareHeadersResponse { - pub status_code: u16, - pub headers: Vec<(String, String)>, -} - -#[turbo_tasks::value(shared)] -#[derive(Debug, Clone, Default)] -pub struct MiddlewareBodyResponse(Bytes); - -#[derive(Deserialize, Debug)] -#[serde(tag = "type", rename_all = "kebab-case")] -enum RouterIncomingMessage { - Rewrite { data: RewriteResponse }, - MiddlewareHeaders { data: MiddlewareHeadersResponse }, - MiddlewareBody { data: Vec }, - None, - Error { error: StructuredError }, -} - -#[turbo_tasks::value] -#[derive(Debug, Clone, Default)] -pub struct MiddlewareResponse { - pub status_code: u16, - pub headers: Vec<(String, String)>, - #[turbo_tasks(trace_ignore)] - pub body: Stream>, -} - -#[turbo_tasks::value] -#[derive(Debug)] -pub enum RouterResult { - Rewrite(RewriteResponse), - Middleware(MiddlewareResponse), - None, - Error(#[turbo_tasks(trace_ignore)] SharedError), -} - -#[turbo_tasks::function] -async fn next_config_changed( - context: Vc>, - project_path: Vc, -) -> Result> { - let find_config_result = find_context_file(project_path, next_configs()); - Ok(match *find_config_result.await? { - FindContextFileResult::Found(config_path, _) => { - let module = context.process( - Vc::upcast(FileSource::new(config_path)), - Value::new(ReferenceType::Internal(InnerAssets::empty())), - ); - any_content_changed_of_module(module) - } - FindContextFileResult::NotFound(_) => Completion::immutable(), - }) -} - -#[turbo_tasks::function] -async fn config_assets( - context: Vc>, - project_path: Vc, - page_extensions: Vc>, -) -> Result> { - let find_config_result = find_context_file(project_path, middleware_files(page_extensions)); - - // The router.ts file expects a manifest of chunks for the middleware. If there - // is no middleware file, then we need to generate a default empty manifest - // and we cannot process it with the next-edge transition because it - // requires a real file for some reason. - let (manifest, config) = match *find_config_result.await? { - FindContextFileResult::Found(config_path, _) => { - let config = context.process( - Vc::upcast(FileSource::new(config_path)), - Value::new(ReferenceType::EcmaScriptModules( - EcmaScriptModulesReferenceSubType::Undefined, - )), - ); - let config = parse_config_from_source(config); - let manifest = context.with_transition("next-edge".to_string()).process( - Vc::upcast(FileSource::new(config_path)), - Value::new(ReferenceType::EcmaScriptModules( - EcmaScriptModulesReferenceSubType::Undefined, - )), - ); - (manifest, config) - } - FindContextFileResult::NotFound(_) => { - let manifest = context.process( - Vc::upcast(VirtualSource::new( - project_path.join("middleware.js".to_string()), - AssetContent::file(File::from("export default [];").into()), - )), - Value::new(ReferenceType::Internal(InnerAssets::empty())), - ); - let config = Default::default(); - (manifest, config) - } - }; - - let config_asset = context.process( - Vc::upcast(VirtualSource::new( - project_path.join("middleware_config.js".to_string()), - AssetContent::file( - File::from(format!( - "export default {};", - json!({ "matcher": &config.await?.matcher }) - )) - .into(), - ), - )), - Value::new(ReferenceType::Internal(InnerAssets::empty())), - ); - - Ok(Vc::cell(indexmap! { - "MIDDLEWARE_CHUNK_GROUP".to_string() => manifest, - "MIDDLEWARE_CONFIG".to_string() => config_asset, - })) -} - -#[turbo_tasks::function] -fn route_executor( - context: Vc>, - configs: Vc, -) -> Vc> { - context.process( - next_asset("entry/router.ts".to_string()), - Value::new(ReferenceType::Internal(configs)), - ) -} - -#[turbo_tasks::function] -fn edge_transition_map( - server_addr: Vc, - dist_root: Vc, - project_path: Vc, - output_path: Vc, - next_config: Vc, - execution_context: Vc, -) -> Vc { - let mode = NextMode::DevServer; - - let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr, dist_root); - - let edge_chunking_context = Vc::upcast( - DevChunkingContext::builder( - project_path, - output_path.join("edge".to_string()), - output_path.join("edge/chunks".to_string()), - output_path.join("edge/assets".to_string()), - edge_compile_time_info.environment(), - ) - .reference_chunk_source_maps(should_debug("router")) - .build(), - ); - - let edge_resolve_options_context = get_edge_resolve_options_context( - project_path, - Value::new(ServerContextType::Middleware), - mode, - next_config, - execution_context, - ); - - let server_module_options_context = get_server_module_options_context( - project_path, - execution_context, - Value::new(ServerContextType::Middleware), - mode, - next_config, - ); - - let next_edge_transition = Vc::upcast( - NextEdgeRouteTransition { - edge_compile_time_info, - edge_chunking_context, - edge_module_options_context: Some(server_module_options_context), - edge_resolve_options_context, - output_path: output_path.root(), - base_path: project_path, - bootstrap_asset: next_asset("entry/edge-bootstrap.ts".to_string()), - entry_name: "middleware".to_string(), - } - .cell(), - ); - - Vc::cell( - [("next-edge".to_string(), next_edge_transition)] - .into_iter() - .collect(), - ) -} - -#[turbo_tasks::function] -pub async fn route( - execution_context: Vc, - request: Vc, - dist_root: Vc, - next_config: Vc, - server_addr: Vc, - routes_changed: Vc, -) -> Result> { - let RouterRequest { - ref method, - ref pathname, - .. - } = *request.await?; - route_internal( - execution_context, - request, - dist_root, - next_config, - server_addr, - routes_changed, - ) - .attach_description(format!("Next.js Routing for {} {}", method, pathname)) - .await -} - -macro_rules! shared_anyhow { - ($msg:literal $(,)?) => { - turbo_tasks::util::SharedError::new(anyhow::anyhow!($msg)) - }; - ($err:expr $(,)?) => { - turbo_tasks::util::SharedError::new(anyhow::anyhow!($err)) - }; - ($fmt:expr, $($arg:tt)*) => { - turbo_tasks::util::SharedError::new(anyhow::anyhow!($fmt, $($arg)*)) - }; -} - -#[turbo_tasks::function] -async fn route_internal( - execution_context: Vc, - request: Vc, - dist_root: Vc, - next_config: Vc, - server_addr: Vc, - routes_changed: Vc, -) -> Result> { - let ExecutionContext { - project_path, - chunking_context, - env, - } = *execution_context.await?; - - let context = node_evaluate_asset_context( - execution_context, - Some(get_next_build_import_map()), - Some(edge_transition_map( - server_addr, - dist_root, - project_path, - chunking_context.output_root(), - next_config, - execution_context, - )), - ); - - let configs = config_assets(context, project_path, next_config.page_extensions()); - let router_asset = route_executor(context, configs); - - // This invalidates the router when the next config changes - let next_config_changed = next_config_changed(context, project_path); - - let request = serde_json::value::to_value(&*request.await?)?; - let Some(dir) = to_sys_path(project_path).await? else { - bail!("Next.js requires a disk path to check for valid routes"); - }; - let chunking_context = chunking_context.with_layer("router".to_string()); - let server_addr = server_addr.await?; - let invalidation = Completions::all(vec![next_config_changed, routes_changed]); - let debug = should_debug("router"); - let result = evaluate( - router_asset, - project_path, - env, - AssetIdent::from_path(project_path), - context, - chunking_context.with_layer("router".to_string()), - None, - vec![ - Vc::cell(request), - Vc::cell(dir.to_string_lossy().into()), - Vc::cell(serde_json::to_value(ServerInfo::try_from(&*server_addr)?)?), - ], - invalidation, - debug, - ) - .await?; - - let mut read = result.read(); - - let first = match read.next().await { - Some(Ok(first)) => first, - Some(Err(e)) => { - return Ok(RouterResult::Error(SharedError::new( - anyhow!(e) - .context("router evaluation failed: received error from javascript stream"), - )) - .cell()) - } - None => { - return Ok(RouterResult::Error(shared_anyhow!( - "router evaluation failed: no message received from javascript stream" - )) - .cell()) - } - }; - let first = first.to_str()?; - let first: RouterIncomingMessage = parse_json_with_source_context(first) - .with_context(|| format!("parsing incoming message ({})", first))?; - - let (res, read) = match first { - RouterIncomingMessage::Rewrite { data } => (RouterResult::Rewrite(data), Some(read)), - - RouterIncomingMessage::MiddlewareHeaders { data } => { - // The double encoding here is annoying. It'd be a lot nicer if we could embed - // a buffer directly into the IPC message without having to wrap it in an - // object. - let body = read.map(|data| { - let chunk: RouterIncomingMessage = data? - .to_str() - .context("error decoding string") - .and_then(parse_json_with_source_context)?; - match chunk { - RouterIncomingMessage::MiddlewareBody { data } => Ok(Bytes::from(data)), - m => Err(shared_anyhow!("unexpected message type: {:#?}", m)), - } - }); - let middleware = MiddlewareResponse { - status_code: data.status_code, - headers: data.headers, - body: Stream::from(body), - }; - - (RouterResult::Middleware(middleware), None) - } - - RouterIncomingMessage::None => (RouterResult::None, Some(read)), - - RouterIncomingMessage::Error { error } => { - // Must be the same pool as above - let pool = get_evaluate_pool( - router_asset, - project_path, - env, - context, - chunking_context, - None, - invalidation, - debug, - ) - .await?; - ( - RouterResult::Error(shared_anyhow!( - trace_stack_with_source_mapping_assets( - error, - pool.assets_for_source_mapping, - chunking_context.output_root(), - project_path - ) - .await? - )), - Some(read), - ) - } - - RouterIncomingMessage::MiddlewareBody { .. } => ( - RouterResult::Error(shared_anyhow!( - "unexpected incoming middleware body without middleware headers" - )), - Some(read), - ), - }; - - // Middleware will naturally drain the full stream, but the rest only take a - // single item. In order to free the NodeJsOperation, we must pull another - // value out of the stream. - if let Some(mut read) = read { - if let Some(v) = read.next().await { - bail!("unexpected message type: {:#?}", v); - } - } - - Ok(res.cell()) -} diff --git a/packages/next-swc/crates/next-core/src/router_source.rs b/packages/next-swc/crates/next-core/src/router_source.rs deleted file mode 100644 index a43ec5f86515f..0000000000000 --- a/packages/next-swc/crates/next-core/src/router_source.rs +++ /dev/null @@ -1,222 +0,0 @@ -use anyhow::{anyhow, bail, Context, Result}; -use futures::{Stream, TryStreamExt}; -use indexmap::IndexSet; -use turbo_tasks::{Completion, Completions, Value, Vc}; -use turbopack_binding::turbopack::{ - core::{ - environment::ServerAddr, - introspect::{Introspectable, IntrospectableChildren}, - }, - dev_server::source::{ - route_tree::{RouteTree, RouteType}, - Body, ContentSource, ContentSourceContent, ContentSourceData, ContentSourceDataVary, - GetContentSourceContent, HeaderList, ProxyResult, RewriteBuilder, - }, - node::execution_context::ExecutionContext, -}; - -use crate::{ - app_structure::OptionAppDir, - next_config::NextConfig, - pages_structure::PagesStructure, - router::{route, RouterRequest, RouterResult}, -}; - -#[turbo_tasks::value(shared)] -pub struct NextRouterContentSource { - /// A wrapped content source from which we will fetch assets. - inner: Vc>, - execution_context: Vc, - next_config: Vc, - server_addr: Vc, - app_dir: Vc, - pages_structure: Vc, - dist_root: Vc, -} - -#[turbo_tasks::value_impl] -impl NextRouterContentSource { - #[turbo_tasks::function] - pub fn new( - inner: Vc>, - execution_context: Vc, - next_config: Vc, - server_addr: Vc, - app_dir: Vc, - pages_structure: Vc, - dist_root: Vc, - ) -> Vc { - NextRouterContentSource { - inner, - execution_context, - next_config, - server_addr, - app_dir, - pages_structure, - dist_root, - } - .cell() - } -} - -#[turbo_tasks::function] -fn routes_changed( - app_dir: Vc, - pages_structure: Vc, - next_config: Vc, -) -> Vc { - Completions::all(vec![ - app_dir.routes_changed(next_config), - pages_structure.routes_changed(), - ]) -} - -#[turbo_tasks::value_impl] -impl ContentSource for NextRouterContentSource { - #[turbo_tasks::function] - async fn get_routes(self: Vc) -> Result> { - let this = self.await?; - // The next-dev server can currently run against projects as simple as - // `index.js`. If this isn't a Next.js project, don't try to use the Next.js - // router. - if this.app_dir.await?.is_none() && this.pages_structure.await?.pages.is_none() { - return Ok(this.inner.get_routes()); - } - - // Prefetch get_routes from inner - let _ = this.inner.get_routes(); - - Ok(RouteTree::new_route( - Vec::new(), - RouteType::CatchAll, - Vc::upcast(self), - )) - } -} - -#[turbo_tasks::value_impl] -impl GetContentSourceContent for NextRouterContentSource { - #[turbo_tasks::function] - fn vary(&self) -> Vc { - ContentSourceDataVary { - method: true, - raw_headers: true, - raw_query: true, - body: true, - ..Default::default() - } - .cell() - } - - #[turbo_tasks::function] - async fn get( - self: Vc, - path: String, - data: Value, - ) -> Result> { - let this = self.await?; - - let ContentSourceData { - method: Some(method), - raw_headers: Some(raw_headers), - raw_query: Some(raw_query), - body: Some(body), - .. - } = &*data - else { - bail!("missing data for router"); - }; - - // TODO: change router so we can stream the request body to it - let mut body_stream = body.await?.read(); - - let mut body = Vec::with_capacity(body_stream.size_hint().0); - while let Some(data) = body_stream.try_next().await? { - body.push(data); - } - - let request = RouterRequest { - pathname: format!("/{path}"), - method: method.clone(), - raw_headers: raw_headers.clone(), - raw_query: raw_query.clone(), - body, - } - .cell(); - - let res = route( - this.execution_context, - request, - this.dist_root, - this.next_config, - this.server_addr, - routes_changed(this.app_dir, this.pages_structure, this.next_config), - ); - - let res = res - .await - .with_context(|| format!("failed to fetch /{path}{}", formated_query(raw_query)))?; - - Ok(match &*res { - RouterResult::Error(e) => { - return Err(anyhow!(e.clone()).context(format!( - "error during Next.js routing for /{path}{}", - formated_query(raw_query) - ))) - } - RouterResult::None => { - let rewrite = - RewriteBuilder::new_source_with_path_and_query(this.inner, format!("/{path}")); - ContentSourceContent::Rewrite(rewrite.build()).cell() - } - RouterResult::Rewrite(data) => { - let mut rewrite = - RewriteBuilder::new_source_with_path_and_query(this.inner, data.url.clone()); - if !data.headers.is_empty() { - rewrite = rewrite.response_headers(HeaderList::new(data.headers.clone())); - } - ContentSourceContent::Rewrite(rewrite.build()).cell() - } - RouterResult::Middleware(data) => ContentSourceContent::HttpProxy( - ProxyResult { - status: data.status_code, - headers: data.headers.clone(), - body: Body::from_stream(data.body.read()), - } - .cell(), - ) - .cell(), - }) - } -} - -fn formated_query(query: &str) -> String { - if query.is_empty() { - "".to_string() - } else { - format!("?{query}") - } -} - -#[turbo_tasks::value_impl] -impl Introspectable for NextRouterContentSource { - #[turbo_tasks::function] - fn ty(&self) -> Vc { - Vc::cell("next router source".to_string()) - } - - #[turbo_tasks::function] - fn details(&self) -> Vc { - Vc::cell("handles routing by letting Next.js handle the routing.".to_string()) - } - - #[turbo_tasks::function] - async fn children(&self) -> Result> { - let mut children = IndexSet::new(); - if let Some(inner) = Vc::try_resolve_sidecast::>(self.inner).await? - { - children.insert((Vc::cell("inner".to_string()), inner)); - } - Ok(Vc::cell(children)) - } -} diff --git a/packages/next-swc/crates/next-core/src/web_entry_source.rs b/packages/next-swc/crates/next-core/src/web_entry_source.rs deleted file mode 100644 index 6e7b62ef4461c..0000000000000 --- a/packages/next-swc/crates/next-core/src/web_entry_source.rs +++ /dev/null @@ -1,252 +0,0 @@ -use std::collections::HashMap; - -use anyhow::{anyhow, Result}; -use turbo_tasks::Vc; -use turbopack_binding::{ - turbo::{ - tasks::{TryJoinIterExt, Value}, - tasks_fs::FileSystemPath, - }, - turbopack::{ - core::{ - chunk::{ChunkableModule, ChunkingContext}, - compile_time_defines, - compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReferences}, - context::AssetContext, - environment::{BrowserEnvironment, Environment, ExecutionEnvironment}, - file_source::FileSource, - free_var_references, - reference_type::{EntryReferenceSubType, ReferenceType}, - resolve::{ - origin::{PlainResolveOrigin, ResolveOrigin, ResolveOriginExt}, - parse::Request, - }, - }, - dev::{react_refresh::assert_can_resolve_react_refresh, DevChunkingContext}, - dev_server::{ - html::DevHtmlAsset, - source::{asset_graph::AssetGraphContentSource, ContentSource}, - }, - node::execution_context::ExecutionContext, - turbopack::{ecmascript::EcmascriptModuleAsset, ModuleAssetContext}, - }, -}; - -use crate::{ - embed_js::next_js_file_path, - mode::NextMode, - next_client::{ - context::{get_client_resolve_options_context, ClientContextType}, - get_client_module_options_context, RuntimeEntries, RuntimeEntry, - }, - next_config::NextConfig, -}; - -fn defines() -> CompileTimeDefines { - compile_time_defines!( - process.turbopack = true, - process.env.NODE_ENV = "development", - ) -} - -#[turbo_tasks::function] -fn web_defines() -> Vc { - defines().cell() -} - -#[turbo_tasks::function] -async fn web_free_vars() -> Result> { - Ok(free_var_references!(..defines().into_iter()).cell()) -} - -#[turbo_tasks::function] -pub fn get_compile_time_info(browserslist_query: String) -> Vc { - CompileTimeInfo::builder(Environment::new(Value::new(ExecutionEnvironment::Browser( - BrowserEnvironment { - dom: true, - web_worker: false, - service_worker: false, - browserslist_query: browserslist_query.to_owned(), - } - .into(), - )))) - .defines(web_defines()) - .free_var_references(web_free_vars()) - .cell() -} - -#[turbo_tasks::function] -async fn get_web_runtime_entries( - project_root: Vc, - ty: Value, - mode: NextMode, - next_config: Vc, - execution_context: Vc, -) -> Result> { - let mut runtime_entries = vec![]; - - let resolve_options_context = - get_client_resolve_options_context(project_root, ty, mode, next_config, execution_context); - let enable_react_refresh = - assert_can_resolve_react_refresh(project_root, resolve_options_context) - .await? - .as_request(); - - // It's important that React Refresh come before the regular bootstrap file, - // because the bootstrap contains JSX which requires Refresh's global - // functions to be available. - if let Some(request) = enable_react_refresh { - runtime_entries - .push(RuntimeEntry::Request(request, project_root.join("_".to_string())).cell()) - }; - - runtime_entries.push( - RuntimeEntry::Source(Vc::upcast(FileSource::new(next_js_file_path( - "dev/bootstrap.ts".to_string(), - )))) - .cell(), - ); - - Ok(Vc::cell(runtime_entries)) -} - -// This is different from `get_client_chunking_context` as we need the assets -// to be available under a different root, otherwise we can run into conflicts. -// We don't want to have `get_client_chunking_context` depend on the -// `ClientContextType` as it's only relevant in this case, and would otherwise -// create new dev chunking contexts for no reason. -#[turbo_tasks::function] -fn get_web_client_chunking_context( - project_path: Vc, - client_root: Vc, - environment: Vc, -) -> Vc> { - Vc::upcast( - DevChunkingContext::builder( - project_path, - client_root, - client_root.join("_chunks".to_string()), - client_root.join("_media".to_string()), - environment, - ) - .hot_module_replacement() - .build(), - ) -} - -#[turbo_tasks::function] -fn get_web_client_asset_context( - project_path: Vc, - execution_context: Vc, - compile_time_info: Vc, - ty: Value, - mode: NextMode, - next_config: Vc, -) -> Vc> { - let resolve_options_context = - get_client_resolve_options_context(project_path, ty, mode, next_config, execution_context); - let module_options_context = get_client_module_options_context( - project_path, - execution_context, - compile_time_info.environment(), - ty, - mode, - next_config, - ); - - let context: Vc> = Vc::upcast(ModuleAssetContext::new( - Vc::cell(HashMap::new()), - compile_time_info, - module_options_context, - resolve_options_context, - )); - - context -} - -#[turbo_tasks::function] -pub async fn create_web_entry_source( - project_root: Vc, - execution_context: Vc, - entry_requests: Vec>, - client_root: Vc, - eager_compile: bool, - browserslist_query: String, - next_config: Vc, -) -> Result>> { - let ty = Value::new(ClientContextType::Other); - let mode = NextMode::DevServer; - let compile_time_info = get_compile_time_info(browserslist_query); - let context = get_web_client_asset_context( - project_root, - execution_context, - compile_time_info, - ty, - mode, - next_config, - ); - let chunking_context = - get_web_client_chunking_context(project_root, client_root, compile_time_info.environment()); - let entries = get_web_runtime_entries(project_root, ty, mode, next_config, execution_context); - - let runtime_entries = entries.resolve_entries(context); - - let origin = Vc::upcast::>(PlainResolveOrigin::new( - context, - project_root.join("_".to_string()), - )); - let entries = entry_requests - .into_iter() - .map(|request| async move { - let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Web)); - Ok(origin - .resolve_asset(request, origin.resolve_options(ty.clone()), ty) - .primary_modules() - .await? - .first() - .copied()) - }) - .try_join() - .await?; - - let entries: Vec<_> = entries - .into_iter() - .flatten() - .map(|module| async move { - if let Some(ecmascript) = - Vc::try_resolve_downcast_type::(module).await? - { - Ok(( - Vc::upcast(ecmascript), - chunking_context, - Some(runtime_entries.with_entry(Vc::upcast(ecmascript))), - )) - } else if let Some(chunkable) = - Vc::try_resolve_sidecast::>(module).await? - { - // TODO this is missing runtime code, so it's probably broken and we should also - // add an ecmascript chunk with the runtime code - Ok((chunkable, chunking_context, None)) - } else { - // TODO convert into a serve-able asset - Err(anyhow!( - "Entry module is not chunkable, so it can't be used to bootstrap the \ - application" - )) - } - }) - .try_join() - .await?; - - let entry_asset = Vc::upcast(DevHtmlAsset::new( - client_root.join("index.html".to_string()), - entries, - )); - - let graph = Vc::upcast(if eager_compile { - AssetGraphContentSource::new_eager(client_root, entry_asset) - } else { - AssetGraphContentSource::new_lazy(client_root, entry_asset) - }); - Ok(graph) -} diff --git a/packages/next-swc/crates/next-dev-tests/.gitignore b/packages/next-swc/crates/next-dev-tests/.gitignore deleted file mode 100644 index 559953e86a971..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tests/temp \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/Cargo.toml b/packages/next-swc/crates/next-dev-tests/Cargo.toml deleted file mode 100644 index 03f450b3b2f19..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/Cargo.toml +++ /dev/null @@ -1,67 +0,0 @@ -[package] -name = "next-dev-tests" -version = "0.1.0" -description = "TBD" -license = "MPL-2.0" -edition = "2021" -autobenches = false - -# don't publish this crate -publish = false - -[features] -tokio_console = [ - "dep:console-subscriber", - "tokio/tracing", - "turbopack-binding/__turbo_tasks_tokio_tracing", -] - -[dependencies] -console-subscriber = { workspace = true, optional = true } - -[dev-dependencies] -anyhow = { workspace = true } -chromiumoxide = { workspace = true, features = [ - "tokio-runtime", -], default-features = false } -dunce = { workspace = true } -futures = { workspace = true } -httpmock = { workspace = true, default-features = false, features = ["standalone"] } -lazy_static = { workspace = true } -mime = { workspace = true } -next-core = { workspace = true } -next-dev = { path = "../next-dev" } -owo-colors = { workspace = true } -parking_lot = { workspace = true } -rand = { workspace = true } -regex = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -tempdir = "0.3.7" -testing = { workspace = true } -tokio = { workspace = true, features = ["full"] } -# For matching on errors from chromiumoxide. Keep in -# sync with chromiumoxide's tungstenite requirement. -tungstenite = { workspace = true } -turbopack-binding = { workspace = true, features = [ - "__turbo_tasks_malloc", - "__turbo_tasks_memory", - "__turbo_tasks", - "__turbo_tasks_fs", - "__turbo_tasks_testing", - "__turbopack_cli_utils", - "__turbopack_test_utils", - "__turbopack_core", - "__turbopack_core_issue_path", - "__turbopack_node", - "__turbopack_dev_server", - "__swc_transform_relay" -]} -turbo-tasks = { workspace = true } -url = { workspace = true } -webbrowser = { workspace = true } - -[build-dependencies] -turbopack-binding = { workspace = true, features = [ - "__turbo_tasks_build" -]} diff --git a/packages/next-swc/crates/next-dev-tests/build.rs b/packages/next-swc/crates/next-dev-tests/build.rs deleted file mode 100644 index 8ff772ae9eded..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/build.rs +++ /dev/null @@ -1,9 +0,0 @@ -use turbopack_binding::turbo::tasks_build::{generate_register, rerun_if_glob}; - -fn main() { - generate_register(); - // The test/integration crate need to be rebuilt if any test input is changed. - // Unfortunately, we can't have the build.rs file operate differently on - // each file, so the entire next-dev crate needs to be rebuilt. - rerun_if_glob("tests/integration/*/*", "tests/integration"); -} diff --git a/packages/next-swc/crates/next-dev-tests/test-harness/harness.ts b/packages/next-swc/crates/next-dev-tests/test-harness/harness.ts deleted file mode 100644 index 38deb45c34904..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/test-harness/harness.ts +++ /dev/null @@ -1,275 +0,0 @@ -import * as jest from 'jest-circus-browser/dist/umd/jest-circus' -import expectMod from 'expect/build-es5/index' - -declare global { - var __jest__: typeof jest - var expect: typeof expectMod - // We need to extract only the call signature as `autoReady(jest.describe)` drops all the other properties - var describe: AutoReady - var it: AutoReady - var TURBOPACK_READY: (arg: string) => void - var TURBOPACK_CHANGE_FILE: (arg: string) => void - var nsObj: (obj: any) => any - var __turbopackFileChanged: (id: string, error: Error) => void - - interface Window { - NEXT_HYDRATED?: boolean - onNextHydrated?: () => void - } -} - -globalThis.__jest__ = jest -globalThis.expect = expectMod -globalThis.describe = autoReady(jest.describe, markReady) -globalThis.it = autoReady(jest.it, markReady) - -// From https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/test/TestCases.template.js#L422 -globalThis.nsObj = function nsObj(obj) { - Object.defineProperty(obj, Symbol.toStringTag, { - value: 'Module', - }) - return obj -} - -type AnyFunction = (...args: any[]) => any - -type AutoReady = T & { - [K in keyof T]: T[K] extends AnyFunction ? AutoReady : T[K] -} - -function autoReady void>( - fn: T, - callback: F -): AutoReady { - const wrappedFn = ((...args: Parameters): ReturnType => { - callback() - - return fn(...args) - }) as AutoReady - - for (const key in fn) { - if (typeof fn[key] === 'function') { - ;(wrappedFn as any)[key] = autoReady(fn[key] as AnyFunction, callback) - } else { - ;(wrappedFn as any)[key] = fn[key] - } - } - - return wrappedFn -} - -let isReady = false -function markReady() { - if (!isReady) { - isReady = true - requestIdleCallback( - () => { - if (typeof TURBOPACK_READY === 'function') { - TURBOPACK_READY('') - } else { - console.info( - '%cTurbopack tests:', - 'font-weight: bold;', - 'Entering debug mode. Run `await __jest__.run()` in the browser console to run tests.' - ) - } - }, - { timeout: 20000 } - ) - } -} - -export function wait(ms: number): Promise { - return new Promise((resolve) => { - setTimeout(resolve, ms) - }) -} - -export async function waitForCondition( - predicate: () => boolean, - timeout: number | null = null -): Promise { - const start = Date.now() - while (true) { - if (predicate()) { - break - } - - await wait(1) - - if (timeout != null && Date.now() - start > timeout) { - throw new Error('Timed out waiting for condition') - } - } -} - -async function waitForPath(contentWindow: Window, path: string): Promise { - return waitForCondition(() => contentWindow.location.pathname === path) -} - -/** - * Loads a new page in an iframe and waits for it to load. - */ -export function load(iframe: HTMLIFrameElement, path: string): Promise { - iframe.src = path - - return new Promise((resolve) => { - let eventListener = () => { - iframe.removeEventListener('load', eventListener) - resolve() - } - iframe.addEventListener('load', eventListener) - }) -} - -/** - * Waits for the currently loading page in an iframe to finish loading. - * - * If the iframe is already loaded, this function will return immediately. - * - * Note: if you've just changed the iframe's `src` attribute, you should use `load` instead. - */ -export function waitForLoaded(iframe: HTMLIFrameElement): Promise { - return new Promise((resolve) => { - if ( - iframe.contentDocument != null && - iframe.contentDocument.readyState === 'complete' && - iframe.contentDocument.documentURI !== 'about:blank' - ) { - resolve() - } else { - let eventListener = () => { - iframe.removeEventListener('load', eventListener) - resolve() - } - iframe.addEventListener('load', eventListener) - } - }) -} - -export function waitForSelector( - node: HTMLIFrameElement | ShadowRoot, - selector: string -): Promise { - return new Promise((resolve, reject) => { - const document = - 'contentDocument' in node ? node.contentDocument!.documentElement : node - const timeout = 30000 - let element = document.querySelector(selector) - if (element) { - return resolve(element) - } - const observer = new MutationObserver(async () => { - let el = document.querySelector(selector) - if (el) { - resolve(el) - observer.disconnect() - } - }) - observer.observe(document, { childList: true, subtree: true }) - if (timeout) { - setTimeout(() => { - observer.disconnect() - reject( - new Error( - `Timed out waiting for selector "${selector}" in "${document}"\n\nNode content: "${ - 'innerHTML' in document ? document.innerHTML : 'no innerHTML' - }"` - ) - ) - }, timeout) - } - }) -} - -export async function waitForErrorOverlay( - node: HTMLIFrameElement -): Promise { - let element = await waitForSelector(node, 'nextjs-portal') - return element.shadowRoot! -} - -export function waitForHydration( - iframe: HTMLIFrameElement, - path: string -): Promise { - return new Promise((resolve) => { - if ( - iframe.contentDocument != null && - iframe.contentDocument.readyState === 'complete' - ) { - waitForHydrationAndResolve(iframe.contentWindow!, path).then(resolve) - } else { - const eventListener = () => { - waitForHydrationAndResolve(iframe.contentWindow!, path).then(resolve) - iframe.removeEventListener('load', eventListener) - } - iframe.addEventListener('load', eventListener) - } - }) -} - -async function waitForHydrationAndResolve( - contentWindow: Window, - path: string -): Promise { - await waitForPath(contentWindow, path) - - return await new Promise((resolve) => { - if (contentWindow.NEXT_HYDRATED) { - resolve() - } else { - contentWindow.onNextHydrated = () => { - resolve() - } - } - }) -} - -export function markAsHydrated() { - window.NEXT_HYDRATED = true - if (typeof window.onNextHydrated === 'function') { - window.onNextHydrated() - } -} - -const fileChangedResolvers: Map< - string, - { resolve: (value: unknown) => void; reject: (error: Error) => void } -> = new Map() - -globalThis.__turbopackFileChanged = (id: string, error?: Error) => { - const resolver = fileChangedResolvers.get(id) - if (resolver == null) { - throw new Error(`No resolver found for id ${id}`) - } else if (error != null) { - resolver.reject(error) - } else { - resolver.resolve(null) - } -} - -function unsafeUniqueId(): string { - const LENGTH = 10 - const BASE = 16 - return Math.floor(Math.random() * Math.pow(BASE, LENGTH)) - .toString(BASE) - .slice(0, LENGTH) -} - -export async function changeFile( - path: string, - find: string, - replaceWith: string -) { - return new Promise((resolve, reject) => { - let id - while ((id = unsafeUniqueId())) { - if (!fileChangedResolvers.has(id)) break - } - - fileChangedResolvers.set(id, { resolve, reject }) - - TURBOPACK_CHANGE_FILE(JSON.stringify({ path, id, find, replaceWith })) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/test-harness/hooks.ts b/packages/next-swc/crates/next-dev-tests/test-harness/hooks.ts deleted file mode 100644 index 19363eb1b8c56..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/test-harness/hooks.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useEffect } from 'react' - -export type Harness = typeof import('./harness') - -let ranOnce = false -/** - * Run a callback once the test harness is loaded. - */ -export function useTestHarness void>( - callback: T -) { - useEffect(() => { - if (ranOnce) { - return - } - - ranOnce = true - import('./harness').then(callback) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/test-harness/package.json b/packages/next-swc/crates/next-dev-tests/test-harness/package.json deleted file mode 100644 index c42a95bf6bcb7..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/test-harness/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@turbo/pack-test-harness", - "private": true, - "version": "0.0.1", - "main": "./hooks.ts", - "dependencies": { - "expect": "24.5.0", - "jest-circus": "27.5.1", - "jest-circus-browser": "^1.0.7" - } -} diff --git a/packages/next-swc/crates/next-dev-tests/test-harness/types.d.ts b/packages/next-swc/crates/next-dev-tests/test-harness/types.d.ts deleted file mode 100644 index 67dfa385b97f8..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/test-harness/types.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare module 'jest-circus-browser/dist/umd/jest-circus' { - export * from 'jest-circus' -} - -declare module 'expect/build-es5/index' { - export { default } from 'expect' -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration.rs b/packages/next-swc/crates/next-dev-tests/tests/integration.rs deleted file mode 100644 index 5c195dc22c016..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration.rs +++ /dev/null @@ -1,768 +0,0 @@ -#![feature(arbitrary_self_types)] -#![feature(async_fn_in_trait)] -#![cfg(test)] - -use std::{ - collections::{hash_map::Entry, HashMap}, - env, - fmt::Write, - future::{pending, Future}, - net::{IpAddr, Ipv4Addr, SocketAddr}, - panic::{catch_unwind, resume_unwind, AssertUnwindSafe}, - path::{Path, PathBuf}, - time::Duration, -}; - -use anyhow::{anyhow, Context, Result}; -use chromiumoxide::{ - browser::{Browser, BrowserConfig}, - cdp::{ - browser_protocol::network::EventResponseReceived, - js_protocol::runtime::{ - AddBindingParams, EventBindingCalled, EventConsoleApiCalled, EventExceptionThrown, - PropertyPreview, RemoteObject, - }, - }, - error::CdpError::Ws, - Page, -}; -use dunce::canonicalize; -use futures::StreamExt; -use lazy_static::lazy_static; -use next_core::turbopack::{ - cli_utils::issue::{format_issue, LogOptions}, - core::issue::IssueSeverity, -}; -use next_dev::{EntryRequest, NextDevServerBuilder}; -use owo_colors::OwoColorize; -use parking_lot::Mutex; -use regex::{Captures, Regex, Replacer}; -use serde::Deserialize; -use tempdir::TempDir; -use tokio::{ - net::TcpSocket, - sync::mpsc::{unbounded_channel, UnboundedSender}, - task::JoinSet, -}; -use tungstenite::{error::ProtocolError::ResetWithoutClosingHandshake, Error::Protocol}; -use turbo_tasks::{ReadRef, Vc}; -use turbopack_binding::{ - turbo::{ - tasks::{RawVc, State, TransientInstance, TransientValue, TurboTasks}, - tasks_fs::{DiskFileSystem, FileSystem, FileSystemPath}, - tasks_memory::MemoryBackend, - tasks_testing::retry::{retry, retry_async}, - }, - turbopack::{ - core::issue::{ - CapturedIssues, Issue, IssueReporter, Issues, OptionIssueSource, PlainIssue, - }, - test_utils::snapshot::snapshot_issues, - }, -}; - -fn register() { - next_dev::register(); - include!(concat!(env!("OUT_DIR"), "/register_test_integration.rs")); -} - -#[derive(Debug)] -struct JsResult { - uncaught_exceptions: Vec, - run_result: JestRunResult, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -struct JestRunResult { - test_results: Vec, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -struct JestTestResult { - test_path: Vec, - errors: Vec, -} - -lazy_static! { - /// Allows for interactive manual debugging of a test case in a browser with: - /// `TURBOPACK_DEBUG_BROWSER=1 cargo test -p next-dev-tests -- test_my_pattern --nocapture` - static ref DEBUG_BROWSER: bool = env::var("TURBOPACK_DEBUG_BROWSER").is_ok(); - /// Only starts the dev server on port 3000, but doesn't spawn a browser or run any tests. - static ref DEBUG_START: bool = env::var("TURBOPACK_DEBUG_START").is_ok(); - /// When using TURBOPACK_DEBUG_START, this will open the browser to the dev server. - static ref DEBUG_OPEN: bool = env::var("TURBOPACK_DEBUG_OPEN").is_ok(); -} - -fn run_async_test<'a, T>(future: impl Future + Send + 'a) -> T { - let runtime = tokio::runtime::Builder::new_multi_thread() - .worker_threads(1) - .enable_all() - .build() - .unwrap(); - let result = catch_unwind(AssertUnwindSafe(|| runtime.block_on(future))); - println!("Stutting down runtime..."); - runtime.shutdown_timeout(Duration::from_secs(5)); - println!("Stut down runtime"); - match result { - Ok(result) => result, - Err(err) => resume_unwind(err), - } -} - -#[testing::fixture("tests/integration/*/*/*/input")] -fn test(resource: PathBuf) { - let resource = resource.parent().unwrap().to_path_buf(); - if 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 - // are not run. - // - // All current `__flakey__` tests need longer timeouts, but the current - // build of `jest-circus-browser` does not support configuring this. - // - // TODO(WEB-319): Update the version of `jest-circus` in `jest-circus-browser`, - // which supports configuring this. Or explore an alternative. - return; - } - - let JsResult { - uncaught_exceptions, - run_result, - } = run_async_test(run_test(resource)); - - let mut messages = vec![]; - - if run_result.test_results.is_empty() { - messages.push("No tests were run.".to_string()); - } - - for test_result in run_result.test_results { - // It's possible to fail multiple tests across these tests, - // so collect them and fail the respective test in Rust with - // an aggregate message. - if !test_result.errors.is_empty() { - messages.push(format!( - "\"{}\":\n{}", - test_result.test_path[1..].join(" > "), - test_result.errors.join("\n") - )); - } - } - - for uncaught_exception in uncaught_exceptions { - messages.push(format!("Uncaught exception: {}", uncaught_exception)); - } - - if !messages.is_empty() { - panic!( - "Failed with error(s) in the following test(s):\n\n{}", - messages.join("\n\n--\n") - ) - }; -} - -fn copy_recursive(from: &Path, to: &Path) -> std::io::Result<()> { - let from = canonicalize(from)?; - let to = canonicalize(to)?; - let mut entries = vec![]; - for entry in from.read_dir()? { - let entry = entry?; - let path = entry.path(); - let to_path = to.join(path.file_name().unwrap()); - if path.is_dir() { - std::fs::create_dir_all(&to_path)?; - entries.push((path, to_path)); - } else { - std::fs::copy(&path, &to_path)?; - } - } - for (from, to) in entries { - copy_recursive(&from, &to)?; - } - Ok(()) -} - -async fn run_test(resource: PathBuf) -> JsResult { - register(); - - let resource = canonicalize(resource).unwrap(); - assert!(resource.exists(), "{} does not exist", resource.display()); - assert!( - resource.is_dir(), - "{} is not a directory. Integration tests must be directories.", - resource.to_str().unwrap() - ); - - let package_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let tests_dir = package_root.join("tests"); - let integration_tests_dir = tests_dir.join("integration"); - // We run tests from a temporary directory because tests can modify files in the - // test directory when testing the file watcher/HMR, and we have no reliable way - // to ensure that we can restore the original state of the test directory after - // running the test. - let resource_temp: PathBuf = tests_dir.join("temp").join( - resource - .strip_prefix(integration_tests_dir) - .expect("resource path must be within the integration tests directory"), - ); - - // We don't care about errors when removing the previous temp directory. - // It can still exist if we crashed during a previous test run. - let _ = std::fs::remove_dir_all(&resource_temp); - std::fs::create_dir_all(&resource_temp).expect("failed to create temporary directory"); - copy_recursive(&resource, &resource_temp) - .expect("failed to copy test files to temporary directory"); - - let cargo_workspace_root = canonicalize(package_root) - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .to_path_buf(); - - let test_dir = resource_temp.to_path_buf(); - let workspace_root = cargo_workspace_root.parent().unwrap().parent().unwrap(); - let project_dir = test_dir.join("input"); - let requested_addr = if *DEBUG_START { - "127.0.0.1:3000".parse().unwrap() - } else { - get_free_local_addr().unwrap() - }; - - let mock_dir = resource_temp.join("__httpmock__"); - let mock_server_future = get_mock_server_future(&mock_dir); - - let (issue_tx, mut issue_rx) = unbounded_channel(); - let issue_tx = TransientInstance::new(issue_tx); - - let result; - - { - let tt = TurboTasks::new(MemoryBackend::default()); - let server = NextDevServerBuilder::new( - tt.clone(), - project_dir.to_string_lossy().to_string(), - workspace_root.to_string_lossy().to_string(), - ) - .entry_request(EntryRequest::Module( - "@turbo/pack-test-harness".to_string(), - "/harness".to_string(), - )) - .entry_request(EntryRequest::Relative("index.js".to_owned())) - .eager_compile(false) - .hostname(requested_addr.ip()) - .port(requested_addr.port()) - .log_level(turbopack_binding::turbopack::core::issue::IssueSeverity::Warning) - .log_detail(true) - .issue_reporter(Box::new(move || { - Vc::upcast(TestIssueReporter::new(issue_tx.clone())) - })) - .show_all(true) - .build() - .await - .unwrap(); - - let local_addr = - SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), server.addr.port()); - - println!( - "{event_type} - server started at http://{address}", - event_type = "ready".green(), - address = server.addr - ); - - if *DEBUG_START { - if *DEBUG_OPEN { - webbrowser::open(&format!("http://{}", local_addr)).unwrap(); - } - tokio::select! { - _ = mock_server_future => {}, - _ = pending() => {}, - _ = server.future => {}, - }; - panic!("Never resolves") - } - - result = tokio::select! { - // Poll the mock_server first to add the env var - _ = mock_server_future => panic!("Never resolves"), - r = run_browser(local_addr, &project_dir) => r.expect("error while running browser"), - _ = server.future => panic!("Never resolves"), - }; - - env::remove_var("TURBOPACK_TEST_ONLY_MOCK_SERVER"); - - let task = tt.spawn_once_task(async move { - let issues_fs = Vc::upcast::>(DiskFileSystem::new( - "issues".to_string(), - resource.join("issues").to_string_lossy().to_string(), - )); - - let mut issues = vec![]; - while let Ok(issue) = issue_rx.try_recv() { - issues.push(issue); - } - - snapshot_issues( - issues.iter().cloned(), - issues_fs.root(), - &cargo_workspace_root.to_string_lossy(), - ) - .await?; - - Ok::, _>(Default::default()) - }); - tt.wait_task_completion(task, true).await.unwrap(); - } - - if let Err(err) = retry( - (), - |()| std::fs::remove_dir_all(&resource_temp), - 3, - Duration::from_millis(100), - ) { - eprintln!("Failed to remove temporary directory: {}", err); - } - - result -} - -async fn create_browser(is_debugging: bool) -> Result<(Browser, TempDir, JoinSet<()>)> { - let mut config_builder = BrowserConfig::builder(); - config_builder = config_builder.no_sandbox(); - let tmp = TempDir::new("chromiumoxid").unwrap(); - config_builder = config_builder.user_data_dir(&tmp); - if is_debugging { - config_builder = config_builder - .with_head() - .args(vec!["--auto-open-devtools-for-tabs"]); - } - - let (browser, mut handler) = retry_async( - config_builder.build().map_err(|s| anyhow!(s))?, - |c| { - let c = c.clone(); - Browser::launch(c) - }, - 3, - Duration::from_millis(100), - ) - .await - .context("Launching browser failed")?; - - // For windows it's important that the browser is dropped so that the test can - // complete. To do that we need to cancel the spawned task below (which will - // drop the browser). For this we are using a JoinSet which cancels all tasks - // when dropped. - let mut set = JoinSet::new(); - // See https://crates.io/crates/chromiumoxide - set.spawn(async move { - loop { - if let Err(Ws(Protocol(ResetWithoutClosingHandshake))) = handler.next().await.unwrap() { - // The user has most likely closed the browser. End gracefully. - break; - } - } - }); - - Ok((browser, tmp, set)) -} - -const TURBOPACK_READY_BINDING: &str = "TURBOPACK_READY"; -const TURBOPACK_DONE_BINDING: &str = "TURBOPACK_DONE"; -const TURBOPACK_CHANGE_FILE_BINDING: &str = "TURBOPACK_CHANGE_FILE"; -const BINDINGS: [&str; 3] = [ - TURBOPACK_READY_BINDING, - TURBOPACK_DONE_BINDING, - TURBOPACK_CHANGE_FILE_BINDING, -]; - -async fn run_browser(addr: SocketAddr, project_dir: &Path) -> Result { - let is_debugging = *DEBUG_BROWSER; - println!("starting browser..."); - let (browser, _tmp, mut handle) = create_browser(is_debugging).await?; - - println!("open about:blank..."); - // `browser.new_page()` opens a tab, navigates to the destination, and waits for - // the page to load. chromiumoxide/Chrome DevTools Protocol has been flakey, - // returning `ChannelSendError`s (WEB-259). Retry if necessary. - let page = retry_async( - (), - |_| browser.new_page("about:blank"), - 5, - Duration::from_millis(100), - ) - .await - .context("Failed to create new browser page")?; - - for binding in BINDINGS { - page.execute(AddBindingParams::new(binding)).await?; - } - - let mut errors = page - .event_listener::() - .await - .context("Unable to listen to exception events")?; - let mut binding_events = page - .event_listener::() - .await - .context("Unable to listen to binding events")?; - let mut console_events = page - .event_listener::() - .await - .context("Unable to listen to console events")?; - let mut network_response_events = page - .event_listener::() - .await - .context("Unable to listen to response received events")?; - - println!("start navigating to http://{addr}..."); - page.evaluate_expression(format!("window.location='http://{addr}'")) - .await - .context("Unable to evaluate javascript to naviagate to target page")?; - - println!("waiting for navigation..."); - // Wait for the next network response event - // This is the HTML page that we're testing - network_response_events.next().await.context( - "Network events channel ended unexpectedly while waiting on the network response", - )?; - - if is_debugging { - let _ = page.evaluate( - r#"console.info("%cTurbopack tests:", "font-weight: bold;", "Waiting for TURBOPACK_READY to be signaled by page...");"#, - ) - .await; - } - - println!("finished navigation to http://{addr}"); - let mut errors_next = errors.next(); - let mut bindings_next = binding_events.next(); - let mut console_next = console_events.next(); - let mut network_next = network_response_events.next(); - let mut uncaught_exceptions = vec![]; - - loop { - tokio::select! { - event = &mut console_next => { - if let Some(event) = event { - println!( - "console {:?}: {}", - event.r#type, - event - .args - .iter() - .filter_map(|a| a.value.as_ref().map(|v| format!("{:?}", v))) - .collect::>() - .join(", ") - ); - } else { - return Err(anyhow!("Console events channel ended unexpectedly")); - } - console_next = console_events.next(); - } - event = &mut errors_next => { - if let Some(event) = event { - let mut message = String::new(); - let d = &event.exception_details; - writeln!(message, "{}", d.text)?; - if let Some(RemoteObject { preview: Some(ref exception), .. }) = d.exception { - if let Some(PropertyPreview{ value: Some(ref exception_message), .. }) = exception.properties.iter().find(|p| p.name == "message") { - writeln!(message, "{}", exception_message)?; - } - } - if let Some(stack_trace) = &d.stack_trace { - for frame in &stack_trace.call_frames { - writeln!(message, " at {} ({}:{}:{})", frame.function_name, frame.url, frame.line_number, frame.column_number)?; - } - } - let expected_error = message.contains("(expected error)"); - let message = message.trim_end(); - if !is_debugging { - if !expected_error { - uncaught_exceptions.push(message.to_string()); - } - } else if expected_error { - println!("Exception throw in page:\n{}", message); - } else { - println!("Exception throw in page (this would fail the test case without TURBOPACK_DEBUG_BROWSER):\n{}", message); - } - } else { - return Err(anyhow!("Error events channel ended unexpectedly")); - } - errors_next = errors.next(); - } - event = &mut bindings_next => { - if let Some(event) = event { - if let Some(run_result) = handle_binding(&page, &event, project_dir, is_debugging).await? { - return Ok(JsResult { - uncaught_exceptions, - run_result, - }); - } - } else { - return Err(anyhow!("Binding events channel ended unexpectedly")); - } - bindings_next = binding_events.next(); - } - event = &mut network_next => { - if let Some(event) = event { - println!("network {} [{}]", event.response.url, event.response.status); - } else { - return Err(anyhow!("Network events channel ended unexpectedly")); - } - network_next = network_response_events.next(); - } - result = handle.join_next() => { - if let Some(result) = result { - result?; - } else { - return Err(anyhow!("Browser closed")); - } - } - () = tokio::time::sleep(Duration::from_secs(60)) => { - if !is_debugging { - return Err(anyhow!("Test timeout while waiting for TURBOPACK_READY")); - } - } - }; - } -} - -fn get_free_local_addr() -> Result { - let socket = TcpSocket::new_v6()?; - socket.bind("[::]:0".parse().unwrap())?; - socket.local_addr() -} - -async fn get_mock_server_future(mock_dir: &Path) -> Result<(), String> { - if mock_dir.exists() { - let port = get_free_local_addr().unwrap().port(); - env::set_var( - "TURBOPACK_TEST_ONLY_MOCK_SERVER", - format!("http://127.0.0.1:{}", port), - ); - - httpmock::standalone::start_standalone_server( - port, - false, - Some(mock_dir.to_path_buf()), - false, - 0, - std::future::pending(), - ) - .await - } else { - std::future::pending::>().await - } -} - -async fn handle_binding( - page: &Page, - event: &EventBindingCalled, - project_dir: &Path, - is_debugging: bool, -) -> Result, anyhow::Error> { - match event.name.as_str() { - TURBOPACK_READY_BINDING => { - if is_debugging { - let run_tests_msg = "Entering debug mode. Run `await __jest__.run()` in the \ - browser console to run tests."; - println!("\n\n{}", run_tests_msg); - page.evaluate(format!( - r#"console.info("%cTurbopack tests:", "font-weight: bold;", "{}");"#, - run_tests_msg - )) - .await?; - } else { - page.evaluate_expression( - "(() => { __jest__.run().then((runResult) => \ - TURBOPACK_DONE(JSON.stringify(runResult))) })()", - ) - .await?; - } - } - TURBOPACK_DONE_BINDING => { - let run_result: JestRunResult = serde_json::from_str(&event.payload)?; - return Ok(Some(run_result)); - } - TURBOPACK_CHANGE_FILE_BINDING => { - let change_file: ChangeFileCommand = serde_json::from_str(&event.payload)?; - let path = Path::new(&change_file.path); - - // Ensure `change_file.path` can't escape the project directory. - let path = path - .components() - .filter(|c| matches!(c, std::path::Component::Normal(_))) - .collect::(); - - let path: PathBuf = project_dir.join(path); - - let mut file_contents = std::fs::read_to_string(&path)?; - if !file_contents.contains(&change_file.find) { - page.evaluate(format!( - "__turbopackFileChanged({}, new Error({}));", - serde_json::to_string(&change_file.id)?, - serde_json::to_string(&format!( - "TURBOPACK_CHANGE_FILE: file {} does not contain {}", - path.display(), - &change_file.find - ))? - )) - .await?; - } else { - file_contents = file_contents.replace(&change_file.find, &change_file.replace_with); - std::fs::write(&path, file_contents)?; - - page.evaluate(format!( - "__turbopackFileChanged({});", - serde_json::to_string(&change_file.id)? - )) - .await?; - } - } - _ => {} - }; - Ok(None) -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -struct ChangeFileCommand { - path: String, - id: String, - find: String, - replace_with: String, -} - -#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] -struct TestIssueReporter { - #[turbo_tasks(trace_ignore, debug_ignore)] - pub issue_tx: State>>, - #[turbo_tasks(trace_ignore, debug_ignore)] - pub already_printed: Mutex>, -} - -#[turbo_tasks::value_impl] -impl TestIssueReporter { - #[turbo_tasks::function] - fn new(issue_tx: TransientInstance>>) -> Vc { - TestIssueReporter { - issue_tx: State::new((*issue_tx).clone()), - already_printed: Default::default(), - } - .cell() - } -} - -#[turbo_tasks::value_impl] -impl IssueReporter for TestIssueReporter { - #[turbo_tasks::function] - async fn report_issues( - &self, - captured_issues: TransientInstance>, - _source: TransientValue, - _min_failing_severity: Vc, - ) -> Result> { - let log_options = LogOptions { - current_dir: PathBuf::new(), - project_dir: PathBuf::new(), - show_all: true, - log_detail: true, - log_level: IssueSeverity::Info, - }; - let issue_tx = self.issue_tx.get_untracked().clone(); - for (issue, path) in captured_issues.iter_with_shortest_path() { - let plain = NormalizedIssue(issue).cell().into_plain(path); - issue_tx.send(plain.await?)?; - let str = format_issue(&*plain.await?, None, &log_options); - if let Entry::Vacant(e) = self.already_printed.lock().entry(str) { - println!("{}", e.key()); - e.insert(()); - } - } - Ok(Vc::cell(false)) - } -} - -struct StackTraceReplacer; - -impl Replacer for StackTraceReplacer { - fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) { - let code = caps.get(2).map_or("", |m| m.as_str()); - if code.starts_with("node:") { - return; - } - let mut name = caps.get(1).map_or("", |m| m.as_str()); - name = name.strip_prefix("Object.").unwrap_or(name); - write!(dst, "\n at {} ({})", name, code).unwrap(); - } -} - -#[turbo_tasks::value(transparent)] -struct NormalizedIssue(Vc>); - -#[turbo_tasks::value_impl] -impl Issue for NormalizedIssue { - #[turbo_tasks::function] - fn severity(&self) -> Vc { - self.0.severity() - } - - #[turbo_tasks::function] - fn file_path(&self) -> Vc { - self.0.file_path() - } - - #[turbo_tasks::function] - fn category(&self) -> Vc { - self.0.category() - } - - #[turbo_tasks::function] - fn title(&self) -> Vc { - self.0.title() - } - - #[turbo_tasks::function] - async fn description(&self) -> Result> { - let str = self.0.description().await?; - let regex1 = Regex::new(r"\n +at (.+) \((.+)\)(?: \[.+\])?").unwrap(); - let regex2 = Regex::new(r"\n +at ()(.+) \[.+\]").unwrap(); - let regex3 = Regex::new(r"\n +\[at .+\]").unwrap(); - Ok(Vc::cell( - regex3 - .replace_all( - ®ex2.replace_all( - ®ex1.replace_all(&str, StackTraceReplacer), - StackTraceReplacer, - ), - "", - ) - .to_string(), - )) - } - - #[turbo_tasks::function] - fn detail(&self) -> Vc { - self.0.detail() - } - - #[turbo_tasks::function] - fn documentation_link(&self) -> Vc { - self.0.documentation_link() - } - - #[turbo_tasks::function] - fn source(&self) -> Vc { - self.0.source() - } - - #[turbo_tasks::function] - fn sub_issues(&self) -> Vc { - self.0.sub_issues() - } -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/.gitignore b/packages/next-swc/crates/next-dev-tests/tests/integration/.gitignore deleted file mode 100644 index cf4bab9ddde9f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!node_modules diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/[slug]/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/[slug]/page.tsx deleted file mode 100644 index 43c1da0265a19..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/[slug]/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import type React from 'react' -import Test from '../test' - -export default function Page(): React.ReactElement { - return ( -
- -
- ) -} - -export async function generateMetadata({ params }) { - return { - title: `Page(${params.slug})`, - openGraph: { - images: new URL('../triangle-black.png', import.meta.url).pathname, - }, - } -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/layout.tsx deleted file mode 100644 index a3a820cbd4ca2..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/layout.tsx +++ /dev/null @@ -1,17 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} - -export const metadata = { - icons: { - icon: new URL('./triangle-black.png', import.meta.url).pathname, - }, - title: { - absolute: 'RootLayout absolute', - template: '%s - RootLayout', - }, -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/page.tsx deleted file mode 100644 index f6d20b0d35c3c..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { redirect } from 'next/navigation' - -export default function Page() { - redirect('/slug_name') -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/test.tsx deleted file mode 100644 index edf1783e80915..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/test.tsx +++ /dev/null @@ -1,19 +0,0 @@ -'use client' - -import type React from 'react' -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test(): React.ReactElement | null { - useTestHarness(() => { - it('should have the correct title set', () => { - expect(document.title).toBe('Page(slug_name) - RootLayout') - let iconMeta = document.querySelector('link[rel=icon]') - expect(iconMeta).toHaveProperty('href') - expect(iconMeta.href).toMatch(/\/_next\/static\/assets/) - let ogImageMeta = document.querySelector("meta[property='og:image']") - expect(ogImageMeta).toHaveProperty('content') - expect(ogImageMeta.content).toMatch(/\/_next\/static\/assets/) - }) - }) - return null -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/triangle-black.png b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/triangle-black.png deleted file mode 100644 index 351730591885f..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/__flakey__/metadata/input/app/triangle-black.png and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/layout.tsx deleted file mode 100644 index 23a51cee327d2..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/layout.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { cookies } from 'next/headers' - -export default function RootLayout({ children }: { children: any }) { - return ( - - - {JSON.stringify(cookies(), null, 2)} - {children} - - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/test.tsx deleted file mode 100644 index 1c412a9caa6a4..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/input/app/test.tsx +++ /dev/null @@ -1,10 +0,0 @@ -'use client' - -import { useEffect } from 'react' -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('should run', () => {}) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-615d60.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-615d60.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-615d60.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f211f8.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f211f8.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f211f8.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-10ad32.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-10ad32.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-10ad32.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-4d5699.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-4d5699.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-4d5699.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-88200c.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-88200c.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-88200c.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d90ec8.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d90ec8.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/async-local-storage/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d90ec8.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/loading.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/loading.tsx deleted file mode 100644 index f324e16207bed..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/loading.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Loading() { - return <>Loading -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/test.tsx deleted file mode 100644 index 759722501f36c..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/input/app/test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('should run', () => {}) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2f90bd.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2f90bd.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2f90bd.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bbe197.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bbe197.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bbe197.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-795af5.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-795af5.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-795af5.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-8107e7.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-8107e7.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-8107e7.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-a8d64a.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-a8d64a.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-a8d64a.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d1a1dc.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d1a1dc.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/basic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d1a1dc.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/page.tsx deleted file mode 100644 index 7d99b29aef5ee..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/page.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import Test from './test' -import { unstable_cache } from 'next/cache' - -const getValue = unstable_cache(async () => Math.random(), [], { - revalidate: 60, -}) - -export default async function Page() { - return ( -
-
{await getValue()}
-
{await getValue()}
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/test.tsx deleted file mode 100644 index 22250c957f32d..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/app/test.tsx +++ /dev/null @@ -1,14 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('should cache with unstable_cache', () => { - let value1 = document.getElementById('value1').textContent - let value2 = document.getElementById('value2').textContent - expect(value1).toBe(value2) - expect(value1).not.toBe('') - }) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/next.config.js deleted file mode 100644 index cfa3ac3d7aa94..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/input/next.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - experimental: { - appDir: true, - }, -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-08276b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-08276b.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-08276b.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-423435.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-423435.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-423435.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-08bf86.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-08bf86.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-08bf86.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6b5c3b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6b5c3b.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6b5c3b.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1db8e4.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1db8e4.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1db8e4.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-9d675b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-9d675b.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/cache/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-9d675b.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx deleted file mode 100644 index 1b54d5f2e0a1a..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import Test from './test' - -export const dynamic = 'force-dynamic' - -export default function Page({ searchParams }) { - return ( -
-

{JSON.stringify(searchParams)}

- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx deleted file mode 100644 index 759722501f36c..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('should run', () => {}) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-1e6bd2.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-1e6bd2.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-1e6bd2.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-c3518b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-c3518b.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-c3518b.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b0350.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b0350.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b0350.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9d61ea.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9d61ea.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9d61ea.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48b6cc.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48b6cc.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48b6cc.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48fbac.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48fbac.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-48fbac.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/apple-icon.png b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/apple-icon.png deleted file mode 100644 index 7cbc1d2673361..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/apple-icon.png and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/favicon.ico b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/favicon.ico deleted file mode 100644 index 4965832f2c9b0..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/favicon.ico and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon1234.png b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon1234.png deleted file mode 100644 index c54f465b124a4..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon1234.png and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon234.png b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon234.png deleted file mode 100644 index e3b4277bf093d..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon234.png and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/manifest.webmanifest b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/manifest.webmanifest deleted file mode 100644 index f3e287945395b..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/manifest.webmanifest +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Next.js Static Manifest", - "short_name": "Next.js App", - "description": "Next.js App", - "start_url": "/", - "display": "standalone", - "background_color": "#fff", - "theme_color": "#fff" -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.alt.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.alt.txt deleted file mode 100644 index e07d9e8a67033..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.alt.txt +++ /dev/null @@ -1 +0,0 @@ -This is an alt text. \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.png b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.png deleted file mode 100644 index 7cbc1d2673361..0000000000000 Binary files a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/opengraph-image.png and /dev/null differ diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/robots.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/robots.txt deleted file mode 100644 index 0ad279c73692e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-Agent: * -Disallow: diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/sitemap.xml b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/sitemap.xml deleted file mode 100644 index 9d2b2deade0c4..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/sitemap.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - https://vercel.com/ - 2023-03-06T18:04:14.008Z - - diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/test.tsx deleted file mode 100644 index fbe8614d765ce..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/test.tsx +++ /dev/null @@ -1,84 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('should have the correct link tags', () => { - const links = Array.from(document.querySelectorAll('link')).filter( - (l) => l.rel !== 'preload' - ) - expect( - links.map((l) => ({ - href: l.getAttribute('href'), - rel: l.getAttribute('rel'), - sizes: l.getAttribute('sizes'), - })) - ).toEqual([ - expect.objectContaining({ - rel: 'manifest', - href: expect.stringMatching(/^\/manifest\.webmanifest$/), - sizes: null, - }), - expect.objectContaining({ - rel: 'icon', - href: expect.stringMatching(/^\/icon\d+\.png\?.+$/), - sizes: '32x32', - }), - expect.objectContaining({ - rel: 'icon', - href: expect.stringMatching(/^\/icon\d+\.png\?.+$/), - sizes: '64x64', - }), - expect.objectContaining({ - rel: 'apple-touch-icon', - href: expect.stringMatching(/^\/apple-icon\.png\?.+$/), - sizes: '114x114', - }), - ]) - }) - - it('should have the correct meta tags', () => { - const meta = Array.from(document.querySelectorAll('meta')) - const metaObject = Object.fromEntries( - meta - .filter((l) => l.getAttribute('property')) - .map((l) => [l.getAttribute('property'), l.getAttribute('content')]) - ) - expect(metaObject).toEqual({ - 'og:image': expect.stringMatching(/^.+\/opengraph-image\.png\?.+$/), - 'og:image:width': '114', - 'og:image:height': '114', - 'og:image:type': 'image/png', - 'og:image:alt': 'This is an alt text.', - }) - }) - - it('should provide a robots.txt', async () => { - const res = await fetch('/robots.txt') - expect(res.status).toBe(200) - expect(await res.text()).toBe('User-Agent: *\nDisallow:\n') - }) - - it('should provide a sitemap.xml', async () => { - const res = await fetch('/sitemap.xml') - expect(res.status).toBe(200) - expect(await res.text()).toBe( - ` - - - https://vercel.com/ - 2023-03-06T18:04:14.008Z - - -` - ) - }) - - it('should provide a favicon.ico', async () => { - const res = await fetch('/favicon.ico') - expect(res.status).toBe(200) - expect(res.headers.get('content-type')).toBe('image/x-icon') - }) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-30dfe3.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-30dfe3.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-30dfe3.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-dd8e93.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-dd8e93.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-dd8e93.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9e0a4d.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9e0a4d.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-9e0a4d.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-cc19c2.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-cc19c2.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-cc19c2.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e9606d.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e9606d.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e9606d.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-f910b2.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-f910b2.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-f910b2.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/page.tsx deleted file mode 100644 index 02a11ef0c0d2d..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { Test } from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/test.tsx deleted file mode 100644 index 27354d9b2d466..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/input/app/test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export function Test() { - useTestHarness(() => { - it('should allow to import a named export from a client component', () => {}) - }, []) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-a4d8c6.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-a4d8c6.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-a4d8c6.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e57b91.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e57b91.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e57b91.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5ee8eb.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5ee8eb.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5ee8eb.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-894c9c.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-894c9c.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-894c9c.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-007854.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-007854.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-007854.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e3b2ee.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e3b2ee.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/named-client-comp/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-e3b2ee.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/api/test/route.ts b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/api/test/route.ts deleted file mode 100644 index 2b923bc5f9e42..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/api/test/route.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { cookies } from 'next/headers' - -export async function GET(request: Request) { - const cookieStore = cookies() - const token = cookieStore.get('token')?.value ?? Math.random() - - return new Response(String(token), { - status: 200, - headers: { 'Set-Cookie': `token=${token}` }, - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/test.tsx deleted file mode 100644 index 47d9d1f16b92b..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/input/app/test.tsx +++ /dev/null @@ -1,18 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -function test() { - it('should handle cookies in Route request', async () => { - const first = await fetch('/api/test') - const text = await first.text() - expect(text).toMatch(/[\d.]+/) - - const second = await fetch('/api/test') - expect(await second.text()).toEqual(text) - }, 20000) -} - -export default function Test() { - useTestHarness(test) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-6aa55e.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-6aa55e.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-6aa55e.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bc6d9a.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bc6d9a.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-bc6d9a.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-0947c0.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-0947c0.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-0947c0.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ca71f4.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ca71f4.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ca71f4.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-16b505.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-16b505.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-16b505.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5e9551.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5e9551.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-627/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5e9551.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/.env b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/.env deleted file mode 100644 index f57df94426bc6..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/.env +++ /dev/null @@ -1 +0,0 @@ -FOOBAR="foobar" diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/[slug]/route.ts b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/[slug]/route.ts deleted file mode 100644 index af0aa5ab47a3a..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/[slug]/route.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NextResponse } from 'next/server' -import type { NextRequest } from 'next/server' - -export const helloHandler = async (_req: NextRequest): Promise => { - return NextResponse.json(process.env) -} - -export const GET = helloHandler diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/test.tsx deleted file mode 100644 index 57a57994c45d4..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/input/app/test.tsx +++ /dev/null @@ -1,15 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test() { - useTestHarness(() => { - it('includes ENV vars in route edge runner', async () => { - const res = await fetch('/route') - const json = await res.json() - expect(json).toMatchObject({ - FOOBAR: 'foobar', - }) - }, 20000) - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-0e650c.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-0e650c.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-0e650c.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-18f099.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-18f099.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-18f099.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6344fe.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6344fe.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-6344fe.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-e71678.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-e71678.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-e71678.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-181dae.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-181dae.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-181dae.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d3e5c8.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d3e5c8.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route-WEB-869/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-d3e5c8.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/[slug]/route.ts b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/[slug]/route.ts deleted file mode 100644 index 804e0f3dd14a0..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/[slug]/route.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { type NextRequest } from 'next/server' - -export const helloHandler = async ( - request: NextRequest, - { params }: { params?: Record } -): Promise => { - const { pathname } = request.nextUrl - - return new Response(`hello ${params?.slug}`, { - headers: { - method: request.method, - pathname, - }, - }) -} - -export const GET = helloHandler -export const HEAD = helloHandler -export const OPTIONS = helloHandler -export const POST = helloHandler -export const PUT = helloHandler -export const DELETE = helloHandler -export const PATCH = helloHandler - -export const runtime = 'experimental-edge' diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/api/crypto/route.ts b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/api/crypto/route.ts deleted file mode 100644 index cd3bc88c1b72a..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/api/crypto/route.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { NextResponse } from 'next/server' -import { generateKey } from 'crypto' -import { promisify } from 'util' - -const generate = promisify(generateKey) - -export async function GET(): Promise { - const key = await generate('hmac', { length: 64 }) - - return NextResponse.json({ data: key.type }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/layout.tsx deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RootLayout({ children }: { children: any }) { - return ( - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/page.tsx deleted file mode 100644 index 2deb30edb528f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Test from './test' - -export default function Page() { - return ( -
- -
- ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/test.tsx deleted file mode 100644 index 942610e02c7f6..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/input/app/test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -function test() { - it('should make a GET request', async () => { - const res = await fetch('/world') - const text = await res.text() - expect(text).toEqual('hello world') - expect(res.headers.get('method')).toEqual('GET') - }, 20000) - - it('should make a POST request', async () => { - const res = await fetch('/route.js', { - method: 'POST', - }) - const text = await res.text() - expect(text).toEqual('hello route.js') - expect(res.headers.get('method')).toEqual('POST') - }, 20000) - - it('should make a GET request to /api/crypto which should support node builtins', async () => { - const res = await fetch('/api/crypto') - const text = await res.text() - expect(text).toEqual('{"data":"secret"}') - }, 20000) -} - -export default function Test() { - useTestHarness(() => test()) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2aa45d.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2aa45d.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-2aa45d.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e68187.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e68187.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-e68187.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b60e1.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b60e1.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-5b60e1.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-726667.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-726667.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-726667.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1938da.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1938da.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1938da.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ff63b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ff63b.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/route/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ff63b.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/app/page.jsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/app/page.jsx deleted file mode 100755 index 7e005c0b16c25..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/app/page.jsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Home() { - return 'app' -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/layout.jsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/layout.jsx deleted file mode 100755 index 89f94ddde951f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/layout.jsx +++ /dev/null @@ -1,8 +0,0 @@ -export default function RootLayout({ children }) { - return ( - - - {children} - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/page.jsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/page.jsx deleted file mode 100755 index b76809f60cf05..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/input/src/app/page.jsx +++ /dev/null @@ -1,47 +0,0 @@ -'use client' - -import { useEffect } from 'react' -import { RSC_VARY_HEADER } from 'next/dist/client/components/app-router-headers' -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Home() { - useTestHarness(runTests) - return 'index' -} - -function runTests() { - it('should include RSC vary for app route', async () => { - const res = await fetch('/app') - - expect(res.headers.get('vary')).toBe(RSC_VARY_HEADER) - - const text = await res.text() - expect(text).toContain(' { - const res = await fetch('/app', { - headers: { - RSC: 1, - }, - }) - - expect(res.headers.get('vary')).toBe(RSC_VARY_HEADER) - - const text = await res.text() - expect(text).not.toContain(' { - const res = await fetch('/page') - - const vary = res.headers.get('vary') || '' - expect(vary.split(/\s*,\s*/g)).not.toContain('RSC') - - const text = await res.text() - expect(text).toContain('_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f7d479.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f7d479.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-f7d479.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-c41869.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-c41869.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-c41869.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ea04f0.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ea04f0.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-ea04f0.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5c2d9d.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5c2d9d.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-5c2d9d.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-61ac8b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-61ac8b.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/rsc-NEXT-657/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-61ac8b.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file 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 deleted file mode 100644 index 41a47cf25dfde..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx +++ /dev/null @@ -1,5 +0,0 @@ -'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 deleted file mode 100644 index 12c84680889be..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 1ebdc1d7496c3..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 2d92effd8aa07..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.tsx +++ /dev/null @@ -1,20 +0,0 @@ -'use client' - -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Test({ action }) { - useTestHarness(() => { - 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/ - ) - }) - }) -} 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 -865a1b.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not -865a1b.txt deleted file mode 100644 index 540e052b34a95..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not -865a1b.txt +++ /dev/null @@ -1 +0,0 @@ -error - [unsupported] [project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/app/use-server/input/app/action.tsx Server actions ("use server") are not yet supported in Turbopack \ No newline at end of file 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 -ba6be3.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not -ba6be3.txt deleted file mode 100644 index 540e052b34a95..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/Server actions (__quo__use server__quo__) are not -ba6be3.txt +++ /dev/null @@ -1 +0,0 @@ -error - [unsupported] [project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/app/use-server/input/app/action.tsx Server actions ("use server") are not yet supported in Turbopack \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-56286f.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-56286f.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-56286f.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-be8bd7.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-be8bd7.txt deleted file mode 100644 index cb668aa67930e..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFile(__q____q____q____star__0__-be8bd7.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:18:19 lint TP1004 fs.readFile(???*0*) is very dynamic - 14 | default: obj - 15 | }; - 16 | } - 17 | const nodeFs = { - + v - 18 + readFile: (f)=>_fs.default.promises.readFile(f), - + ^ - 19 | readFileSync: (f)=>_fs.default.readFileSync(f), - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-36829a.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-36829a.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-36829a.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-fc1949.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-fc1949.txt deleted file mode 100644 index e7d760c7e4242..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-fc1949.txt +++ /dev/null @@ -1,15 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:19:23 lint TP1004 fs.readFileSync(???*0*) is very dynamic - 15 | }; - 16 | } - 17 | const nodeFs = { - 18 | readFile: (f)=>_fs.default.promises.readFile(f), - + v - 19 + readFileSync: (f)=>_fs.default.readFileSync(f), - + ^ - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ac6a0.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ac6a0.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-1ac6a0.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-c835a4.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-c835a4.txt deleted file mode 100644 index 0d33591b07a5f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/issues/lint TP1004 fs.stat(__q____q____q____star__0__star-c835a4.txt +++ /dev/null @@ -1,14 +0,0 @@ -warning - [parse] [project]/packages/next/dist/server/lib/node-fs-methods.js /packages/next/dist/server/lib/node-fs-methods.js:24:15 lint TP1004 fs.stat(???*0*) is very dynamic - 20 | writeFile: (f, d)=>_fs.default.promises.writeFile(f, d), - 21 | mkdir: (dir)=>_fs.default.promises.mkdir(dir, { - 22 | recursive: true - 23 | }), - + v - 24 + stat: (f)=>_fs.default.promises.stat(f) - + ^ - 25 | }; - 26 | - 27 | //# sourceMappingURL=node-fs-methods.js.map - - - *0* f - ⚠️ pattern without value \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/index.js deleted file mode 100644 index 0295dbf912890..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { named } from './module.js' - -function Fun({ value = named }) { - return value -} - -it('support imports in default arguments', () => { - expect(Fun({})).toBe('named') -}) diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/module.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/module.js deleted file mode 100644 index 102e13c46ae82..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/default-args/input/module.js +++ /dev/null @@ -1 +0,0 @@ -export const named = 'named' diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/module.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/module.tsx deleted file mode 100644 index 752d8aaa4a00f..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/module.tsx +++ /dev/null @@ -1 +0,0 @@ -export const Named = ({ children }) =>
{children}
diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/pages/index.js deleted file mode 100644 index a1072dc99e1f6..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/jsx-member/input/pages/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import { useTestHarness } from '@turbo/pack-test-harness' -import * as Named from '../module.tsx' - -export default function Page() { - useTestHarness(runTests) - - const object = { Named: Named.Named } - const object2 = { Named } - - return ( - <> - Hello World - Hello There - Hello You - - ) -} - -function runTests() { - it('should render the element', () => { - const html = document.body.innerHTML - expect(html).toContain('Hello World') - expect(html).toContain('Hello There') - expect(html).toContain('Hello You') - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/swc-helpers/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/swc-helpers/input/pages/index.js deleted file mode 100644 index ef59fffa89217..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/basic/swc-helpers/input/pages/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function Page() { - useTestHarness(runTests) - - const props1 = { className: 'foo' } - const props2 = { style: { color: 'red' } } - // this will require the `_extends` helper on SSR - return ( -
- Hello World -
- ) -} - -function runTests() { - it('should render the #test element in red and with class foo', () => { - const el = document.getElementById('test') - expect(el.style.color).toBe('red') - expect(el.className).toBe('foo') - }) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic1.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic1.js deleted file mode 100644 index 7e5600be4fcd0..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic1.js +++ /dev/null @@ -1 +0,0 @@ -import '../styles/dynamic1.css' diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic2.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic2.js deleted file mode 100644 index 986a69edb3f2c..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/lib/dynamic2.js +++ /dev/null @@ -1 +0,0 @@ -import '../styles/dynamic2.css' diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/a.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/a.tsx deleted file mode 100644 index aa1c00a50d9d8..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/a.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import Link from 'next/link' -import '@/styles/a.css' -import { useEffect } from 'react' -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function A() { - useTestHarness((harness) => { - harness.markAsHydrated() - }) - - useEffect(() => { - globalThis.DYNAMIC_IMPORT1 = () => import('../lib/dynamic1.js') - globalThis.DYNAMIC_IMPORT2 = () => import('../lib/dynamic2.js') - }) - - return ( - <> - - B - - - - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/b.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/b.tsx deleted file mode 100644 index c8d574f6174f6..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/b.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import Link from 'next/link' -import '@/styles/b.css' -import { useTestHarness } from '@turbo/pack-test-harness' - -export default function B() { - useTestHarness((harness) => harness.markAsHydrated()) - - return ( - <> - - A - - - ) -} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/index.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/index.tsx deleted file mode 100644 index b645dc958e061..0000000000000 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/css/deduplication/input/pages/index.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { useRef } from 'react' -import { Harness, useTestHarness } from '@turbo/pack-test-harness' - -export default function Page() { - const iframeRef = useRef(null) - - useTestHarness((harness) => runTests(harness, iframeRef.current!)) - - return ( - <> -