From fa9c6021b4894356323a5d3f4997c0251f9c8b75 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Tue, 23 May 2023 11:17:35 +0000 Subject: [PATCH 01/15] v13.4.4-canary.3 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 +-- packages/eslint-plugin-next/package.json | 2 +- packages/font/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++----- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 29 ++++++++++++++------ 17 files changed, 44 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index fcf5ef1ec343a..a2bf314e6e1a7 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "13.4.4-canary.2" + "version": "13.4.4-canary.3" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index a766312f6e44e..d73b1d273730d 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 83dbacf2d68d0..615f465c91430 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "13.4.4-canary.2", + "@next/eslint-plugin-next": "13.4.4-canary.3", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.42.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index c594f190813cf..1d89fc74f0bcd 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "ESLint plugin for NextJS.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 50903444738b0..5ab27da65acd2 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 944301efcedbe..9453813e8cf1f 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 65fd0dd9b7ffa..a114970accb85 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index a32d1296cec8a..57e0612c79ecf 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index d27203dd7c51b..2a92a4dec4fbd 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 83bee0d9ed191..a903d1eec0982 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 8d2a761179d54..b09f3b87d8980 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index eaef98f162ea4..5bafba0c19db7 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 9f6c947f7981c..23d8da83a065a 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index 7ba63fb4950ad..7ea3a1c733952 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@next/env": "13.4.4-canary.2", + "@next/env": "13.4.4-canary.3", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -139,11 +139,11 @@ "@jest/types": "29.5.0", "@napi-rs/cli": "2.14.7", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "13.4.4-canary.2", - "@next/polyfill-nomodule": "13.4.4-canary.2", - "@next/react-dev-overlay": "13.4.4-canary.2", - "@next/react-refresh-utils": "13.4.4-canary.2", - "@next/swc": "13.4.4-canary.2", + "@next/polyfill-module": "13.4.4-canary.3", + "@next/polyfill-nomodule": "13.4.4-canary.3", + "@next/react-dev-overlay": "13.4.4-canary.3", + "@next/react-refresh-utils": "13.4.4-canary.3", + "@next/swc": "13.4.4-canary.3", "@opentelemetry/api": "1.4.1", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index d269b8bec9cf8..8ba17e92aa2ef 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 3d9e5566e94b7..cac52765e4a98 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "13.4.4-canary.2", + "version": "13.4.4-canary.3", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9932b91efbcda..2d84871787150 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -460,7 +460,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 13.4.4-canary.2 + '@next/eslint-plugin-next': 13.4.4-canary.3 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.42.0 eslint: ^7.23.0 || ^8.0.0 @@ -536,12 +536,12 @@ importers: '@jest/types': 29.5.0 '@napi-rs/cli': 2.14.7 '@napi-rs/triples': 1.1.0 - '@next/env': 13.4.4-canary.2 - '@next/polyfill-module': 13.4.4-canary.2 - '@next/polyfill-nomodule': 13.4.4-canary.2 - '@next/react-dev-overlay': 13.4.4-canary.2 - '@next/react-refresh-utils': 13.4.4-canary.2 - '@next/swc': 13.4.4-canary.2 + '@next/env': 13.4.4-canary.3 + '@next/polyfill-module': 13.4.4-canary.3 + '@next/polyfill-nomodule': 13.4.4-canary.3 + '@next/react-dev-overlay': 13.4.4-canary.3 + '@next/react-refresh-utils': 13.4.4-canary.3 + '@next/swc': 13.4.4-canary.3 '@opentelemetry/api': 1.4.1 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.5.1 @@ -5997,7 +5997,7 @@ packages: dependencies: '@mdx-js/mdx': 2.2.1 source-map: 0.7.3 - webpack: 5.74.0_@swc+core@1.3.55 + webpack: 5.74.0 transitivePeerDependencies: - supports-color @@ -6669,6 +6669,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: true optional: true /@swc/core-darwin-x64/1.3.55: @@ -6677,6 +6678,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm-gnueabihf/1.3.55: @@ -6685,6 +6687,7 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm64-gnu/1.3.55: @@ -6693,6 +6696,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm64-musl/1.3.55: @@ -6701,6 +6705,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-x64-gnu/1.3.55: @@ -6709,6 +6714,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-x64-musl/1.3.55: @@ -6717,6 +6723,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-win32-arm64-msvc/1.3.55: @@ -6725,6 +6732,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core-win32-ia32-msvc/1.3.55: @@ -6733,6 +6741,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core-win32-x64-msvc/1.3.55: @@ -6741,6 +6750,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core/1.3.55_@swc+helpers@0.5.1: @@ -6765,6 +6775,7 @@ packages: '@swc/core-win32-arm64-msvc': 1.3.55 '@swc/core-win32-ia32-msvc': 1.3.55 '@swc/core-win32-x64-msvc': 1.3.55 + dev: true /@swc/helpers/0.4.14: resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} @@ -23658,6 +23669,7 @@ packages: source-map: 0.6.1 terser: 5.14.1 webpack: 5.74.0_@swc+core@1.3.55 + dev: true /terser-webpack-plugin/5.2.4_webpack@5.74.0: resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==} @@ -25067,6 +25079,7 @@ packages: - '@swc/core' - esbuild - uglify-js + dev: true /websocket-driver/0.7.3: resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==} From 03d6dcc08de9509ec0a19b760ec9b2a606ff551e Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 23 May 2023 13:41:01 +0200 Subject: [PATCH 02/15] Move debugging variable into useEffect (#50210) ## What? Ensures the debugging variables are only assigned when the values change. --- .../next/src/client/components/app-router.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/next/src/client/components/app-router.tsx b/packages/next/src/client/components/app-router.tsx index 3a2ffa604a9b4..b10ac6c52a105 100644 --- a/packages/next/src/client/components/app-router.tsx +++ b/packages/next/src/client/components/app-router.tsx @@ -331,9 +331,16 @@ function Router({ return routerInstance }, [dispatch, navigate]) - // Add `window.nd` for debugging purposes. - // This is not meant for use in applications as concurrent rendering will affect the cache/tree/router. - if (typeof window !== 'undefined') { + useEffect(() => { + // Exists for debugging purposes. Don't use in application code. + if (window.next) { + window.next.router = appRouter + } + }, [appRouter]) + + useEffect(() => { + // Add `window.nd` for debugging purposes. + // This is not meant for use in applications as concurrent rendering will affect the cache/tree/router. // @ts-ignore this is for debugging window.nd = { router: appRouter, @@ -341,7 +348,7 @@ function Router({ prefetchCache, tree, } - } + }, [appRouter, cache, prefetchCache, tree]) // When mpaNavigation flag is set do a hard navigation to the new url. // Infinitely suspend because we don't actually want to rerender any child From ad79fed1a2c2e6e66d54bb8fd95947c4edf8f271 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 23 May 2023 16:29:58 +0200 Subject: [PATCH 03/15] ci: update github token (#50216) [slack-thread](https://vercel.slack.com/archives/C01LN7C5QR5/p1684849596794369?thread_ts=1684428058.764599&cid=C01LN7C5QR5) --- .github/workflows/trigger_release.yml | 4 ++-- scripts/start-release.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index db2d63a9ac242..6292167adc81e 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -18,7 +18,7 @@ on: - major secrets: - RELEASE_BOT_TOKEN: + RELEASE_BOT_GITHUB_TOKEN: required: true name: Trigger Release @@ -78,4 +78,4 @@ jobs: - run: node ./scripts/start-release.js --release-type ${{ github.event.inputs.releaseType }} --semver-type ${{ github.event.inputs.semverType }} env: - RELEASE_BOT_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }} + RELEASE_BOT_GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} diff --git a/scripts/start-release.js b/scripts/start-release.js index fca82adf1bb96..23e06fbde8072 100644 --- a/scripts/start-release.js +++ b/scripts/start-release.js @@ -95,10 +95,10 @@ async function main() { return } - const githubToken = process.env.RELEASE_BOT_TOKEN + const githubToken = process.env.RELEASE_BOT_GITHUB_TOKEN if (!githubToken) { - console.log(`Missing RELEASE_BOT_TOKEN`) + console.log(`Missing RELEASE_BOT_GITHUB_TOKEN`) return } From 3d40cb01ab8689aa5944d9c62445de4ef503175e Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 23 May 2023 17:21:25 +0200 Subject: [PATCH 04/15] refactor webpack loaders (#49535) ### What? * allow to apply existing pipeline * change webpack loader key to glob for more flexibility * add test cases * add special error message when using the old config syntax Old config: ```js experimental: { turbo: { loaders: { ".mdx": ["mdx-loader"] } } } ``` New config ``` js experimental: { turbo: { rules: { // key is a glob now // normal syntax will treat the result as ecmascript code "*.mdx": ["mdx-loader"], // glob allows more advanced matching "./images/**/*.png": { loaders: ["image-optimize-loader"], // result of loader will be handled in other steps // under the same name/path (here .png) // This will use the existing .png pipeline (static asset) // It might also use other rules matching .png. as: "*" }, "*.generate-image.js": { loaders: ["image-generation-loader"], // It also possible to pass this under a different name // into the pipeline. Here it will treat the result as png image as: "*.png" } } } } ``` ### Why? More flexibility and allowing to use the builtin module handling over non-js types. fixes WEB-1009 ### Turbopack changes * https://github.com/vercel/turbo/pull/4955 * https://github.com/vercel/turbo/pull/4880 --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .prettierignore | 2 + Cargo.lock | 69 +++++---- Cargo.toml | 6 +- .../next-swc/crates/next-core/js/package.json | 4 +- .../next-swc/crates/next-core/src/babel.rs | 85 ++++++----- .../next-core/src/next_client/context.rs | 20 +-- .../crates/next-core/src/next_config.rs | 140 +++++++++++++++--- .../next-core/src/next_server/context.rs | 20 +-- .../next-swc/crates/next-core/src/sass.rs | 54 ++++--- .../webpack-loaders/input/next.config.js | 11 ++ .../webpack-loaders/input/pages/index.js | 11 ++ ....turbo.loaders__quo__ has been -391244.txt | 21 +++ .../basic-options/input/next.config.js | 4 +- .../emitted-errors/input/next.config.js | 4 +- .../no-options/input/next.config.js | 13 +- .../node_modules/raw-as-json-loader/index.js | 3 + .../no-options/input/pages/hello.jraw | 1 + .../no-options/input/pages/hello.raw.js | 1 + .../no-options/input/pages/hello.raw.raw | 1 + .../no-options/input/pages/index.js | 20 ++- .../no-options/input/raw/hello.js | 1 + pnpm-lock.yaml | 18 +-- 22 files changed, 346 insertions(+), 163 deletions(-) create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/next.config.js create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/pages/index.js create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/issues/__quo__experimental.turbo.loaders__quo__ has been -391244.txt create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/node_modules/raw-as-json-loader/index.js create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.jraw create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.js create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.raw create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/raw/hello.js diff --git a/.prettierignore b/.prettierignore index edcab939ce4c2..baf4892dfbfbb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -22,6 +22,8 @@ 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 6b1e97ab484f8..3e7b985674d0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "serde", ] @@ -3424,7 +3424,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "serde", @@ -7034,7 +7034,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "auto-hash-map", @@ -7065,7 +7065,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "cargo-lock", @@ -7077,7 +7077,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "bytes", @@ -7092,7 +7092,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "dotenvy", @@ -7106,7 +7106,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "indexmap", @@ -7123,7 +7123,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "auto-hash-map", @@ -7153,7 +7153,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "base16", "hex", @@ -7165,7 +7165,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7179,7 +7179,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "proc-macro2", "quote", @@ -7189,7 +7189,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "mimalloc", ] @@ -7197,7 +7197,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "auto-hash-map", @@ -7220,7 +7220,7 @@ dependencies = [ [[package]] name = "turbo-tasks-testing" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "auto-hash-map", @@ -7232,7 +7232,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-recursion", @@ -7262,7 +7262,7 @@ dependencies = [ [[package]] name = "turbopack-bench" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "chromiumoxide", @@ -7292,7 +7292,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "auto-hash-map", "mdxjs", @@ -7332,7 +7332,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "clap 4.1.11", @@ -7356,7 +7356,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-trait", @@ -7384,7 +7384,7 @@ dependencies = [ [[package]] name = "turbopack-create-test-app" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "clap 4.1.11", @@ -7397,7 +7397,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-trait", @@ -7419,7 +7419,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "indexmap", @@ -7441,7 +7441,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-compression", @@ -7476,7 +7476,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-trait", @@ -7494,10 +7494,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "styled_components", - "styled_jsx", "swc_core", - "swc_emotion", "tokio", "tracing", "turbo-tasks", @@ -7512,7 +7509,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-trait", @@ -7533,7 +7530,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "indexmap", @@ -7549,7 +7546,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "base64 0.21.0", @@ -7569,7 +7566,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "serde", @@ -7584,7 +7581,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "mdxjs", @@ -7599,7 +7596,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "async-stream", @@ -7634,7 +7631,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "serde", @@ -7650,7 +7647,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "swc_core", "turbo-tasks", @@ -7661,7 +7658,7 @@ dependencies = [ [[package]] name = "turbopack-test-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230522.2#cee02be048d8f402f1ad50dd2b8589cacd9ae910" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" dependencies = [ "anyhow", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index f79c49e6f831d..834d31aaa4302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,11 +42,11 @@ swc_core = { version = "0.76.18" } testing = { version = "0.33.11" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230522.2" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. -turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230522.2" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230522.2" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } # General Deps diff --git a/packages/next-swc/crates/next-core/js/package.json b/packages/next-swc/crates/next-core/js/package.json index e12d22bb4b853..a7e775934c7fd 100644 --- a/packages/next-swc/crates/next-core/js/package.json +++ b/packages/next-swc/crates/next-core/js/package.json @@ -10,8 +10,8 @@ "check": "tsc --noEmit" }, "dependencies": { - "@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2", - "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230522.2", + "@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2", + "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2", "anser": "^2.1.1", "css.escape": "^1.5.1", "next": "*", diff --git a/packages/next-swc/crates/next-core/src/babel.rs b/packages/next-swc/crates/next-core/src/babel.rs index 18805f600ceec..73f89f0e7c8fd 100644 --- a/packages/next-swc/crates/next-core/src/babel.rs +++ b/packages/next-swc/crates/next-core/src/babel.rs @@ -10,9 +10,10 @@ use turbopack_binding::{ issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc}, resolve::{parse::RequestVc, pattern::Pattern, resolve}, }, - node::transforms::webpack::{WebpackLoaderConfigItem, WebpackLoaderConfigItemsVc}, + node::transforms::webpack::{WebpackLoaderItem, WebpackLoaderItemsVc}, turbopack::{ - module_options::WebpackLoadersOptionsVc, resolve_options, + module_options::{LoaderRuleItem, OptionWebpackRulesVc, WebpackRulesVc}, + resolve_options, resolve_options_context::ResolveOptionsContext, }, }, @@ -36,8 +37,8 @@ const BABEL_CONFIG_FILES: &[&str] = &[ #[turbo_tasks::function] pub async fn maybe_add_babel_loader( project_root: FileSystemPathVc, - webpack_options: WebpackLoadersOptionsVc, -) -> Result { + webpack_rules: Option, +) -> Result { let has_babel_config = { let mut has_babel_config = false; for filename in BABEL_CONFIG_FILES { @@ -51,30 +52,22 @@ pub async fn maybe_add_babel_loader( }; if has_babel_config { - let mut options = (*webpack_options.await?).clone(); + let mut rules = if let Some(webpack_rules) = webpack_rules { + webpack_rules.await?.clone_value() + } else { + Default::default() + }; let mut has_emitted_babel_resolve_issue = false; - for ext in [".js", ".jsx", ".ts", ".tsx", ".cjs", ".mjs"] { - let configs = options.extension_to_loaders.get(ext); - let has_babel_loader = match configs { - None => false, - Some(configs) => { - let mut has_babel_loader = false; - for config in &*configs.await? { - let name = match config { - WebpackLoaderConfigItem::LoaderName(name) => name, - WebpackLoaderConfigItem::LoaderNameWithOptions { - loader: name, - options: _, - } => name, - }; - - if name == "babel-loader" { - has_babel_loader = true; - break; - } - } - has_babel_loader - } + let mut has_changed = false; + for pattern in ["*.js", "*.jsx", "*.ts", "*.tsx", "*.cjs", "*.mjs"] { + let rule = rules.get_mut(pattern); + let has_babel_loader = if let Some(rule) = rule.as_ref() { + rule.loaders + .await? + .iter() + .any(|c| c.loader == "babel-loader") + } else { + false }; if !has_babel_loader { @@ -100,24 +93,34 @@ pub async fn maybe_add_babel_loader( has_emitted_babel_resolve_issue = true; } - let loader = WebpackLoaderConfigItem::LoaderName("babel-loader".to_owned()); - options.extension_to_loaders.insert( - ext.to_owned(), - if options.extension_to_loaders.contains_key(ext) { - let mut new_configs = (*(options.extension_to_loaders[ext].await?)).clone(); - new_configs.push(loader); - WebpackLoaderConfigItemsVc::cell(new_configs) - } else { - WebpackLoaderConfigItemsVc::cell(vec![loader]) - }, - ); + let loader = WebpackLoaderItem { + loader: "babel-loader".to_string(), + options: Default::default(), + }; + if let Some(rule) = rule { + let mut loaders = rule.loaders.await?.clone_value(); + loaders.push(loader); + rule.loaders = WebpackLoaderItemsVc::cell(loaders); + } else { + rules.insert( + pattern.to_string(), + LoaderRuleItem { + loaders: WebpackLoaderItemsVc::cell(vec![loader]), + rename_as: Some("*".to_string()), + }, + ); + } + has_changed = true; } } - Ok(options.cell()) - } else { - Ok(webpack_options) + if has_changed { + return Ok(OptionWebpackRulesVc::cell(Some(WebpackRulesVc::cell( + rules, + )))); + } } + Ok(OptionWebpackRulesVc::cell(webpack_rules)) } #[turbo_tasks::function] diff --git a/packages/next-swc/crates/next-core/src/next_client/context.rs b/packages/next-swc/crates/next-core/src/next_client/context.rs index 34259022be95f..19ee91d71ed72 100644 --- a/packages/next-swc/crates/next-core/src/next_client/context.rs +++ b/packages/next-swc/crates/next-core/src/next_client/context.rs @@ -195,22 +195,18 @@ pub async fn get_client_module_options_context( }; let jsx_runtime_options = get_jsx_transform_options(project_path, mode, Some(resolve_options_context)); - let enable_webpack_loaders = { - let options = &*next_config.webpack_loaders_options().await?; - let loaders_options = WebpackLoadersOptions { - extension_to_loaders: options.clone(), + let webpack_rules = + *maybe_add_babel_loader(project_path, *next_config.webpack_rules().await?).await?; + let webpack_rules = maybe_add_sass_loader(next_config.sass_config(), webpack_rules).await?; + let enable_webpack_loaders = webpack_rules.map(|rules| { + WebpackLoadersOptions { + rules, loader_runner_package: Some(get_external_next_compiled_package_mapping( StringVc::cell("loader-runner".to_owned()), )), - ..Default::default() } - .cell(); - - let loaders_options = maybe_add_babel_loader(project_path, loaders_options); - maybe_add_sass_loader(next_config.sass_config(), loaders_options) - .await? - .clone_if() - }; + .cell() + }); let source_transforms = vec![ *get_relay_transform_plugin(next_config).await?, diff --git a/packages/next-swc/crates/next-core/src/next_config.rs b/packages/next-swc/crates/next-core/src/next_config.rs index ff0b5a8e8ce3b..6e23aefb6f32c 100644 --- a/packages/next-swc/crates/next-core/src/next_config.rs +++ b/packages/next-swc/crates/next-core/src/next_config.rs @@ -3,7 +3,7 @@ use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; use turbo_tasks::{ - primitives::{BoolVc, JsonValueVc, StringsVc}, + primitives::{BoolVc, JsonValueVc, StringVc, StringsVc}, trace::TraceRawVcs, CompletionVc, Value, }; @@ -17,7 +17,7 @@ use turbopack_binding::{ chunk::ChunkingContext, context::AssetContext, ident::AssetIdentVc, - issue::IssueContextExt, + issue::{Issue, IssueContextExt, IssueSeverity, IssueSeverityVc, IssueVc}, reference_type::{EntryReferenceSubType, ReferenceType}, resolve::{ find_context_file, @@ -36,9 +36,12 @@ use turbopack_binding::{ node::{ evaluate::evaluate, execution_context::{ExecutionContext, ExecutionContextVc}, - transforms::webpack::{WebpackLoaderConfigItems, WebpackLoaderConfigItemsVc}, + transforms::webpack::{WebpackLoaderItem, WebpackLoaderItemsVc}, + }, + turbopack::{ + evaluate_context::node_evaluate_asset_context, + module_options::{LoaderRuleItem, OptionWebpackRulesVc, WebpackRulesVc}, }, - turbopack::evaluate_context::node_evaluate_asset_context, }, }; @@ -352,10 +355,30 @@ pub enum RemotePatternProtocal { #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, TraceRawVcs)] #[serde(rename_all = "camelCase")] pub struct ExperimentalTurboConfig { - pub loaders: Option>, + /// This option has been replace by `rules`. + pub loaders: Option, + pub rules: Option>, pub resolve_alias: Option>, } +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)] +#[serde(rename_all = "camelCase", untagged)] +pub enum RuleConfigItem { + Loaders(Vec), + Options { + loaders: Vec, + #[serde(default, alias = "as")] + rename_as: Option, + }, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)] +#[serde(untagged)] +pub enum LoaderItem { + LoaderName(String), + LoaderOptions(WebpackLoaderItem), +} + #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, TraceRawVcs)] #[serde(rename_all = "camelCase")] pub struct ExperimentalConfig { @@ -461,10 +484,6 @@ pub enum RemoveConsoleConfig { Config { exclude: Option> }, } -#[derive(Default)] -#[turbo_tasks::value(transparent)] -pub struct WebpackExtensionToLoaders(IndexMap); - #[turbo_tasks::value_impl] impl NextConfigVc { #[turbo_tasks::function] @@ -539,19 +558,46 @@ impl NextConfigVc { } #[turbo_tasks::function] - pub async fn webpack_loaders_options(self) -> Result { + pub async fn webpack_rules(self) -> Result { let this = self.await?; - let Some(turbo_loaders) = this.experimental.turbo.as_ref().and_then(|t| t.loaders.as_ref()) else { - return Ok(WebpackExtensionToLoadersVc::cell(IndexMap::new())); + let Some(turbo_rules) = this.experimental.turbo.as_ref().and_then(|t| t.rules.as_ref()) else { + return Ok(OptionWebpackRulesVc::cell(None)); }; - let mut extension_to_loaders = IndexMap::new(); - for (ext, loaders) in turbo_loaders { - extension_to_loaders.insert( - ext.clone(), - WebpackLoaderConfigItemsVc::cell(loaders.0.clone()), - ); + if turbo_rules.is_empty() { + return Ok(OptionWebpackRulesVc::cell(None)); + } + let mut rules = IndexMap::new(); + for (ext, rule) in turbo_rules { + fn transform_loaders(loaders: &[LoaderItem]) -> WebpackLoaderItemsVc { + WebpackLoaderItemsVc::cell( + loaders + .iter() + .map(|item| match item { + LoaderItem::LoaderName(name) => WebpackLoaderItem { + loader: name.clone(), + options: Default::default(), + }, + LoaderItem::LoaderOptions(options) => options.clone(), + }) + .collect(), + ) + } + let rule = match rule { + RuleConfigItem::Loaders(loaders) => LoaderRuleItem { + loaders: transform_loaders(loaders), + rename_as: None, + }, + RuleConfigItem::Options { loaders, rename_as } => LoaderRuleItem { + loaders: transform_loaders(loaders), + rename_as: rename_as.clone(), + }, + }; + + rules.insert(ext.clone(), rule); } - Ok(WebpackExtensionToLoaders(extension_to_loaders).cell()) + Ok(OptionWebpackRulesVc::cell(Some(WebpackRulesVc::cell( + rules, + )))) } #[turbo_tasks::function] @@ -658,6 +704,23 @@ pub async fn load_next_config_internal( }; let next_config: NextConfig = parse_json_with_source_context(val.to_str()?)?; + if let Some(turbo) = next_config.experimental.turbo.as_ref() { + if turbo.loaders.is_some() { + OutdatedConfigIssue { + path: config_file.unwrap_or(project_path), + old_name: "experimental.turbo.loaders".to_string(), + new_name: "experimental.turbo.rules".to_string(), + description: "The new option is similar, but the key should be a glob instead of \ + an extension. +Example: loaders: { \".mdx\": [\"mdx-loader\"] } -> rules: { \"*.mdx\": [\"mdx-loader\"] }" + .to_string(), + } + .cell() + .as_issue() + .emit() + } + } + Ok(next_config.cell()) } @@ -668,3 +731,42 @@ pub async fn has_next_config(context: FileSystemPathVc) -> Result { FindContextFileResult::NotFound(_) ))) } + +#[turbo_tasks::value] +struct OutdatedConfigIssue { + path: FileSystemPathVc, + old_name: String, + new_name: String, + description: String, +} + +#[turbo_tasks::value_impl] +impl Issue for OutdatedConfigIssue { + #[turbo_tasks::function] + fn severity(&self) -> IssueSeverityVc { + IssueSeverity::Error.into() + } + + #[turbo_tasks::function] + fn category(&self) -> StringVc { + StringVc::cell("config".to_string()) + } + + #[turbo_tasks::function] + fn context(&self) -> FileSystemPathVc { + self.path + } + + #[turbo_tasks::function] + fn title(&self) -> StringVc { + StringVc::cell(format!( + "\"{}\" has been replaced by \"{}\"", + self.old_name, self.new_name + )) + } + + #[turbo_tasks::function] + fn description(&self) -> StringVc { + StringVc::cell(self.description.to_string()) + } +} diff --git a/packages/next-swc/crates/next-core/src/next_server/context.rs b/packages/next-swc/crates/next-core/src/next_server/context.rs index 2b33db3c8b793..beedcb31a7fee 100644 --- a/packages/next-swc/crates/next-core/src/next_server/context.rs +++ b/packages/next-swc/crates/next-core/src/next_server/context.rs @@ -284,22 +284,18 @@ pub async fn get_server_module_options_context( ..Default::default() }); - let enable_webpack_loaders = { - let options = &*next_config.webpack_loaders_options().await?; - let loaders_options = WebpackLoadersOptions { - extension_to_loaders: options.clone(), + let webpack_rules = + *maybe_add_babel_loader(project_path, *next_config.webpack_rules().await?).await?; + let webpack_rules = maybe_add_sass_loader(next_config.sass_config(), webpack_rules).await?; + let enable_webpack_loaders = webpack_rules.map(|rules| { + WebpackLoadersOptions { + rules, loader_runner_package: Some(get_external_next_compiled_package_mapping( StringVc::cell("loader-runner".to_owned()), )), - ..Default::default() } - .cell(); - - let loaders_options = maybe_add_babel_loader(project_path, loaders_options); - maybe_add_sass_loader(next_config.sass_config(), loaders_options) - .await? - .clone_if() - }; + .cell() + }); // EcmascriptTransformPlugins for custom transforms let styled_components_transform_plugin = diff --git a/packages/next-swc/crates/next-core/src/sass.rs b/packages/next-swc/crates/next-core/src/sass.rs index dc94291c83ff4..dbd4ee861975e 100644 --- a/packages/next-swc/crates/next-core/src/sass.rs +++ b/packages/next-swc/crates/next-core/src/sass.rs @@ -1,20 +1,27 @@ -use anyhow::Result; +use anyhow::{bail, Result}; use turbo_tasks::primitives::JsonValueVc; use turbopack_binding::turbopack::{ - node::transforms::webpack::{WebpackLoaderConfigItem, WebpackLoaderConfigItemsVc}, - turbopack::module_options::WebpackLoadersOptionsVc, + node::transforms::webpack::{WebpackLoaderItem, WebpackLoaderItemsVc}, + turbopack::module_options::{LoaderRuleItem, OptionWebpackRulesVc, WebpackRulesVc}, }; #[turbo_tasks::function] pub async fn maybe_add_sass_loader( sass_options: JsonValueVc, - webpack_options: WebpackLoadersOptionsVc, -) -> Result { - let mut options = (*webpack_options.await?).clone(); - - let sass_options = sass_options.await?.as_object().unwrap().clone(); - for ext in [".scss", ".sass"] { - let loader = WebpackLoaderConfigItem::LoaderNameWithOptions { + webpack_rules: Option, +) -> Result { + let sass_options = sass_options.await?; + let Some(sass_options) = sass_options.as_object() else { + bail!("sass_options must be an object"); + }; + let mut rules = if let Some(webpack_rules) = webpack_rules { + webpack_rules.await?.clone_value() + } else { + Default::default() + }; + for pattern in ["*.scss", "*.sass"] { + let rule = rules.get_mut(pattern); + let loader = WebpackLoaderItem { loader: "next/dist/compiled/sass-loader".to_string(), options: serde_json::json!({ //https://github.com/vercel/turbo/blob/d527eb54be384a4658243304cecd547d09c05c6b/crates/turbopack-node/src/transforms/webpack.rs#L191 @@ -26,17 +33,22 @@ pub async fn maybe_add_sass_loader( .clone(), }; - options.extension_to_loaders.insert( - ext.to_owned(), - if options.extension_to_loaders.contains_key(ext) { - let mut new_configs = (*(options.extension_to_loaders[ext].await?)).clone(); - new_configs.push(loader); - WebpackLoaderConfigItemsVc::cell(new_configs) - } else { - WebpackLoaderConfigItemsVc::cell(vec![loader]) - }, - ); + if let Some(rule) = rule { + let mut loaders = rule.loaders.await?.clone_value(); + loaders.push(loader); + rule.loaders = WebpackLoaderItemsVc::cell(loaders); + } else { + rules.insert( + pattern.to_string(), + LoaderRuleItem { + loaders: WebpackLoaderItemsVc::cell(vec![loader]), + rename_as: Some("*".to_string()), + }, + ); + } } - Ok(options.cell()) + Ok(OptionWebpackRulesVc::cell(Some(WebpackRulesVc::cell( + rules, + )))) } diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/next.config.js new file mode 100644 index 0000000000000..c57d50163ebef --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/next.config.js @@ -0,0 +1,11 @@ +module.exports = { + experimental: { + turbo: { + loaders: { + '.replace': [ + { loader: 'replace-loader', options: { defaultExport: 3 } }, + ], + }, + }, + }, +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/pages/index.js new file mode 100644 index 0000000000000..060471b4b1508 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/input/pages/index.js @@ -0,0 +1,11 @@ +import { useTestHarness } from '@turbo/pack-test-harness' + +export default function Home() { + useTestHarness(runTests) + + return null +} + +function runTests() { + it('run', () => {}) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/issues/__quo__experimental.turbo.loaders__quo__ has been -391244.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/issues/__quo__experimental.turbo.loaders__quo__ has been -391244.txt new file mode 100644 index 0000000000000..610c77113dd3b --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/error/webpack-loaders/issues/__quo__experimental.turbo.loaders__quo__ has been -391244.txt @@ -0,0 +1,21 @@ +PlainIssue { + severity: Error, + context: "[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/error/webpack-loaders/input/next.config.js", + category: "config", + title: "\"experimental.turbo.loaders\" has been replaced by \"experimental.turbo.rules\"", + description: "The new option is similar, but the key should be a glob instead of an extension.\nExample: loaders: { \".mdx\": [\"mdx-loader\"] } -> rules: { \"*.mdx\": [\"mdx-loader\"] }", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [ + PlainIssueProcessingPathItem { + context: Some( + "[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/error/webpack-loaders/input/next.config.js", + ), + description: "Loading Next.js config", + }, + ], + ), +} \ No newline at end of file diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/basic-options/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/basic-options/input/next.config.js index c57d50163ebef..34e8968264d87 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/basic-options/input/next.config.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/basic-options/input/next.config.js @@ -1,8 +1,8 @@ module.exports = { experimental: { turbo: { - loaders: { - '.replace': [ + rules: { + '*.replace': [ { loader: 'replace-loader', options: { defaultExport: 3 } }, ], }, diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/next.config.js index 0e34aefe9786c..73a765218b60a 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/next.config.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/next.config.js @@ -1,8 +1,8 @@ module.exports = { experimental: { turbo: { - loaders: { - '.emit': ['emit-loader'], + rules: { + '*.emit': ['emit-loader'], }, }, }, diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/next.config.js index feacb3f1225b8..06335a9f19315 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/next.config.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/next.config.js @@ -1,8 +1,17 @@ module.exports = { experimental: { turbo: { - loaders: { - '.raw': ['raw-loader'], + rules: { + '*.raw.*': { + loaders: ['raw-loader'], + as: '*', + }, + '*.raw': ['raw-loader'], + '*.jraw': { + loaders: ['raw-as-json-loader'], + as: '*.json', + }, + './raw/**': ['raw-loader'], }, }, }, diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/node_modules/raw-as-json-loader/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/node_modules/raw-as-json-loader/index.js new file mode 100644 index 0000000000000..422794b59f718 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/node_modules/raw-as-json-loader/index.js @@ -0,0 +1,3 @@ +module.exports = async (source) => { + return `${JSON.stringify(source.trim())}` +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.jraw b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.jraw new file mode 100644 index 0000000000000..557db03de997c --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.jraw @@ -0,0 +1 @@ +Hello World diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.js new file mode 100644 index 0000000000000..557db03de997c --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.js @@ -0,0 +1 @@ +Hello World diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.raw b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.raw new file mode 100644 index 0000000000000..557db03de997c --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/hello.raw.raw @@ -0,0 +1 @@ +Hello World diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/index.js index eaacde5849404..076829d80674a 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/index.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/pages/index.js @@ -1,5 +1,9 @@ import { useTestHarness } from '@turbo/pack-test-harness' -import source from './hello.raw' +import source1 from './hello.raw' +import source2 from '../raw/hello.js' +import source3 from './hello.raw.raw' +import source4 from './hello.raw.js' +import source5 from './hello.jraw' export default function Home() { useTestHarness(runTests) @@ -9,6 +13,18 @@ export default function Home() { function runTests() { it('runs a simple loader', () => { - expect(source).toBe('Hello World') + expect(source1).toBe('Hello World') + }) + it('runs a loader matching relative path glob', () => { + expect(source2).toBe('}}} Hello World') + }) + it('runs a loader with "as" continue (to other match)', () => { + expect(source3).toBe('export default "Hello World";') + }) + it('runs a loader with "as" continue (to default js match)', () => { + expect(source4).toBe('Hello World') + }) + it('runs a loader with "as" to builtin type', () => { + expect(source5).toBe('Hello World') }) } diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/raw/hello.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/raw/hello.js new file mode 100644 index 0000000000000..1b617ed34e23e --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/no-options/input/raw/hello.js @@ -0,0 +1 @@ +}}} Hello World \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d84871787150..9826ac9335499 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1012,8 +1012,8 @@ importers: '@types/react': 18.2.5 '@types/react-dom': 18.2.3 '@vercel/ncc': ^0.36.0 - '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2 - '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230522.2 + '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2 + '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2 anser: ^2.1.1 css.escape: ^1.5.1 find-up: ^6.3.0 @@ -1025,8 +1025,8 @@ importers: stacktrace-parser: ^0.1.10 strip-ansi: ^7.0.1 dependencies: - '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2_react-refresh@0.12.0' - '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230522.2' + '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0' + '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2' anser: 2.1.1 css.escape: 1.5.1 next: link:../../../../next @@ -25490,9 +25490,9 @@ packages: /zwitch/2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2_react-refresh@0.12.0': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2} - id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230522.2' + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2} + id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2' name: '@vercel/turbopack-dev' version: 0.0.0 dependencies: @@ -25502,8 +25502,8 @@ packages: - webpack dev: false - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230522.2': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230522.2} + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2} name: '@vercel/turbopack-node' version: 0.0.0 dependencies: From 0718dbb7a549853c1a9eef78b008490d16020a43 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 23 May 2023 08:32:05 -0700 Subject: [PATCH 05/15] Fix static workers distributing (#50194) This removes the `computeWorkerKey` from our static workers as this doesn't work in practice as efficiently as we hoped since a single page can have thousands of paths to render which won't be distributed to separate workers if the same worker key is returned. Fixes: https://github.com/vercel/next.js/issues/49593 **Before** ![before](https://github.com/vercel/next.js/assets/22380829/da1e0a03-8b15-42a6-a2ac-6e4ff29c350d) **After** ![after](https://github.com/vercel/next.js/assets/22380829/b27354f6-bcdb-4cad-888c-7d6b143e0ee2) --- packages/next/src/build/index.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index bcadfeca7cc1f..f79b62ca158c3 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -1189,20 +1189,6 @@ export default async function build( }, }, enableWorkerThreads: config.experimental.workerThreads, - computeWorkerKey(method, ...args) { - if (method === 'exportPage') { - const typedArgs = args as Parameters< - typeof import('./worker').exportPage - > - return typedArgs[0].pathMap.page - } else if (method === 'isPageStatic') { - const typedArgs = args as Parameters< - typeof import('./worker').isPageStatic - > - return typedArgs[0].originalAppPath || typedArgs[0].page - } - return method - }, exposedMethods: sharedPool ? [ 'hasCustomGetInitialProps', From eba9e39ea487f281dc6cfc1ee2de09e2c4b23d61 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 23 May 2023 17:37:57 +0200 Subject: [PATCH 06/15] Ensure NEXT_DYNAMIC_NO_SSR_CODE has a unique name (#50219) ## What? Ensures `NEXT_DYNAMIC_NO_SSR_CODE` has a unique error code value, this accidentally had the value for dynamic server usage (e.g. calling cookies()) which caused the warning to be shown as shown in #48442. ## How? Changed the digest value to something unique. Fixes NEXT-1125 Fixes #48442 --- .../next/src/shared/lib/lazy-dynamic/no-ssr-error.ts | 2 +- .../app/layout.tsx | 7 +++++++ .../app/page.tsx | 5 +++++ .../deopted-into-client-rendering-warning.test.ts | 12 ++++++++++++ .../next.config.js | 10 ++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/e2e/app-dir/deopted-into-client-rendering-warning/app/layout.tsx create mode 100644 test/e2e/app-dir/deopted-into-client-rendering-warning/app/page.tsx create mode 100644 test/e2e/app-dir/deopted-into-client-rendering-warning/deopted-into-client-rendering-warning.test.ts create mode 100644 test/e2e/app-dir/deopted-into-client-rendering-warning/next.config.js diff --git a/packages/next/src/shared/lib/lazy-dynamic/no-ssr-error.ts b/packages/next/src/shared/lib/lazy-dynamic/no-ssr-error.ts index 1bf650c989dac..74303dc74bd45 100644 --- a/packages/next/src/shared/lib/lazy-dynamic/no-ssr-error.ts +++ b/packages/next/src/shared/lib/lazy-dynamic/no-ssr-error.ts @@ -1,3 +1,3 @@ // This has to be a shared module which is shared between client component error boundary and dynamic component -export const NEXT_DYNAMIC_NO_SSR_CODE = 'DYNAMIC_SERVER_USAGE' +export const NEXT_DYNAMIC_NO_SSR_CODE = 'NEXT_DYNAMIC_NO_SSR_CODE' diff --git a/test/e2e/app-dir/deopted-into-client-rendering-warning/app/layout.tsx b/test/e2e/app-dir/deopted-into-client-rendering-warning/app/layout.tsx new file mode 100644 index 0000000000000..e7077399c03ce --- /dev/null +++ b/test/e2e/app-dir/deopted-into-client-rendering-warning/app/layout.tsx @@ -0,0 +1,7 @@ +export default function Root({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ) +} diff --git a/test/e2e/app-dir/deopted-into-client-rendering-warning/app/page.tsx b/test/e2e/app-dir/deopted-into-client-rendering-warning/app/page.tsx new file mode 100644 index 0000000000000..8f2c030122961 --- /dev/null +++ b/test/e2e/app-dir/deopted-into-client-rendering-warning/app/page.tsx @@ -0,0 +1,5 @@ +import { cookies } from 'next/headers' +export default function Home() { + cookies() + return null +} diff --git a/test/e2e/app-dir/deopted-into-client-rendering-warning/deopted-into-client-rendering-warning.test.ts b/test/e2e/app-dir/deopted-into-client-rendering-warning/deopted-into-client-rendering-warning.test.ts new file mode 100644 index 0000000000000..14fef96955161 --- /dev/null +++ b/test/e2e/app-dir/deopted-into-client-rendering-warning/deopted-into-client-rendering-warning.test.ts @@ -0,0 +1,12 @@ +import { nextBuild } from 'next-test-utils' + +it('should not show deopted into client rendering warning', async () => { + const output = await nextBuild(__dirname, undefined, { + stdout: true, + stderr: true, + }) + expect(output.code).toBe(0) + expect(output.stderr).not.toContain( + `Entire page / deopted into client-side rendering.` + ) +}) diff --git a/test/e2e/app-dir/deopted-into-client-rendering-warning/next.config.js b/test/e2e/app-dir/deopted-into-client-rendering-warning/next.config.js new file mode 100644 index 0000000000000..3d24f6813557e --- /dev/null +++ b/test/e2e/app-dir/deopted-into-client-rendering-warning/next.config.js @@ -0,0 +1,10 @@ +/** + * @type {import('next').NextConfig} + */ +const nextConfig = { + typescript: { + ignoreBuildErrors: true, + }, +} + +module.exports = nextConfig From 2fa58c3a885ef037f6cb5264464beb1c9ef1a72b Mon Sep 17 00:00:00 2001 From: Jesse Koldewijn <60965908+JesseKoldewijn@users.noreply.github.com> Date: Tue, 23 May 2023 17:41:59 +0200 Subject: [PATCH 07/15] fix: Added blockfrost-js, lucid-cardano & mongoose package to srvExtPackages to prevent issue #49783 from happening. (#49938) fixes #49783 ### What? Added the following packages to the server component exclusion list which prevents these packages from going through the currently default compile pipeline for apps that use the App Router. Packages added are: "@blockfrost/blockfrost-js", "@jpg-store/lucid-cardano" and "mongoose". (For instance, mongo was already in this exclusion list) ### Why? These packages are required by the "@emurgo/cardano-serialization-lib-nodejs" packages and break when not added to this list while using the app router. ### How? I've added these packages to the server-external-packages json file in the Next.js package's lib directory. --- packages/next/src/lib/server-external-packages.json | 3 +++ pnpm-lock.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/next/src/lib/server-external-packages.json b/packages/next/src/lib/server-external-packages.json index 6b9eb5db08b4f..2af3637b92672 100644 --- a/packages/next/src/lib/server-external-packages.json +++ b/packages/next/src/lib/server-external-packages.json @@ -1,4 +1,6 @@ [ + "@blockfrost/blockfrost-js", + "@jpg-store/lucid-cardano", "@prisma/client", "@vercel/og", "@sentry/nextjs", @@ -19,6 +21,7 @@ "lodash", "mdx-bundler", "mongodb", + "mongoose", "next-mdx-remote", "next-seo", "pg", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9826ac9335499..23ffc3d85168e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25514,4 +25514,4 @@ packages: resolution: {tarball: https://codeload.github.com/watson/ci-info/tar.gz/f43f6a1cefff47fb361c88cf4b943fdbcaafe540} name: ci-info version: 2.0.0 - dev: true + dev: true \ No newline at end of file From 9eaf4f5dc846900cdfcdfb23c63bd4681e686de0 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Tue, 23 May 2023 16:03:50 +0000 Subject: [PATCH 08/15] v13.4.4-canary.4 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/font/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 16 ++++++++-------- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index a2bf314e6e1a7..e26a55117899c 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "13.4.4-canary.3" + "version": "13.4.4-canary.4" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index d73b1d273730d..56db1c731f377 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 615f465c91430..2d95541f2b6c8 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "13.4.4-canary.3", + "@next/eslint-plugin-next": "13.4.4-canary.4", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.42.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 1d89fc74f0bcd..67b02008557bc 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "ESLint plugin for NextJS.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 5ab27da65acd2..a88c6d79f1be2 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 9453813e8cf1f..0e27d1900adc9 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index a114970accb85..57185bff33a2f 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 57e0612c79ecf..419e20fba13cb 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 2a92a4dec4fbd..96d7f105df726 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index a903d1eec0982..b332a03c13c93 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index b09f3b87d8980..a65f70e752aee 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 5bafba0c19db7..1ab3929a0bf83 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 23d8da83a065a..0a9b5e762a69e 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index 7ea3a1c733952..caf7862f9b902 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@next/env": "13.4.4-canary.3", + "@next/env": "13.4.4-canary.4", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -139,11 +139,11 @@ "@jest/types": "29.5.0", "@napi-rs/cli": "2.14.7", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "13.4.4-canary.3", - "@next/polyfill-nomodule": "13.4.4-canary.3", - "@next/react-dev-overlay": "13.4.4-canary.3", - "@next/react-refresh-utils": "13.4.4-canary.3", - "@next/swc": "13.4.4-canary.3", + "@next/polyfill-module": "13.4.4-canary.4", + "@next/polyfill-nomodule": "13.4.4-canary.4", + "@next/react-dev-overlay": "13.4.4-canary.4", + "@next/react-refresh-utils": "13.4.4-canary.4", + "@next/swc": "13.4.4-canary.4", "@opentelemetry/api": "1.4.1", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 8ba17e92aa2ef..0468838a4c297 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index cac52765e4a98..1929036a3078e 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "13.4.4-canary.3", + "version": "13.4.4-canary.4", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 23ffc3d85168e..eba60105193d4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -460,7 +460,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 13.4.4-canary.3 + '@next/eslint-plugin-next': 13.4.4-canary.4 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.42.0 eslint: ^7.23.0 || ^8.0.0 @@ -536,12 +536,12 @@ importers: '@jest/types': 29.5.0 '@napi-rs/cli': 2.14.7 '@napi-rs/triples': 1.1.0 - '@next/env': 13.4.4-canary.3 - '@next/polyfill-module': 13.4.4-canary.3 - '@next/polyfill-nomodule': 13.4.4-canary.3 - '@next/react-dev-overlay': 13.4.4-canary.3 - '@next/react-refresh-utils': 13.4.4-canary.3 - '@next/swc': 13.4.4-canary.3 + '@next/env': 13.4.4-canary.4 + '@next/polyfill-module': 13.4.4-canary.4 + '@next/polyfill-nomodule': 13.4.4-canary.4 + '@next/react-dev-overlay': 13.4.4-canary.4 + '@next/react-refresh-utils': 13.4.4-canary.4 + '@next/swc': 13.4.4-canary.4 '@opentelemetry/api': 1.4.1 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.5.1 @@ -25514,4 +25514,4 @@ packages: resolution: {tarball: https://codeload.github.com/watson/ci-info/tar.gz/f43f6a1cefff47fb361c88cf4b943fdbcaafe540} name: ci-info version: 2.0.0 - dev: true \ No newline at end of file + dev: true From 33b8e6157f64fe640a4f668db2a6c94a108f2410 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 23 May 2023 18:39:27 +0200 Subject: [PATCH 09/15] change static path to /_next/static/media (#50207) ### What? align output path of turbopack and webpack ### Why? passing test cases ### Turbopack Changes * https://github.com/vercel/turbo/pull/5072 --- Cargo.lock | 66 +++++++++---------- Cargo.toml | 6 +- .../next-swc/crates/next-core/js/package.json | 4 +- .../crates/next-core/src/app_source.rs | 11 +++- .../next-core/src/next_client/context.rs | 2 +- .../next/image/app/input/app/test.js | 2 +- .../next/image/basic/input/pages/index.js | 8 +-- ...txt => Processing image failed-b2edcb.txt} | 2 +- .../transpilePackages/input/pages/index.js | 2 +- pnpm-lock.yaml | 33 +++------- 10 files changed, 65 insertions(+), 71 deletions(-) rename packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/{Processing image failed-d388f6.txt => Processing image failed-b2edcb.txt} (80%) diff --git a/Cargo.lock b/Cargo.lock index 3e7b985674d0f..fb22dd0d8ff36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "serde", ] @@ -3424,7 +3424,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "serde", @@ -7034,7 +7034,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "auto-hash-map", @@ -7065,7 +7065,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "cargo-lock", @@ -7077,7 +7077,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "bytes", @@ -7092,7 +7092,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "dotenvy", @@ -7106,7 +7106,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "indexmap", @@ -7123,7 +7123,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "auto-hash-map", @@ -7153,7 +7153,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "base16", "hex", @@ -7165,7 +7165,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7179,7 +7179,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "proc-macro2", "quote", @@ -7189,7 +7189,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "mimalloc", ] @@ -7197,7 +7197,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "auto-hash-map", @@ -7220,7 +7220,7 @@ dependencies = [ [[package]] name = "turbo-tasks-testing" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "auto-hash-map", @@ -7232,7 +7232,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-recursion", @@ -7262,7 +7262,7 @@ dependencies = [ [[package]] name = "turbopack-bench" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "chromiumoxide", @@ -7292,7 +7292,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "auto-hash-map", "mdxjs", @@ -7332,7 +7332,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "clap 4.1.11", @@ -7356,7 +7356,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-trait", @@ -7384,7 +7384,7 @@ dependencies = [ [[package]] name = "turbopack-create-test-app" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "clap 4.1.11", @@ -7397,7 +7397,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-trait", @@ -7419,7 +7419,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "indexmap", @@ -7441,7 +7441,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-compression", @@ -7476,7 +7476,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-trait", @@ -7509,7 +7509,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-trait", @@ -7530,7 +7530,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "indexmap", @@ -7546,7 +7546,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "base64 0.21.0", @@ -7566,7 +7566,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "serde", @@ -7581,7 +7581,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "mdxjs", @@ -7596,7 +7596,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "async-stream", @@ -7631,7 +7631,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "serde", @@ -7647,7 +7647,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "swc_core", "turbo-tasks", @@ -7658,7 +7658,7 @@ dependencies = [ [[package]] name = "turbopack-test-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.2#2a0256bec14e867f8f086f82692f467e2f02cbb1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230523.3#49ac90877547511d9f962f126a7b23b5cc0d45be" dependencies = [ "anyhow", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 834d31aaa4302..94717e43ae259 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,11 +42,11 @@ swc_core = { version = "0.76.18" } testing = { version = "0.33.11" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.3" } # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. -turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.3" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.3" } # General Deps diff --git a/packages/next-swc/crates/next-core/js/package.json b/packages/next-swc/crates/next-core/js/package.json index a7e775934c7fd..0832a47097989 100644 --- a/packages/next-swc/crates/next-core/js/package.json +++ b/packages/next-swc/crates/next-core/js/package.json @@ -10,8 +10,8 @@ "check": "tsc --noEmit" }, "dependencies": { - "@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2", - "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2", + "@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3", + "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3", "anser": "^2.1.1", "css.escape": "^1.5.1", "next": "*", diff --git a/packages/next-swc/crates/next-core/src/app_source.rs b/packages/next-swc/crates/next-core/src/app_source.rs index 020ed5acc630e..fd54ba0d9be6c 100644 --- a/packages/next-swc/crates/next-core/src/app_source.rs +++ b/packages/next-swc/crates/next-core/src/app_source.rs @@ -674,6 +674,7 @@ async fn create_app_route_source_for_route( project_path, intermediate_output_path: intermediate_output_path_root, output_root: intermediate_output_path_root, + app_dir, } .cell() .into(), @@ -1018,7 +1019,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; project_path, intermediate_output_path, intermediate_output_path.join("chunks"), - server_root.join("_next/static/assets"), + get_client_assets_path(server_root, Value::new(ClientContextType::App { app_dir })), context.compile_time_info().environment(), ) .layer("ssr") @@ -1087,6 +1088,7 @@ struct AppRoute { project_path: FileSystemPathVc, server_root: FileSystemPathVc, output_root: FileSystemPathVc, + app_dir: FileSystemPathVc, } #[turbo_tasks::value_impl] @@ -1099,7 +1101,12 @@ impl AppRouteVc { this.project_path, this.intermediate_output_path, this.intermediate_output_path.join("chunks"), - this.server_root.join("_next/static/assets"), + get_client_assets_path( + this.server_root, + Value::new(ClientContextType::App { + app_dir: this.app_dir, + }), + ), this.context.compile_time_info().environment(), ) .layer("ssr") diff --git a/packages/next-swc/crates/next-core/src/next_client/context.rs b/packages/next-swc/crates/next-core/src/next_client/context.rs index 19ee91d71ed72..a4e42e1a0415d 100644 --- a/packages/next-swc/crates/next-core/src/next_client/context.rs +++ b/packages/next-swc/crates/next-core/src/next_client/context.rs @@ -343,7 +343,7 @@ pub fn get_client_assets_path( match ty.into_value() { ClientContextType::Pages { .. } | ClientContextType::App { .. } - | ClientContextType::Fallback => server_root.join("/_next/static/assets"), + | ClientContextType::Fallback => server_root.join("/_next/static/media"), ClientContextType::Other => server_root.join("/_assets"), } } diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/test.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/test.js index 4a166a45b8e73..3434cdf21e132 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/test.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/test.js @@ -8,7 +8,7 @@ export default function Test() { function runTests() { it('should link to imported image', async () => { const img = document.querySelector('#imported') - expect(img.src).toContain(encodeURIComponent('_next/static/assets')) + expect(img.src).toContain(encodeURIComponent('_next/static/media')) const res = await fetch(img.src) expect(res.status).toBe(200) diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js index da8a04e47bb63..f800de5cdafc4 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js @@ -83,7 +83,7 @@ function runTests() { it('should link to imported image', async () => { const img = document.querySelector('#imported') - expect(img.src).toContain(encodeURIComponent('_next/static/assets')) + expect(img.src).toContain(encodeURIComponent('_next/static/media')) const res = await fetch(img.src) expect(res.status).toBe(200) @@ -91,7 +91,7 @@ function runTests() { it('should link to imported svg image', async () => { const img = document.querySelector('#svg') - expect(img.src).toContain('_next/static/assets') + expect(img.src).toContain('_next/static/media') const res = await fetch(img.src) expect(res.status).toBe(200) @@ -107,7 +107,7 @@ function runTests() { it('should link to imported broken image', async () => { const img = document.querySelector('#broken') - expect(img.src).toContain(encodeURIComponent('_next/static/assets')) + expect(img.src).toContain(encodeURIComponent('_next/static/media')) const res = await fetch(img.src) expect(res.status).toBe(404) @@ -115,7 +115,7 @@ function runTests() { it('should link to imported broken svg image', async () => { const img = document.querySelector('#broken-svg') - expect(img.src).toContain('_next/static/assets') + expect(img.src).toContain('_next/static/media') const res = await fetch(img.src) expect(res.status).toBe(200) diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-d388f6.txt b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-b2edcb.txt similarity index 80% rename from packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-d388f6.txt rename to packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-b2edcb.txt index 0099f39aaffe8..c2fd16b728565 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-d388f6.txt +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-b2edcb.txt @@ -1,6 +1,6 @@ PlainIssue { severity: Error, - context: "[root of the server]/_next/static/assets/11d09843b5b83333.jpeg", + context: "[root of the server]/_next/static/media/broken.11d09843.jpeg", category: "image", title: "Processing image failed", description: "unable to decode image data\n\nCaused by:\n- failed to fill whole buffer", diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/transpilePackages/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/transpilePackages/input/pages/index.js index e27575358e803..152af958ad896 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/transpilePackages/input/pages/index.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/transpilePackages/input/pages/index.js @@ -10,6 +10,6 @@ export default function Home() { function runTests() { it('it should link to imported image from a package', function () { const img = document.querySelector('#magic') - expect(img.src).toContain(encodeURIComponent('_next/static/assets')) + expect(img.src).toContain(encodeURIComponent('_next/static/media')) }) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eba60105193d4..85ede6ed46aec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1012,8 +1012,8 @@ importers: '@types/react': 18.2.5 '@types/react-dom': 18.2.3 '@vercel/ncc': ^0.36.0 - '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2 - '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2 + '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3 + '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3 anser: ^2.1.1 css.escape: ^1.5.1 find-up: ^6.3.0 @@ -1025,8 +1025,8 @@ importers: stacktrace-parser: ^0.1.10 strip-ansi: ^7.0.1 dependencies: - '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0' - '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2' + '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3_react-refresh@0.12.0' + '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3' anser: 2.1.1 css.escape: 1.5.1 next: link:../../../../next @@ -5997,7 +5997,7 @@ packages: dependencies: '@mdx-js/mdx': 2.2.1 source-map: 0.7.3 - webpack: 5.74.0 + webpack: 5.74.0_@swc+core@1.3.55 transitivePeerDependencies: - supports-color @@ -6669,7 +6669,6 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true - dev: true optional: true /@swc/core-darwin-x64/1.3.55: @@ -6678,7 +6677,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: true optional: true /@swc/core-linux-arm-gnueabihf/1.3.55: @@ -6687,7 +6685,6 @@ packages: cpu: [arm] os: [linux] requiresBuild: true - dev: true optional: true /@swc/core-linux-arm64-gnu/1.3.55: @@ -6696,7 +6693,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true optional: true /@swc/core-linux-arm64-musl/1.3.55: @@ -6705,7 +6701,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true optional: true /@swc/core-linux-x64-gnu/1.3.55: @@ -6714,7 +6709,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true optional: true /@swc/core-linux-x64-musl/1.3.55: @@ -6723,7 +6717,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true optional: true /@swc/core-win32-arm64-msvc/1.3.55: @@ -6732,7 +6725,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: true optional: true /@swc/core-win32-ia32-msvc/1.3.55: @@ -6741,7 +6733,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: true optional: true /@swc/core-win32-x64-msvc/1.3.55: @@ -6750,7 +6741,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: true optional: true /@swc/core/1.3.55_@swc+helpers@0.5.1: @@ -6775,7 +6765,6 @@ packages: '@swc/core-win32-arm64-msvc': 1.3.55 '@swc/core-win32-ia32-msvc': 1.3.55 '@swc/core-win32-x64-msvc': 1.3.55 - dev: true /@swc/helpers/0.4.14: resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} @@ -23669,7 +23658,6 @@ packages: source-map: 0.6.1 terser: 5.14.1 webpack: 5.74.0_@swc+core@1.3.55 - dev: true /terser-webpack-plugin/5.2.4_webpack@5.74.0: resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==} @@ -25079,7 +25067,6 @@ packages: - '@swc/core' - esbuild - uglify-js - dev: true /websocket-driver/0.7.3: resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==} @@ -25490,9 +25477,9 @@ packages: /zwitch/2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2} - id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2' + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3_react-refresh@0.12.0': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3} + id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3' name: '@vercel/turbopack-dev' version: 0.0.0 dependencies: @@ -25502,8 +25489,8 @@ packages: - webpack dev: false - '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2': - resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2} + '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3': + resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3} name: '@vercel/turbopack-node' version: 0.0.0 dependencies: From 1a40651267deb336d149adcee1e057b616fb59f7 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 23 May 2023 19:36:09 +0200 Subject: [PATCH 10/15] Add special route types to the link type declaration (#50066) This PR adds generated type definitions for `Link` hrefs with only search, hash or with a protocol. Closes #49825. fix NEXT-1203 --- packages/next/src/build/webpack/plugins/next-types-plugin.ts | 3 +++ test/integration/app-types/src/app/type-checks/link/page.tsx | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/packages/next/src/build/webpack/plugins/next-types-plugin.ts b/packages/next/src/build/webpack/plugins/next-types-plugin.ts index 07406afba98cf..81118585efaf8 100644 --- a/packages/next/src/build/webpack/plugins/next-types-plugin.ts +++ b/packages/next/src/build/webpack/plugins/next-types-plugin.ts @@ -362,6 +362,7 @@ function createRouteDefinitions() { */ declare namespace __next_route_internal_types__ { type SearchOrHash = \`?\${string}\` | \`#\${string}\` + type WithProtocol = \`\${string}:\${string}\` type Suffix = '' | SearchOrHash @@ -394,6 +395,8 @@ declare namespace __next_route_internal_types__ { // This keeps autocompletion working for static routes. '| StaticRoutes' } + | SearchOrHash + | WithProtocol | \`\${StaticRoutes}\${SearchOrHash}\` | (T extends \`\${DynamicRoutes}\${Suffix}\` ? T : never) ` diff --git a/test/integration/app-types/src/app/type-checks/link/page.tsx b/test/integration/app-types/src/app/type-checks/link/page.tsx index 2e07b9cecd4e1..6c9fa7e5f2c88 100644 --- a/test/integration/app-types/src/app/type-checks/link/page.tsx +++ b/test/integration/app-types/src/app/type-checks/link/page.tsx @@ -62,6 +62,11 @@ export default function page() { test test test + test + test + test + test + test ) From ff070e530b239e89ed05ff8bfc0990a351e4c0a1 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 23 May 2023 10:49:36 -0700 Subject: [PATCH 11/15] Use correct casing in filenames (#50223) My computer ignored the casing change when copying things over, which causes resolution errors. --- examples/with-turbopack/ui/{Boundary.tsx => boundary.tsx} | 0 examples/with-turbopack/ui/{Button.tsx => button.tsx} | 0 examples/with-turbopack/ui/{Footer.tsx => footer.tsx} | 0 examples/with-turbopack/ui/global-nav.tsx | 2 +- examples/with-turbopack/ui/{Header.tsx => header.tsx} | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename examples/with-turbopack/ui/{Boundary.tsx => boundary.tsx} (100%) rename examples/with-turbopack/ui/{Button.tsx => button.tsx} (100%) rename examples/with-turbopack/ui/{Footer.tsx => footer.tsx} (100%) rename examples/with-turbopack/ui/{Header.tsx => header.tsx} (100%) diff --git a/examples/with-turbopack/ui/Boundary.tsx b/examples/with-turbopack/ui/boundary.tsx similarity index 100% rename from examples/with-turbopack/ui/Boundary.tsx rename to examples/with-turbopack/ui/boundary.tsx diff --git a/examples/with-turbopack/ui/Button.tsx b/examples/with-turbopack/ui/button.tsx similarity index 100% rename from examples/with-turbopack/ui/Button.tsx rename to examples/with-turbopack/ui/button.tsx diff --git a/examples/with-turbopack/ui/Footer.tsx b/examples/with-turbopack/ui/footer.tsx similarity index 100% rename from examples/with-turbopack/ui/Footer.tsx rename to examples/with-turbopack/ui/footer.tsx diff --git a/examples/with-turbopack/ui/global-nav.tsx b/examples/with-turbopack/ui/global-nav.tsx index 30dd87fa98b9a..8ad09e56ac159 100644 --- a/examples/with-turbopack/ui/global-nav.tsx +++ b/examples/with-turbopack/ui/global-nav.tsx @@ -53,7 +53,7 @@ export function GlobalNav() {

- App Router (Beta) + App Router

diff --git a/examples/with-turbopack/ui/Header.tsx b/examples/with-turbopack/ui/header.tsx similarity index 100% rename from examples/with-turbopack/ui/Header.tsx rename to examples/with-turbopack/ui/header.tsx From 90331f38ccf49e0632e84688aae05beac9ac64a6 Mon Sep 17 00:00:00 2001 From: Cowboy Ho <14261588+Cow258@users.noreply.github.com> Date: Wed, 24 May 2023 02:03:08 +0800 Subject: [PATCH 12/15] fix: NODE_OPTIONS='--inspect' in next dev for debugging (#48019) ## Bug This fix closes #47083 issue This fix closes #47561 issue This fix closes #48376 issue **Invalid repetition PRs:** #47671 (this PR changing expired code) (This issue still exist on [v13.4.3-canary.1](https://github.com/vercel/next.js/releases/tag/v13.4.3-canary.1) - [x] Related issues linked using `fixes #number` ### What? When running `NODE_OPTIONS='--inspect' next dev`, the render server didn't start with `--inspect`. In some cases, the `--inspect` flag will be passed when `__NEXT_DISABLE_MEMORY_WATCHER` was set. ### Why? Since #47208 revamped some startup processes, the `NODE_OPTIONS` environment parameter is not passed down to the render server worker. ### How? Just add back the original startup process. ![image](https://user-images.githubusercontent.com/14261588/230398898-791e6909-6f4c-493b-937d-058a7b788849.png) link NEXT-1176 --------- Co-authored-by: JJ Kasper --- .../server/lib/render-server-standalone.ts | 1 + packages/next/src/server/lib/render-server.ts | 7 ++-- .../next/src/server/lib/server-ipc/index.ts | 14 ++++---- packages/next/src/server/lib/start-server.ts | 12 +++++-- packages/next/src/server/lib/worker-utils.ts | 35 ++++++++++++++----- packages/next/src/server/next-server.ts | 7 ++-- 6 files changed, 51 insertions(+), 25 deletions(-) diff --git a/packages/next/src/server/lib/render-server-standalone.ts b/packages/next/src/server/lib/render-server-standalone.ts index cb4778b742103..bbfb406772186 100644 --- a/packages/next/src/server/lib/render-server-standalone.ts +++ b/packages/next/src/server/lib/render-server-standalone.ts @@ -66,6 +66,7 @@ export const createServerHandler = async ({ hostname, minimalMode, workerType: 'router', + isNodeDebugging: false, }) didInitialize = true diff --git a/packages/next/src/server/lib/render-server.ts b/packages/next/src/server/lib/render-server.ts index 7d5d73c027183..0cd1a9d444516 100644 --- a/packages/next/src/server/lib/render-server.ts +++ b/packages/next/src/server/lib/render-server.ts @@ -14,6 +14,7 @@ import { deleteAppClientCache as _deleteAppClientCache, } from '../../build/webpack/plugins/nextjs-require-cache-hot-reloader' import { clearModuleContext as _clearModuleContext } from '../web/sandbox/context' +import { getFreePort } from '../lib/worker-utils' export const WORKER_SELF_EXIT_CODE = 77 const MAXIMUM_HEAP_SIZE_ALLOWED = @@ -45,6 +46,7 @@ export async function initialize(opts: { minimalMode?: boolean hostname?: string workerType: 'router' | 'render' + isNodeDebugging: boolean keepAliveTimeout?: number }): Promise> { // if we already setup the server return as we only need to do @@ -79,7 +81,7 @@ export async function initialize(opts: { server.keepAliveTimeout = opts.keepAliveTimeout } - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { server.on('error', (err: NodeJS.ErrnoException) => { console.error(`Invariant: failed to start render worker`, err) process.exit(1) @@ -123,6 +125,7 @@ export async function initialize(opts: { customServer: false, httpServer: server, port: opts.port, + isNodeDebugging: opts.isNodeDebugging, }) requestHandler = app.getRequestHandler() @@ -133,6 +136,6 @@ export async function initialize(opts: { return reject(err) } }) - server.listen(0, opts.hostname) + server.listen((await getFreePort()) + 1, opts.hostname) }) } diff --git a/packages/next/src/server/lib/server-ipc/index.ts b/packages/next/src/server/lib/server-ipc/index.ts index e5dd765d4221d..76ff467bc90c0 100644 --- a/packages/next/src/server/lib/server-ipc/index.ts +++ b/packages/next/src/server/lib/server-ipc/index.ts @@ -1,9 +1,10 @@ import type NextServer from '../../next-server' -import { genExecArgv, getNodeOptionsWithoutInspect } from '../utils' +import { getNodeOptionsWithoutInspect } from '../utils' import { deserializeErr, errorToJSON } from '../../render' import crypto from 'crypto' import isError from '../../../lib/is-error' +import { genRenderExecArgv } from '../worker-utils' // we can't use process.send as jest-worker relies on // it already and can cause unexpected message errors @@ -78,8 +79,7 @@ export async function createIpcServer( } } -export const createWorker = ( - serverPort: number, +export const createWorker = async ( ipcPort: number, ipcValidationKey: string, isNodeDebugging: boolean | 'brk' | undefined, @@ -88,6 +88,7 @@ export const createWorker = ( ) => { const { initialEnv } = require('@next/env') as typeof import('@next/env') const { Worker } = require('next/dist/compiled/jest-worker') + const worker = new Worker(require.resolve('../render-server'), { numWorkers: 1, // TODO: do we want to allow more than 10 OOM restarts? @@ -97,7 +98,7 @@ export const createWorker = ( FORCE_COLOR: '1', ...initialEnv, // we don't pass down NODE_OPTIONS as it can - // extra memory usage + // allow more memory usage than expected NODE_OPTIONS: getNodeOptionsWithoutInspect() .replace(/--max-old-space-size=[\d]{1,}/, '') .trim(), @@ -115,10 +116,7 @@ export const createWorker = ( } : {}), }, - execArgv: genExecArgv( - isNodeDebugging === undefined ? false : isNodeDebugging, - (serverPort || 0) + 1 - ), + execArgv: isNodeDebugging ? genRenderExecArgv(type) : undefined, }, exposedMethods: [ 'initialize', diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index 97cffed16e8ad..57232707e9b67 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -1,11 +1,12 @@ import http from 'http' import { isIPv6 } from 'net' import * as Log from '../../build/output/log' -import { getNodeOptionsWithoutInspect } from './utils' import type { IncomingMessage, ServerResponse } from 'http' import type { ChildProcess } from 'child_process' import { normalizeRepeatedSlashes } from '../../shared/lib/utils' import { initialEnv } from '@next/env' +import { genExecArgv, getNodeOptionsWithoutInspect } from './utils' +import { getFreePort } from './worker-utils' export interface StartServerOptions { dir: string @@ -184,11 +185,17 @@ export async function startServer({ // TODO: do we want to allow more than 10 OOM restarts? maxRetries: 10, forkOptions: { + execArgv: isNodeDebugging + ? genExecArgv( + isNodeDebugging === undefined ? false : isNodeDebugging, + await getFreePort() + ) + : undefined, env: { FORCE_COLOR: '1', ...((initialEnv || process.env) as typeof process.env), PORT: port + '', - NODE_OPTIONS: getNodeOptionsWithoutInspect().trim(), + NODE_OPTIONS: getNodeOptionsWithoutInspect(), }, }, exposedMethods: ['initialize'], @@ -235,6 +242,7 @@ export async function startServer({ hostname, dev: !!isDev, workerType: 'router', + isNodeDebugging: !!isNodeDebugging, keepAliveTimeout, }) didInitialize = true diff --git a/packages/next/src/server/lib/worker-utils.ts b/packages/next/src/server/lib/worker-utils.ts index 13cda78c85a21..9a827c5f01e13 100644 --- a/packages/next/src/server/lib/worker-utils.ts +++ b/packages/next/src/server/lib/worker-utils.ts @@ -1,6 +1,23 @@ import * as Log from '../../build/output/log' +import http from 'http' -export const genRenderExecArgv = () => { +export const getFreePort = async (): Promise => { + return new Promise((resolve, reject) => { + const server = http.createServer(() => {}) + server.listen(0, () => { + const address = server.address() + server.close() + + if (address && typeof address === 'object') { + resolve(address.port) + } else { + reject(new Error('invalid address from server: ' + address?.toString())) + } + }) + }) +} + +export const genRenderExecArgv = (type: 'pages' | 'app') => { const isDebugging = process.execArgv.some((localArg) => localArg.startsWith('--inspect')) || process.env.NODE_OPTIONS?.match?.(/--inspect(=\S+)?( |$)/) @@ -9,7 +26,7 @@ export const genRenderExecArgv = () => { process.execArgv.some((localArg) => localArg.startsWith('--inspect-brk')) || process.env.NODE_OPTIONS?.match?.(/--inspect-brk(=\S+)?( |$)/) - const debugPort = (() => { + let debugPort = (() => { const debugPortStr = process.execArgv .find( @@ -22,13 +39,15 @@ export const genRenderExecArgv = () => { return debugPortStr ? parseInt(debugPortStr, 10) : 9229 })() + debugPort += type === 'pages' ? 2 : 3 + if (isDebugging || isDebuggingWithBrk) { - Log.warn( + Log.info( `the --inspect${ isDebuggingWithBrk ? '-brk' : '' - } option was detected, the Next.js server should be inspected at port ${ - debugPort + 1 - }.` + } option was detected, the Next.js server${ + type === 'pages' ? ' for pages' : type === 'app' ? ' for app' : '' + } should be inspected at port ${debugPort}.` ) } const execArgv = process.execArgv.filter((localArg) => { @@ -38,9 +57,7 @@ export const genRenderExecArgv = () => { }) if (isDebugging || isDebuggingWithBrk) { - execArgv.push( - `--inspect${isDebuggingWithBrk ? '-brk' : ''}=${debugPort + 1}` - ) + execArgv.push(`--inspect${isDebuggingWithBrk ? '-brk' : ''}=${debugPort}`) } return execArgv diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index f74ac94ec04cd..3e5658d89cc58 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -273,6 +273,7 @@ export default class NextNodeServer extends BaseServer { hostname: this.hostname, minimalMode: this.minimalMode, dev: !!options.dev, + isNodeDebugging: !!options.isNodeDebugging, } const { createWorker, createIpcServer } = require('./lib/server-ipc') as typeof import('./lib/server-ipc') @@ -281,8 +282,7 @@ export default class NextNodeServer extends BaseServer { this.renderWorkers = {} const { ipcPort, ipcValidationKey } = await createIpcServer(this) if (this.hasAppDir) { - this.renderWorkers.app = createWorker( - this.port || 0, + this.renderWorkers.app = await createWorker( ipcPort, ipcValidationKey, options.isNodeDebugging, @@ -290,8 +290,7 @@ export default class NextNodeServer extends BaseServer { this.nextConfig.experimental.serverActions ) } - this.renderWorkers.pages = createWorker( - this.port || 0, + this.renderWorkers.pages = await createWorker( ipcPort, ipcValidationKey, options.isNodeDebugging, From bf7a556204465a0639503e062f046578a1887f69 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 23 May 2023 20:21:56 +0200 Subject: [PATCH 13/15] enable more test cases for turbopack (#50154) ### What? Enable more test cases to run with turbopack ### Why? These test suites are passing and are not flaky. --- .github/workflows/build_test_deploy.yml | 10 +- .../crates/next-dev-tests/tests-manifest.js | 585 +++++++++--------- 2 files changed, 297 insertions(+), 298 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index b91fcab7528cc..1a39808c1a56f 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -833,8 +833,7 @@ jobs: fail-fast: false matrix: node: [18] - # Currently turbopack tests does not utilize groups yet - group: [1] + group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] steps: - run: echo "${{needs.build.outputs.docsChange}}" @@ -856,7 +855,7 @@ jobs: name: next-swc-test-binary path: packages/next-swc/native - - run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_EXTERNAL_TESTS_FILTERS=${NEXT_EXTERNAL_TESTS_FILTERS} __INTERNAL_NEXT_DEV_TEST_TURBO_DEV=TRUE __INTERNAL_CUSTOM_TURBOPACK_BINDINGS=${NEXT_BINDINGS_BIN} __INTERNAL_NEXT_DEV_TEST_TURBO_GLOB_MATCH=${NEXT_DEV_TEST_GLOB} NEXT_E2E_TEST_TIMEOUT=240000 NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type development --timings >> /proc/1/fd/1" + - run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_EXTERNAL_TESTS_FILTERS=${NEXT_EXTERNAL_TESTS_FILTERS} __INTERNAL_NEXT_DEV_TEST_TURBO_DEV=TRUE __INTERNAL_CUSTOM_TURBOPACK_BINDINGS=${NEXT_BINDINGS_BIN} __INTERNAL_NEXT_DEV_TEST_TURBO_GLOB_MATCH=${NEXT_DEV_TEST_GLOB} NEXT_E2E_TEST_TIMEOUT=240000 NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type development --timings -g ${{ matrix.group }}/10 >> /proc/1/fd/1" name: Run test/development if: ${{needs.build.outputs.docsChange == 'nope'}} @@ -879,8 +878,7 @@ jobs: fail-fast: false matrix: node: [18] - # Currently turbopack tests does not utilize groups yet - group: [1] + group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] steps: - run: echo "${{needs.build.outputs.docsChange}}" @@ -902,7 +900,7 @@ jobs: name: next-swc-test-binary path: packages/next-swc/native - - run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_EXTERNAL_TESTS_FILTERS=${NEXT_EXTERNAL_TESTS_FILTERS} __INTERNAL_NEXT_DEV_TEST_TURBO_DEV=TRUE __INTERNAL_CUSTOM_TURBOPACK_BINDINGS=${NEXT_BINDINGS_BIN} __INTERNAL_NEXT_DEV_TEST_TURBO_GLOB_MATCH=${NEXT_DEV_TEST_GLOB} NEXT_E2E_TEST_TIMEOUT=240000 NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings >> /proc/1/fd/1" + - run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_EXTERNAL_TESTS_FILTERS=${NEXT_EXTERNAL_TESTS_FILTERS} __INTERNAL_NEXT_DEV_TEST_TURBO_DEV=TRUE __INTERNAL_CUSTOM_TURBOPACK_BINDINGS=${NEXT_BINDINGS_BIN} __INTERNAL_NEXT_DEV_TEST_TURBO_GLOB_MATCH=${NEXT_DEV_TEST_GLOB} NEXT_E2E_TEST_TIMEOUT=240000 NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/10 >> /proc/1/fd/1" name: Run test/e2e (dev) if: ${{needs.build.outputs.docsChange == 'nope'}} diff --git a/packages/next-swc/crates/next-dev-tests/tests-manifest.js b/packages/next-swc/crates/next-dev-tests/tests-manifest.js index a76d6f4cb9039..685765d26cfb8 100644 --- a/packages/next-swc/crates/next-dev-tests/tests-manifest.js +++ b/packages/next-swc/crates/next-dev-tests/tests-manifest.js @@ -1,11 +1,300 @@ // Tests that are currently enabled with Turbopack in CI. // This list is not actively used, more of high level pictures of what tests are enabled. const enabledTests = [ + 'test/development/acceptance-app/ReactRefreshLogBoxMisc.test.ts', + 'test/development/acceptance-app/ReactRefreshRequire.test.ts', 'test/development/acceptance-app/dynamic-error.test.ts', + 'test/development/acceptance/ReactRefresh.test.ts', + 'test/development/acceptance/ReactRefreshLogBox-scss.test.ts', + 'test/development/acceptance/ReactRefreshLogBoxMisc.test.ts', + 'test/development/api-cors-with-rewrite/index.test.ts', + 'test/development/app-dir/multiple-compiles-single-route/multiple-compiles-single-route.test.ts', + 'test/development/app-hmr/hmr.test.ts', + 'test/development/basic/define-class-fields.test.ts', + 'test/development/basic/emotion-swc.test.ts', 'test/development/basic/legacy-decorators.test.ts', - 'test/integration/plugin-mdx-rs/test/index.test.js', + 'test/development/basic/styled-components-disabled.test.ts', + 'test/development/basic/tailwind-jit.test.ts', + 'test/development/basic/theme-ui.test.ts', + 'test/development/dotenv-default-expansion/index.test.ts', + 'test/development/jsconfig-path-reloading/index.test.ts', + 'test/development/middleware-warnings/index.test.ts', + 'test/development/project-directory-with-styled-jsx-suffix/index.test.ts', + 'test/development/repeated-dev-edits/repeated-dev-edits.test.ts', + 'test/development/tsconfig-path-reloading/index.test.ts', + 'test/development/typescript-auto-install/index.test.ts', + 'test/e2e/app-dir/_allow-underscored-root-directory/_allow-underscored-root-directory.test.ts', + 'test/e2e/app-dir/actions/app-action-export.test.ts', + 'test/e2e/app-dir/app-alias/app-alias.test.ts', + 'test/e2e/app-dir/app-client-cache/client-cache.test.ts', + 'test/e2e/app-dir/app-css-pageextensions/index.test.ts', + 'test/e2e/app-dir/app-external/app-external.test.ts', + 'test/e2e/app-dir/app-prefetch/prefetching.test.ts', + 'test/e2e/app-dir/app-validation/validation.test.ts', + 'test/e2e/app-dir/app/standalone.test.ts', + 'test/e2e/app-dir/app/useReportWebVitals.test.ts', + 'test/e2e/app-dir/app/vercel-speed-insights.test.ts', + 'test/e2e/app-dir/asset-prefix/asset-prefix.test.ts', + 'test/e2e/app-dir/async-component-preload/async-component-preload.test.ts', + 'test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts', + 'test/e2e/app-dir/back-button-download-bug/back-button-download-bug.test.ts', + 'test/e2e/app-dir/dynamic/dynamic.test.ts', + 'test/e2e/app-dir/global-error/global-error.test.ts', + 'test/e2e/app-dir/import/import.test.ts', + 'test/e2e/app-dir/interpolability-with-pages/navigation.test.ts', + 'test/e2e/app-dir/layout-params/layout-params.test.ts', + 'test/e2e/app-dir/metadata-missing-metadata-base/index.test.ts', + 'test/e2e/app-dir/metadata-suspense/index.test.ts', + 'test/e2e/app-dir/navigation/navigation.test.ts', + 'test/e2e/app-dir/not-found/not-found.test.ts', + 'test/e2e/app-dir/rewrites-redirects/rewrites-redirects.test.ts', + 'test/e2e/app-dir/route-page-manifest-bug/route-page-manifest-bug.test.ts', + 'test/e2e/app-dir/router-autoscroll/router-autoscroll.test.ts', + 'test/e2e/app-dir/router-stuck-dynamic-static-segment/router-stuck-dynamic-static-segment.test.ts', + 'test/e2e/app-dir/rsc-basic/rsc-basic.test.ts', + 'test/e2e/app-dir/search-params-react-key/layout-params.test.ts', + 'test/e2e/app-dir/searchparams-static-bailout/searchparams-static-bailout.test.ts', + 'test/e2e/app-dir/similar-pages-paths/similar-pages-paths.test.ts', + 'test/e2e/app-dir/test-template/{{ toFileName name }}/{{ toFileName name }}.test.ts', 'test/e2e/app-dir/underscore-ignore-app-paths/underscore-ignore-app-paths.test.ts', + 'test/e2e/app-dir/use-params/use-params.test.ts', + 'test/e2e/app-dir/use-selected-layout-segment-s/use-selected-layout-segment-s.test.ts', + 'test/e2e/browserslist-extends/index.test.ts', + 'test/e2e/config-promise-export/async-function.test.ts', + 'test/e2e/config-promise-export/promise.test.ts', + 'test/e2e/disable-js-preload/test/index.test.js', + 'test/e2e/dynamic-route-interpolation/index.test.ts', + 'test/e2e/edge-api-endpoints-can-receive-body/index.test.ts', + 'test/e2e/edge-async-local-storage/index.test.ts', + 'test/e2e/edge-compiler-module-exports-preference/index.test.ts', + 'test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts', + 'test/e2e/handle-non-hoisted-swc-helpers/index.test.ts', + 'test/e2e/ignore-invalid-popstateevent/without-i18n.test.ts', + 'test/e2e/link-with-api-rewrite/index.test.ts', + 'test/e2e/middleware-base-path/test/index.test.ts', + 'test/e2e/middleware-general/test/index.test.ts', + 'test/e2e/middleware-responses/test/index.test.ts', + 'test/e2e/middleware-shallow-link/index.test.ts', + 'test/e2e/multi-zone/multi-zone.test.ts', + 'test/e2e/new-link-behavior/child-a-tag-error.test.ts', + 'test/e2e/new-link-behavior/index.test.ts', + 'test/e2e/new-link-behavior/material-ui.test.ts', + 'test/e2e/new-link-behavior/stitches.test.ts', + 'test/e2e/new-link-behavior/typescript.test.ts', + 'test/e2e/next-image-forward-ref/index.test.ts', + 'test/e2e/no-eslint-warn-with-no-eslint-config/index.test.ts', + 'test/e2e/nonce-head-manager/index.test.ts', + 'test/e2e/optimized-loading/test/index.test.ts', 'test/e2e/postcss-config-cjs/index.test.ts', + 'test/e2e/prerender-native-module.test.ts', + 'test/e2e/proxy-request-with-middleware/test/index.test.ts', + 'test/e2e/repeated-forward-slashes-error/repeated-forward-slashes-error.test.ts', + 'test/e2e/ssr-react-context/index.test.ts', + 'test/e2e/styled-jsx/index.test.ts', + 'test/e2e/test-template/{{ toFileName name }}/{{ toFileName name }}.test.ts', + 'test/e2e/test-utils-tests/basic/basic.test.ts', + 'test/e2e/trailingslash-with-rewrite/index.test.ts', + 'test/e2e/transpile-packages/index.test.ts', + 'test/e2e/type-module-interop/index.test.ts', + 'test/e2e/undici-fetch/index.test.ts', + 'test/e2e/yarn-pnp/test/with-eslint.test.ts', + 'test/e2e/yarn-pnp/test/with-mdx.test.ts', + 'test/e2e/yarn-pnp/test/with-next-sass.test.ts', + 'test/integration/404-page-app/test/index.test.js', + 'test/integration/404-page-custom-error/test/index.test.js', + 'test/integration/404-page-ssg/test/index.test.js', + 'test/integration/absolute-assetprefix/test/index.test.js', + 'test/integration/amp-export-validation/test/index.test.js', + 'test/integration/amphtml-custom-optimizer/test/index.test.js', + 'test/integration/amphtml-custom-validator/test/index.test.js', + 'test/integration/amphtml-fragment-style/test/index.test.js', + 'test/integration/api-body-parser/test/index.test.js', + 'test/integration/api-catch-all/test/index.test.js', + 'test/integration/app-aspath/test/index.test.js', + 'test/integration/app-dir-export/test/config.test.ts', + 'test/integration/app-dir-export/test/dynamicapiroute-prod.test.ts', + 'test/integration/app-dir-export/test/dynamicpage-prod.test.ts', + 'test/integration/app-dir-export/test/start.test.ts', + 'test/integration/app-dir-export/test/trailing-slash-start.test.ts', + 'test/integration/app-document-style-fragment/test/index.test.js', + 'test/integration/app-dynamic-error/test/index.test.ts', + 'test/integration/app-functional/test/index.test.js', + 'test/integration/app-tree/test/index.test.js', + 'test/integration/app-types/app-types.test.js', + 'test/integration/auto-export-error-bail/test/index.test.js', + 'test/integration/auto-export-query-error/test/index.test.js', + 'test/integration/babel-custom/test/index.test.js', + 'test/integration/bigint/test/index.test.js', + 'test/integration/build-output/test/index.test.js', + 'test/integration/build-trace-extra-entries-turbo/test/index.test.js', + 'test/integration/build-trace-extra-entries/test/index.test.js', + 'test/integration/build-warnings/test/index.test.js', + 'test/integration/catches-missing-getStaticProps/test/index.test.js', + 'test/integration/chunking/test/index.test.js', + 'test/integration/clean-distdir/test/index.test.js', + 'test/integration/client-404/test/index.test.js', + 'test/integration/client-navigation-a11y/test/index.test.js', + 'test/integration/client-shallow-routing/test/index.test.js', + 'test/integration/config-experimental-warning/test/index.test.js', + 'test/integration/config-promise-error/test/index.test.js', + 'test/integration/config-resolve-alias/test/index.test.js', + 'test/integration/config-schema-check/test/index.test.js', + 'test/integration/config-syntax-error/test/index.test.js', + 'test/integration/config-validation/test/index.test.ts', + 'test/integration/conflicting-ssg-paths/test/index.test.js', + 'test/integration/create-next-app/index.test.ts', + 'test/integration/create-next-app/templates.test.ts', + 'test/integration/critical-css/test/index.test.js', + 'test/integration/css-customization/test/index.test.js', + 'test/integration/css-features/test/index.test.js', + 'test/integration/css-minify/test/index.test.js', + 'test/integration/custom-error-page-exception/test/index.test.js', + 'test/integration/custom-server-types/test/index.test.js', + 'test/integration/dedupes-scripts/test/index.test.js', + 'test/integration/development-hmr-refresh/test/index.test.js', + 'test/integration/disable-js/test/index.test.js', + 'test/integration/dist-dir/test/index.test.js', + 'test/integration/document-file-dependencies/test/index.test.js', + 'test/integration/document-head-warnings/test/index.test.js', + 'test/integration/duplicate-pages/test/index.test.js', + 'test/integration/dynamic-require/test/index.test.js', + 'test/integration/dynamic-route-rename/test/index.test.js', + 'test/integration/empty-object-getInitialProps/test/index.test.js', + 'test/integration/error-in-error/test/index.test.js', + 'test/integration/error-load-fail/test/index.test.js', + 'test/integration/error-plugin-stack-overflow/test/index.test.js', + 'test/integration/errors-on-output-to-public/test/index.test.js', + 'test/integration/errors-on-output-to-static/test/index.test.js', + 'test/integration/eslint/test/index.test.js', + 'test/integration/export-404/test/index.test.js', + 'test/integration/export-default-map/test/index.test.js', + 'test/integration/export-dynamic-pages/test/index.test.js', + 'test/integration/export-fallback-true-error/test/index.test.js', + 'test/integration/export-getInitialProps-warn/test/index.test.js', + 'test/integration/export-image-default/test/index.test.js', + 'test/integration/export-image-loader-legacy/test/index.test.js', + 'test/integration/export-image-loader/test/index.test.js', + 'test/integration/export-index-not-found-gsp/test/index.test.ts', + 'test/integration/export-intent/test/index.test.js', + 'test/integration/export-no-build/test/index.test.js', + 'test/integration/export-progress-status-message/test/index.test.js', + 'test/integration/export-subfolders/test/index.test.js', + 'test/integration/externalize-next-server/test/index.test.js', + 'test/integration/externals-esm-loose/test/index.test.js', + 'test/integration/externals-esm/test/index.test.js', + 'test/integration/fallback-modules/test/index.test.js', + 'test/integration/fetch-polyfill-ky-universal/test/index.test.js', + 'test/integration/fetch-polyfill/test/index.test.js', + 'test/integration/filesystempublicroutes/test/index.test.js', + 'test/integration/firebase-grpc/test/index.test.js', + 'test/integration/font-optimization/test/index.test.js', + 'test/integration/future/test/index.test.js', + 'test/integration/getserversideprops-export-error/test/index.test.js', + 'test/integration/gip-identifier/test/index.test.js', + 'test/integration/gsp-build-errors/test/index.test.js', + 'test/integration/gsp-extension/test/index.test.js', + 'test/integration/gssp-pageProps-merge/test/index.test.js', + 'test/integration/handles-export-errors/test/index.test.js', + 'test/integration/hashbang/test/index.test.js', + 'test/integration/hydrate-then-render/test/index.test.js', + 'test/integration/hydration/test/index.test.js', + 'test/integration/image-generation/test/index.test.ts', + 'test/integration/image-optimizer/test/old-sharp.test.ts', + 'test/integration/index-index/test/index.test.js', + 'test/integration/initial-ref/test/index.test.js', + 'test/integration/invalid-config-values/test/index.test.js', + 'test/integration/invalid-document-image-import/test/index.test.js', + 'test/integration/invalid-href/test/index.test.js', + 'test/integration/invalid-page-automatic-static-optimization/test/index.test.js', + 'test/integration/invalid-revalidate-values/test/index.test.js', + 'test/integration/invalid-server-options/test/index.test.js', + 'test/integration/jsconfig-empty/test/index.test.js', + 'test/integration/jsconfig/test/index.test.js', + 'test/integration/json-serialize-original-error/test/index.test.js', + 'test/integration/legacy-ssg-methods-error/test/index.test.js', + 'test/integration/link-ref/test/index.test.js', + 'test/integration/link-with-multiple-child/test/index.test.js', + 'test/integration/link-without-router/test/index.test.js', + 'test/integration/middleware-build-errors/test/index.test.js', + 'test/integration/middleware-overrides-node.js-api/test/index.test.ts', + 'test/integration/middleware-prefetch/tests/index.test.js', + 'test/integration/middleware-src/test/index.test.js', + 'test/integration/missing-document-component-error/test/index.test.js', + 'test/integration/mixed-ssg-serverprops-error/test/index.test.js', + 'test/integration/next-dynamic/test/index.test.js', + 'test/integration/next-image-legacy/basic/test/index.test.ts', + 'test/integration/next-image-legacy/custom-resolver/test/index.test.ts', + 'test/integration/next-image-legacy/default/test/static.test.ts', + 'test/integration/next-image-legacy/no-intersection-observer-fallback/test/index.test.ts', + 'test/integration/next-image-legacy/noscript/test/index.test.ts', + 'test/integration/next-image-legacy/react-virtualized/test/index.test.ts', + 'test/integration/next-image-new/react-virtualized/test/index.test.ts', + 'test/integration/no-op-export/test/index.test.js', + 'test/integration/no-page-props/test/index.test.js', + 'test/integration/non-next-dist-exclude/test/index.test.js', + 'test/integration/non-standard-node-env-warning/test/index.test.js', + 'test/integration/not-found-revalidate/test/index.test.js', + 'test/integration/numeric-sep/test/index.test.js', + 'test/integration/ondemand/test/index.test.js', + 'test/integration/optional-chaining-nullish-coalescing/test/index.test.js', + 'test/integration/page-config/test/index.test.js', + 'test/integration/page-extensions/test/index.test.js', + 'test/integration/plugin-mdx-rs/test/index.test.js', + 'test/integration/polyfilling-minimal/test/index.test.js', + 'test/integration/polyfills/test/index.test.js', + 'test/integration/port-env-var/test/index.test.js', + 'test/integration/preload-viewport/test/index.test.js', + 'test/integration/prerender-invalid-catchall-params/test/index.test.js', + 'test/integration/prerender-invalid-paths/test/index.test.js', + 'test/integration/prerender-legacy/test/index.test.js', + 'test/integration/prerender-no-revalidate/test/index.test.js', + 'test/integration/prerender-revalidate/test/index.test.js', + 'test/integration/production-browser-sourcemaps/test/index.test.js', + 'test/integration/production-build-dir/test/index.test.js', + 'test/integration/production-config/test/index.test.js', + 'test/integration/production-nav/test/index.test.js', + 'test/integration/production-start-no-build/test/index.test.js', + 'test/integration/production/test/index.test.js', + 'test/integration/query-with-encoding/test/index.test.js', + 'test/integration/re-export-all-exports-from-page-disallowed/test/index.test.js', + 'test/integration/react-profiling-mode/test/index.test.js', + 'test/integration/react-streaming/test/index.test.js', + 'test/integration/read-only-source-hmr/test/index.test.js', + 'test/integration/relay-analytics-disabled/test/index.test.js', + 'test/integration/relay-analytics/test/index.test.js', + 'test/integration/render-error-on-module-error/test/index.test.js', + 'test/integration/render-error-on-top-level-error/with-get-initial-props/test/index.test.js', + 'test/integration/render-error-on-top-level-error/without-get-initial-props/test/index.test.js', + 'test/integration/required-server-files-ssr-404/test/index.test.js', + 'test/integration/revalidate-as-path/test/index.test.js', + 'test/integration/rewrites-destination-query-array/test/index.test.js', + 'test/integration/root-optional-revalidate/test/index.test.js', + 'test/integration/route-indexes/test/index.test.js', + 'test/integration/route-load-cancel-css/test/index.test.js', + 'test/integration/route-load-cancel/test/index.test.js', + 'test/integration/router-hash-navigation/test/index.test.js', + 'test/integration/router-is-ready-app-gip/test/index.test.js', + 'test/integration/router-is-ready/test/index.test.js', + 'test/integration/router-prefetch/test/index.test.js', + 'test/integration/scss/test/group-2.test.js', + 'test/integration/src-dir-support-double-dir/test/index.test.js', + 'test/integration/src-dir-support/test/index.test.js', + 'test/integration/ssg-data-404/test/index.test.js', + 'test/integration/ssg-dynamic-routes-404-page/test/index.test.js', + 'test/integration/static-404/test/index.test.js', + 'test/integration/static-page-name/test/index.test.js', + 'test/integration/styled-jsx-plugin/test/index.test.js', + 'test/integration/tsconfig-verifier/test/index.test.js', + 'test/integration/turbotrace-with-webpack-worker/test/index.test.js', + 'test/integration/typeof-window-replace/test/index.test.js', + 'test/integration/typescript-baseurl/test/index.test.js', + 'test/integration/typescript-custom-tsconfig/test/index.test.js', + 'test/integration/typescript-filtered-files/test/index.test.js', + 'test/integration/typescript-ignore-errors/test/index.test.js', + 'test/integration/webpack-config-extensionalias/test/index.test.js', + 'test/integration/webpack-config-mainjs/test/index.test.js', + 'test/integration/webpack-require-hook/test/index.test.js', + 'test/integration/with-electron/test/index.test.js', ] // Tests that are currently disabled with Turbopack in CI. @@ -22,153 +311,89 @@ const disabledTests = [ 'test/development/acceptance-app/ReactRefreshLogBox-builtins.test.ts', 'test/development/acceptance-app/ReactRefreshLogBox-scss.test.ts', 'test/development/acceptance-app/ReactRefreshLogBox.test.ts', - 'test/development/acceptance-app/ReactRefreshLogBoxMisc.test.ts', 'test/development/acceptance-app/ReactRefreshModule.test.ts', 'test/development/acceptance-app/ReactRefreshRegression.test.ts', - 'test/development/acceptance-app/ReactRefreshRequire.test.ts', 'test/development/acceptance-app/rsc-build-errors.test.ts', 'test/development/acceptance-app/server-components.test.ts', 'test/development/acceptance-app/version-staleness.test.ts', 'test/development/acceptance/component-stack.test.ts', 'test/development/acceptance/error-recovery.test.ts', 'test/development/acceptance/hydration-error.test.ts', - 'test/development/acceptance/ReactRefresh.test.ts', 'test/development/acceptance/ReactRefreshLogBox-app-doc.test.ts', 'test/development/acceptance/ReactRefreshLogBox-builtins.test.ts', - 'test/development/acceptance/ReactRefreshLogBox-scss.test.ts', 'test/development/acceptance/ReactRefreshLogBox.test.ts', - 'test/development/acceptance/ReactRefreshLogBoxMisc.test.ts', 'test/development/acceptance/ReactRefreshModule.test.ts', 'test/development/acceptance/ReactRefreshRegression.test.ts', 'test/development/acceptance/ReactRefreshRequire.test.ts', 'test/development/acceptance/server-component-compiler-errors-in-pages.test.ts', - 'test/development/api-cors-with-rewrite/index.test.ts', 'test/development/api-route-errors/index.test.ts', - 'test/development/app-dir/multiple-compiles-single-route/multiple-compiles-single-route.test.ts', - 'test/development/app-hmr/hmr.test.ts', 'test/development/app-render-error-log/app-render-error-log.test.ts', - 'test/development/basic/define-class-fields.test.ts', - 'test/development/basic/emotion-swc.test.ts', 'test/development/basic/gssp-ssr-change-reloading/test/index.test.ts', 'test/development/basic/hmr.test.ts', 'test/development/basic/misc.test.ts', 'test/development/basic/next-dynamic.test.ts', 'test/development/basic/node-builtins.test.ts', 'test/development/basic/project-directory-rename.test.ts', - 'test/development/basic/styled-components-disabled.test.ts', 'test/development/basic/styled-components.test.ts', - 'test/development/basic/tailwind-jit.test.ts', - 'test/development/basic/theme-ui.test.ts', 'test/development/client-dev-overlay/index.test.ts', 'test/development/correct-tsconfig-defaults/index.test.ts', - 'test/development/dotenv-default-expansion/index.test.ts', 'test/development/gssp-notfound/index.test.ts', - 'test/development/jsconfig-path-reloading/index.test.ts', - 'test/development/middleware-warnings/index.test.ts', 'test/development/next-font/build-errors.test.ts', 'test/development/next-font/deprecated-package.test.ts', 'test/development/next-font/font-loader-in-document-error.test.ts', - 'test/development/project-directory-with-styled-jsx-suffix/index.test.ts', - 'test/development/repeated-dev-edits/repeated-dev-edits.test.ts', - 'test/development/tsconfig-path-reloading/index.test.ts', - 'test/development/typescript-auto-install/index.test.ts', 'test/development/watch-config-file/index.test.ts', 'test/development/webpack-issuer-deprecation-warning/index.test.ts', 'test/e2e/404-page-router/index.test.ts', 'test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts', - 'test/e2e/app-dir/_allow-underscored-root-directory/_allow-underscored-root-directory.test.ts', - 'test/e2e/app-dir/actions/app-action-export.test.ts', 'test/e2e/app-dir/actions/app-action.test.ts', 'test/e2e/app-dir/app-a11y/index.test.ts', - 'test/e2e/app-dir/app-alias/app-alias.test.ts', 'test/e2e/app-dir/app-basepath/index.test.ts', - 'test/e2e/app-dir/app-client-cache/client-cache.test.ts', - 'test/e2e/app-dir/app-css-pageextensions/index.test.ts', 'test/e2e/app-dir/app-css/index.test.ts', 'test/e2e/app-dir/app-edge/app-edge.test.ts', - 'test/e2e/app-dir/app-external/app-external.test.ts', 'test/e2e/app-dir/app-middleware/app-middleware.test.ts', - 'test/e2e/app-dir/app-prefetch/prefetching.test.ts', 'test/e2e/app-dir/app-rendering/rendering.test.ts', 'test/e2e/app-dir/app-routes-trailing-slash/app-routes-trailing-slash.test.ts', 'test/e2e/app-dir/app-routes/app-custom-routes.test.ts', - 'test/e2e/app-dir/app-static/app-static-custom-handler.test.ts', - 'test/e2e/app-dir/app-static/app-static.test.ts', - 'test/e2e/app-dir/app-validation/validation.test.ts', - 'test/e2e/app-dir/app/index.test.ts', - 'test/e2e/app-dir/app/standalone.test.ts', - 'test/e2e/app-dir/app/useReportWebVitals.test.ts', - 'test/e2e/app-dir/app/vercel-speed-insights.test.ts', - 'test/e2e/app-dir/asset-prefix/asset-prefix.test.ts', - 'test/e2e/app-dir/async-component-preload/async-component-preload.test.ts', - 'test/e2e/app-dir/autoscroll-with-css-modules/index.test.ts', - 'test/e2e/app-dir/back-button-download-bug/back-button-download-bug.test.ts', + 'test/e2e/app-dir/app-static/app-static-custom-handler.test.ts', + 'test/e2e/app-dir/app-static/app-static.test.ts', + 'test/e2e/app-dir/app/index.test.ts', 'test/e2e/app-dir/create-root-layout/create-root-layout.test.ts', 'test/e2e/app-dir/crypto-globally-available/crypto-globally-available.test.ts', 'test/e2e/app-dir/draft-mode/draft-mode-edge.test.ts', 'test/e2e/app-dir/draft-mode/draft-mode-node.test.ts', 'test/e2e/app-dir/dynamic-href/dynamic-href.test.ts', - 'test/e2e/app-dir/dynamic/dynamic.test.ts', 'test/e2e/app-dir/edge-runtime-node-compatibility/edge-runtime-node-compatibility.test.ts', 'test/e2e/app-dir/error-boundary-and-not-found-linking/error-boundary-and-not-found-linking.test.ts', 'test/e2e/app-dir/front-redirect-issue/front-redirect-issue.test.ts', - 'test/e2e/app-dir/global-error/global-error.test.ts', 'test/e2e/app-dir/hooks/hooks.test.ts', 'test/e2e/app-dir/i18n-hybrid/i18n-hybrid.test.js', - 'test/e2e/app-dir/import/import.test.ts', 'test/e2e/app-dir/interception-middleware-rewrite/interception-middleware-rewrite.test.ts', - 'test/e2e/app-dir/interpolability-with-pages/navigation.test.ts', - 'test/e2e/app-dir/layout-params/layout-params.test.ts', 'test/e2e/app-dir/mdx/mdx.test.ts', 'test/e2e/app-dir/metadata-dynamic-routes/index.test.ts', - 'test/e2e/app-dir/metadata-missing-metadata-base/index.test.ts', - 'test/e2e/app-dir/metadata-suspense/index.test.ts', 'test/e2e/app-dir/metadata/metadata.test.ts', - 'test/e2e/app-dir/navigation/navigation.test.ts', 'test/e2e/app-dir/next-font/next-font.test.ts', 'test/e2e/app-dir/next-image/next-image.test.ts', - 'test/e2e/app-dir/not-found/not-found.test.ts', 'test/e2e/app-dir/pages-to-app-routing/pages-to-app-routing.test.ts', 'test/e2e/app-dir/parallel-routes-and-interception/parallel-routes-and-interception.test.ts', 'test/e2e/app-dir/parallel-routes-not-found/parallel-routes-not-found.test.ts', - 'test/e2e/app-dir/rewrites-redirects/rewrites-redirects.test.ts', 'test/e2e/app-dir/root-layout-redirect/root-layout-redirect.test.ts', 'test/e2e/app-dir/root-layout/root-layout.test.ts', - 'test/e2e/app-dir/route-page-manifest-bug/route-page-manifest-bug.test.ts', - 'test/e2e/app-dir/router-autoscroll/router-autoscroll.test.ts', - 'test/e2e/app-dir/router-stuck-dynamic-static-segment/router-stuck-dynamic-static-segment.test.ts', 'test/e2e/app-dir/rsc-basic/rsc-basic.test.ts', - 'test/e2e/app-dir/search-params-react-key/layout-params.test.ts', - 'test/e2e/app-dir/searchparams-static-bailout/searchparams-static-bailout.test.ts', 'test/e2e/app-dir/set-cookies/set-cookies.test.ts', - 'test/e2e/app-dir/similar-pages-paths/similar-pages-paths.test.ts', - 'test/e2e/app-dir/test-template/{{ toFileName name }}/{{ toFileName name }}.test.ts', 'test/e2e/app-dir/trailingslash/trailingslash.test.ts', - 'test/e2e/app-dir/use-params/use-params.test.ts', - 'test/e2e/app-dir/use-selected-layout-segment-s/use-selected-layout-segment-s.test.ts', 'test/e2e/app-dir/with-babel/with-babel.test.ts', 'test/e2e/basepath-trailing-slash.test.ts', 'test/e2e/basepath.test.ts', - 'test/e2e/browserslist-extends/index.test.ts', 'test/e2e/browserslist/browserslist.test.ts', 'test/e2e/browserslist/legacybrowsers-false.test.ts', 'test/e2e/browserslist/legacybrowsers-true.test.ts', - 'test/e2e/config-promise-export/async-function.test.ts', - 'test/e2e/config-promise-export/promise.test.ts', - 'test/e2e/disable-js-preload/test/index.test.js', - 'test/e2e/dynamic-route-interpolation/index.test.ts', - 'test/e2e/edge-api-endpoints-can-receive-body/index.test.ts', - 'test/e2e/edge-async-local-storage/index.test.ts', 'test/e2e/edge-can-read-request-body/index.test.ts', 'test/e2e/edge-can-use-wasm-files/index.test.ts', 'test/e2e/edge-compiler-can-import-blob-assets/index.test.ts', - 'test/e2e/edge-compiler-module-exports-preference/index.test.ts', 'test/e2e/edge-configurable-runtime/index.test.ts', 'test/e2e/edge-pages-support/index.test.ts', - 'test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts', 'test/e2e/fetch-failures-have-good-stack-traces-in-edge-runtime/fetch-failures-have-good-stack-traces-in-edge-runtime.test.ts', 'test/e2e/getserversideprops/test/index.test.ts', - 'test/e2e/handle-non-hoisted-swc-helpers/index.test.ts', 'test/e2e/i18n-api-support/index.test.ts', 'test/e2e/i18n-data-fetching-redirect/index.test.ts', 'test/e2e/i18n-default-locale-redirect/i18n-default-locale-redirect.test.ts', @@ -178,32 +403,20 @@ const disabledTests = [ 'test/e2e/i18n-ignore-rewrite-source-locale/rewrites-with-basepath.test.ts', 'test/e2e/i18n-ignore-rewrite-source-locale/rewrites.test.ts', 'test/e2e/ignore-invalid-popstateevent/with-i18n.test.ts', - 'test/e2e/ignore-invalid-popstateevent/without-i18n.test.ts', 'test/e2e/instrumentation-hook-src/instrumentation-hook-src.test.ts', 'test/e2e/instrumentation-hook/instrumentation-hook.test.ts', - 'test/e2e/link-with-api-rewrite/index.test.ts', 'test/e2e/manual-client-base-path/index.test.ts', - 'test/e2e/middleware-base-path/test/index.test.ts', 'test/e2e/middleware-custom-matchers-basepath/test/index.test.ts', 'test/e2e/middleware-custom-matchers-i18n/test/index.test.ts', 'test/e2e/middleware-custom-matchers/test/index.test.ts', 'test/e2e/middleware-dynamic-basepath-matcher/test/index.test.ts', 'test/e2e/middleware-fetches-with-any-http-method/index.test.ts', 'test/e2e/middleware-fetches-with-body/index.test.ts', - 'test/e2e/middleware-general/test/index.test.ts', 'test/e2e/middleware-matcher/index.test.ts', 'test/e2e/middleware-redirects/test/index.test.ts', 'test/e2e/middleware-request-header-overrides/test/index.test.ts', - 'test/e2e/middleware-responses/test/index.test.ts', 'test/e2e/middleware-rewrites/test/index.test.ts', - 'test/e2e/middleware-shallow-link/index.test.ts', 'test/e2e/middleware-trailing-slash/test/index.test.ts', - 'test/e2e/multi-zone/multi-zone.test.ts', - 'test/e2e/new-link-behavior/child-a-tag-error.test.ts', - 'test/e2e/new-link-behavior/index.test.ts', - 'test/e2e/new-link-behavior/material-ui.test.ts', - 'test/e2e/new-link-behavior/stitches.test.ts', - 'test/e2e/new-link-behavior/typescript.test.ts', 'test/e2e/next-font/basepath.test.ts', 'test/e2e/next-font/google-fetch-error.test.ts', 'test/e2e/next-font/index.test.ts', @@ -211,139 +424,62 @@ const disabledTests = [ 'test/e2e/next-font/with-proxy.test.ts', 'test/e2e/next-font/without-preloaded-fonts.test.ts', 'test/e2e/next-head/index.test.ts', - 'test/e2e/next-image-forward-ref/index.test.ts', 'test/e2e/next-script/index.test.ts', - 'test/e2e/no-eslint-warn-with-no-eslint-config/index.test.ts', - 'test/e2e/nonce-head-manager/index.test.ts', 'test/e2e/og-api/index.test.ts', 'test/e2e/opentelemetry/opentelemetry.test.ts', - 'test/e2e/optimized-loading/test/index.test.ts', 'test/e2e/prerender-crawler.test.ts', - 'test/e2e/prerender-native-module.test.ts', 'test/e2e/prerender.test.ts', - 'test/e2e/proxy-request-with-middleware/test/index.test.ts', 'test/e2e/reload-scroll-backforward-restoration/index.test.ts', - 'test/e2e/repeated-forward-slashes-error/repeated-forward-slashes-error.test.ts', 'test/e2e/skip-trailing-slash-redirect/index.test.ts', - 'test/e2e/ssr-react-context/index.test.ts', 'test/e2e/streaming-ssr/index.test.ts', - 'test/e2e/styled-jsx/index.test.ts', 'test/e2e/swc-warnings/index.test.ts', 'test/e2e/switchable-runtime/index.test.ts', - 'test/e2e/test-template/{{ toFileName name }}/{{ toFileName name }}.test.ts', - 'test/e2e/test-utils-tests/basic/basic.test.ts', - 'test/e2e/trailingslash-with-rewrite/index.test.ts', - 'test/e2e/transpile-packages/index.test.ts', - 'test/e2e/type-module-interop/index.test.ts', - 'test/e2e/undici-fetch/index.test.ts', - 'test/e2e/yarn-pnp/test/with-eslint.test.ts', - 'test/e2e/yarn-pnp/test/with-mdx.test.ts', - 'test/e2e/yarn-pnp/test/with-next-sass.test.ts', 'test/examples/examples.test.ts', - 'test/integration/404-page-app/test/index.test.js', - 'test/integration/404-page-custom-error/test/index.test.js', - 'test/integration/404-page-ssg/test/index.test.js', 'test/integration/404-page/test/index.test.js', 'test/integration/500-page/test/index.test.js', - 'test/integration/absolute-assetprefix/test/index.test.js', - 'test/integration/amp-export-validation/test/index.test.js', - 'test/integration/amphtml-custom-optimizer/test/index.test.js', - 'test/integration/amphtml-custom-validator/test/index.test.js', - 'test/integration/amphtml-fragment-style/test/index.test.js', 'test/integration/amphtml-ssg/test/index.test.js', 'test/integration/amphtml/test/index.test.js', - 'test/integration/api-body-parser/test/index.test.js', - 'test/integration/api-catch-all/test/index.test.js', 'test/integration/api-support/test/index.test.js', - 'test/integration/app-aspath/test/index.test.js', - 'test/integration/app-dir-export/test/config.test.ts', 'test/integration/app-dir-export/test/dynamicapiroute-dev.test.ts', - 'test/integration/app-dir-export/test/dynamicapiroute-prod.test.ts', 'test/integration/app-dir-export/test/dynamicpage-dev.test.ts', - 'test/integration/app-dir-export/test/dynamicpage-prod.test.ts', - 'test/integration/app-dir-export/test/start.test.ts', 'test/integration/app-dir-export/test/trailing-slash-dev.test.ts', - 'test/integration/app-dir-export/test/trailing-slash-start.test.ts', 'test/integration/app-document-add-hmr/test/index.test.js', 'test/integration/app-document-import-order/test/index.test.js', 'test/integration/app-document-remove-hmr/test/index.test.js', - 'test/integration/app-document-style-fragment/test/index.test.js', 'test/integration/app-document/test/index.test.js', - 'test/integration/app-dynamic-error/test/index.test.ts', - 'test/integration/app-functional/test/index.test.js', - 'test/integration/app-tree/test/index.test.js', - 'test/integration/app-types/app-types.test.js', 'test/integration/async-modules/test/index.test.js', - 'test/integration/auto-export-error-bail/test/index.test.js', - 'test/integration/auto-export-query-error/test/index.test.js', 'test/integration/auto-export/test/index.test.js', - 'test/integration/babel-custom/test/index.test.js', 'test/integration/babel/test/index.test.js', 'test/integration/basepath-root-catch-all/test/index.test.js', - 'test/integration/bigint/test/index.test.js', 'test/integration/broken-webpack-plugin/test/index.test.js', 'test/integration/build-indicator/test/index.test.js', - 'test/integration/build-output/test/index.test.js', 'test/integration/build-spinners/index.test.ts', - 'test/integration/build-trace-extra-entries-turbo/test/index.test.js', - 'test/integration/build-trace-extra-entries/test/index.test.js', - 'test/integration/build-warnings/test/index.test.js', - 'test/integration/catches-missing-getStaticProps/test/index.test.js', - 'test/integration/chunking/test/index.test.js', - 'test/integration/clean-distdir/test/index.test.js', 'test/integration/cli/test/index.test.js', - 'test/integration/client-404/test/index.test.js', - 'test/integration/client-navigation-a11y/test/index.test.js', 'test/integration/client-navigation/test/index.test.js', - 'test/integration/client-shallow-routing/test/index.test.js', 'test/integration/compression/test/index.test.js', 'test/integration/config-devtool-dev/test/index.test.js', - 'test/integration/config-experimental-warning/test/index.test.js', 'test/integration/config-mjs/test/index.test.js', 'test/integration/config-output-export/test/index.test.ts', - 'test/integration/config-promise-error/test/index.test.js', - 'test/integration/config-resolve-alias/test/index.test.js', - 'test/integration/config-schema-check/test/index.test.js', - 'test/integration/config-syntax-error/test/index.test.js', - 'test/integration/config-validation/test/index.test.ts', 'test/integration/config/test/index.test.js', 'test/integration/conflicting-app-page-error/test/index.test.js', 'test/integration/conflicting-public-file-page/test/index.test.js', - 'test/integration/conflicting-ssg-paths/test/index.test.js', - 'test/integration/create-next-app/index.test.ts', - 'test/integration/create-next-app/templates.test.ts', - 'test/integration/critical-css/test/index.test.js', 'test/integration/css-client-nav/test/index.test.js', - 'test/integration/css-customization/test/index.test.js', - 'test/integration/css-features/test/index.test.js', - 'test/integration/css-minify/test/index.test.js', 'test/integration/css-modules/test/index.test.js', 'test/integration/css/test/group-1.test.js', 'test/integration/css/test/group-2.test.js', - 'test/integration/custom-error-page-exception/test/index.test.js', 'test/integration/custom-error/test/index.test.js', 'test/integration/custom-page-extension/test/index.test.js', 'test/integration/custom-routes-catchall/test/index.test.js', 'test/integration/custom-routes-i18n-index-redirect/test/index.test.js', 'test/integration/custom-routes-i18n/test/index.test.js', 'test/integration/custom-routes/test/index.test.js', - 'test/integration/custom-server-types/test/index.test.js', 'test/integration/custom-server/test/index.test.js', 'test/integration/data-fetching-errors/test/index.test.js', - 'test/integration/dedupes-scripts/test/index.test.js', - 'test/integration/development-hmr-refresh/test/index.test.js', 'test/integration/development-runtime-config/test/index.test.js', - 'test/integration/disable-js/test/index.test.js', - 'test/integration/dist-dir/test/index.test.js', - 'test/integration/document-file-dependencies/test/index.test.js', - 'test/integration/document-head-warnings/test/index.test.js', 'test/integration/draft-mode/test/index.test.ts', - 'test/integration/duplicate-pages/test/index.test.js', 'test/integration/dynamic-optional-routing-root-fallback/test/index.test.js', 'test/integration/dynamic-optional-routing-root-static-paths/test/index.test.js', 'test/integration/dynamic-optional-routing/test/index.test.js', - 'test/integration/dynamic-require/test/index.test.js', - 'test/integration/dynamic-route-rename/test/index.test.js', 'test/integration/dynamic-routing/test/index.test.js', 'test/integration/dynamic-routing/test/middleware.test.js', 'test/integration/edge-runtime-configurable-guards/test/index.test.js', @@ -352,55 +488,16 @@ const disabledTests = [ 'test/integration/edge-runtime-response-error/test/index.test.js', 'test/integration/edge-runtime-streaming-error/test/index.test.ts', 'test/integration/edge-runtime-with-node.js-apis/test/index.test.ts', - 'test/integration/empty-object-getInitialProps/test/index.test.js', 'test/integration/empty-project/test/index.test.js', 'test/integration/env-config/test/index.test.js', - 'test/integration/error-in-error/test/index.test.js', - 'test/integration/error-load-fail/test/index.test.js', - 'test/integration/error-plugin-stack-overflow/test/index.test.js', - 'test/integration/errors-on-output-to-public/test/index.test.js', - 'test/integration/errors-on-output-to-static/test/index.test.js', - 'test/integration/eslint/test/index.test.js', - 'test/integration/export-404/test/index.test.js', - 'test/integration/export-default-map/test/index.test.js', - 'test/integration/export-dynamic-pages/test/index.test.js', - 'test/integration/export-fallback-true-error/test/index.test.js', - 'test/integration/export-getInitialProps-warn/test/index.test.js', - 'test/integration/export-image-default/test/index.test.js', - 'test/integration/export-image-loader-legacy/test/index.test.js', - 'test/integration/export-image-loader/test/index.test.js', - 'test/integration/export-index-not-found-gsp/test/index.test.ts', - 'test/integration/export-intent/test/index.test.js', - 'test/integration/export-no-build/test/index.test.js', - 'test/integration/export-progress-status-message/test/index.test.js', - 'test/integration/export-subfolders/test/index.test.js', - 'test/integration/externalize-next-server/test/index.test.js', - 'test/integration/externals-esm-loose/test/index.test.js', - 'test/integration/externals-esm/test/index.test.js', 'test/integration/fallback-false-rewrite/test/index.test.js', - 'test/integration/fallback-modules/test/index.test.js', 'test/integration/fallback-route-params/test/index.test.js', - 'test/integration/fetch-polyfill-ky-universal/test/index.test.js', - 'test/integration/fetch-polyfill/test/index.test.js', 'test/integration/file-serving/test/index.test.js', - 'test/integration/filesystempublicroutes/test/index.test.js', - 'test/integration/firebase-grpc/test/index.test.js', - 'test/integration/font-optimization/test/index.test.js', - 'test/integration/future/test/index.test.js', 'test/integration/getinitialprops/test/index.test.js', - 'test/integration/getserversideprops-export-error/test/index.test.js', 'test/integration/getserversideprops-preview/test/index.test.js', - 'test/integration/gip-identifier/test/index.test.js', - 'test/integration/gsp-build-errors/test/index.test.js', - 'test/integration/gsp-extension/test/index.test.js', - 'test/integration/gssp-pageProps-merge/test/index.test.js', 'test/integration/gssp-redirect-base-path/test/index.test.js', 'test/integration/gssp-redirect-with-rewrites/test/index.test.js', 'test/integration/gssp-redirect/test/index.test.js', - 'test/integration/handles-export-errors/test/index.test.js', - 'test/integration/hashbang/test/index.test.js', - 'test/integration/hydrate-then-render/test/index.test.js', - 'test/integration/hydration/test/index.test.js', 'test/integration/i18n-support-base-path/test/index.test.js', 'test/integration/i18n-support-catchall/test/index.test.js', 'test/integration/i18n-support-custom-error/test/index.test.js', @@ -409,57 +506,27 @@ const disabledTests = [ 'test/integration/i18n-support-index-rewrite/test/index.test.js', 'test/integration/i18n-support-same-page-hash-change/test/index.test.js', 'test/integration/i18n-support/test/index.test.js', - 'test/integration/image-generation/test/index.test.ts', 'test/integration/image-optimizer/test/content-disposition-type.test.ts', 'test/integration/image-optimizer/test/index.test.ts', 'test/integration/image-optimizer/test/minimum-cache-ttl.test.ts', - 'test/integration/image-optimizer/test/old-sharp.test.ts', 'test/integration/image-optimizer/test/sharp.test.ts', 'test/integration/image-optimizer/test/squoosh.test.ts', 'test/integration/import-assertion/test/index.test.js', - 'test/integration/index-index/test/index.test.js', - 'test/integration/initial-ref/test/index.test.js', - 'test/integration/invalid-config-values/test/index.test.js', 'test/integration/invalid-custom-routes/test/index.test.js', - 'test/integration/invalid-document-image-import/test/index.test.js', - 'test/integration/invalid-href/test/index.test.js', 'test/integration/invalid-middleware-matchers/test/index.test.js', 'test/integration/invalid-multi-match/test/index.test.js', - 'test/integration/invalid-page-automatic-static-optimization/test/index.test.js', - 'test/integration/invalid-revalidate-values/test/index.test.js', - 'test/integration/invalid-server-options/test/index.test.js', 'test/integration/jsconfig-baseurl/test/index.test.js', - 'test/integration/jsconfig-empty/test/index.test.js', 'test/integration/jsconfig-paths/test/index.test.js', - 'test/integration/jsconfig/test/index.test.js', - 'test/integration/json-serialize-original-error/test/index.test.js', - 'test/integration/legacy-ssg-methods-error/test/index.test.js', - 'test/integration/link-ref/test/index.test.js', 'test/integration/link-with-encoding/test/index.test.js', - 'test/integration/link-with-multiple-child/test/index.test.js', - 'test/integration/link-without-router/test/index.test.js', - 'test/integration/middleware-build-errors/test/index.test.js', 'test/integration/middleware-dev-errors/test/index.test.js', 'test/integration/middleware-dev-update/test/index.test.js', - 'test/integration/middleware-overrides-node.js-api/test/index.test.ts', - 'test/integration/middleware-prefetch/tests/index.test.js', - 'test/integration/middleware-src/test/index.test.js', - 'test/integration/missing-document-component-error/test/index.test.js', - 'test/integration/mixed-ssg-serverprops-error/test/index.test.js', 'test/integration/next-dynamic-css/test/index.test.js', 'test/integration/next-dynamic-lazy-compilation/test/index.test.js', - 'test/integration/next-dynamic/test/index.test.js', 'test/integration/next-image-legacy/asset-prefix/test/index.test.ts', 'test/integration/next-image-legacy/base-path/test/index.test.ts', 'test/integration/next-image-legacy/base-path/test/static.test.ts', - 'test/integration/next-image-legacy/basic/test/index.test.ts', - 'test/integration/next-image-legacy/custom-resolver/test/index.test.ts', 'test/integration/next-image-legacy/default/test/index.test.ts', - 'test/integration/next-image-legacy/default/test/static.test.ts', 'test/integration/next-image-legacy/image-from-node-modules/test/index.test.ts', - 'test/integration/next-image-legacy/no-intersection-observer-fallback/test/index.test.ts', - 'test/integration/next-image-legacy/noscript/test/index.test.ts', - 'test/integration/next-image-legacy/react-virtualized/test/index.test.ts', 'test/integration/next-image-legacy/svgo-webpack/test/index.test.ts', 'test/integration/next-image-legacy/trailing-slash/test/index.test.ts', 'test/integration/next-image-legacy/typescript/test/index.test.ts', @@ -478,93 +545,38 @@ const disabledTests = [ 'test/integration/next-image-new/invalid-image-import/test/index.test.ts', 'test/integration/next-image-new/loader-config-edge-runtime/test/index.test.ts', 'test/integration/next-image-new/loader-config/test/index.test.ts', - 'test/integration/next-image-new/react-virtualized/test/index.test.ts', 'test/integration/next-image-new/svgo-webpack/test/index.test.ts', 'test/integration/next-image-new/trailing-slash/test/index.test.ts', 'test/integration/next-image-new/typescript/test/index.test.ts', 'test/integration/next-image-new/unicode/test/index.test.ts', 'test/integration/next-image-new/unoptimized/test/index.test.ts', 'test/integration/no-duplicate-compile-error/test/index.test.js', - 'test/integration/no-op-export/test/index.test.js', 'test/integration/no-override-next-props/test/index.test.js', - 'test/integration/no-page-props/test/index.test.js', 'test/integration/node-fetch-keep-alive/test/index.test.js', - 'test/integration/non-next-dist-exclude/test/index.test.js', - 'test/integration/non-standard-node-env-warning/test/index.test.js', - 'test/integration/not-found-revalidate/test/index.test.js', 'test/integration/nullish-config/test/index.test.js', - 'test/integration/numeric-sep/test/index.test.js', - 'test/integration/ondemand/test/index.test.js', - 'test/integration/optional-chaining-nullish-coalescing/test/index.test.js', - 'test/integration/page-config/test/index.test.js', - 'test/integration/page-extensions/test/index.test.js', - 'test/integration/polyfilling-minimal/test/index.test.js', - 'test/integration/polyfills/test/index.test.js', - 'test/integration/port-env-var/test/index.test.js', - 'test/integration/preload-viewport/test/index.test.js', 'test/integration/prerender-fallback-encoding/test/index.test.js', - 'test/integration/prerender-invalid-catchall-params/test/index.test.js', - 'test/integration/prerender-invalid-paths/test/index.test.js', - 'test/integration/prerender-legacy/test/index.test.js', - 'test/integration/prerender-no-revalidate/test/index.test.js', 'test/integration/prerender-preview/test/index.test.js', - 'test/integration/prerender-revalidate/test/index.test.js', 'test/integration/prerender/test/index.test.js', 'test/integration/preview-fallback/test/index.test.js', 'test/integration/process-env-stub/test/index.test.js', - 'test/integration/production-browser-sourcemaps/test/index.test.js', - 'test/integration/production-build-dir/test/index.test.js', - 'test/integration/production-config/test/index.test.js', - 'test/integration/production-nav/test/index.test.js', - 'test/integration/production-start-no-build/test/index.test.js', - 'test/integration/production/test/index.test.js', 'test/integration/project-dir-delete/index.test.ts', - 'test/integration/query-with-encoding/test/index.test.js', - 'test/integration/re-export-all-exports-from-page-disallowed/test/index.test.js', 'test/integration/react-18/test/index.test.js', - 'test/integration/react-profiling-mode/test/index.test.js', - 'test/integration/react-streaming/test/index.test.js', - 'test/integration/read-only-source-hmr/test/index.test.js', - 'test/integration/relay-analytics-disabled/test/index.test.js', - 'test/integration/relay-analytics/test/index.test.js', 'test/integration/relay-graphql-swc-multi-project/test/index.test.js', 'test/integration/relay-graphql-swc-single-project/test/index.test.js', - 'test/integration/render-error-on-module-error/test/index.test.js', - 'test/integration/render-error-on-top-level-error/with-get-initial-props/test/index.test.js', - 'test/integration/render-error-on-top-level-error/without-get-initial-props/test/index.test.js', 'test/integration/repeated-slashes/test/index.test.js', - 'test/integration/required-server-files-ssr-404/test/index.test.js', - 'test/integration/revalidate-as-path/test/index.test.js', 'test/integration/rewrite-with-browser-history/test/index.test.js', 'test/integration/rewrites-client-resolving/test/index.test.js', - 'test/integration/rewrites-destination-query-array/test/index.test.js', 'test/integration/rewrites-has-condition/test/index.test.js', 'test/integration/rewrites-manual-href-as/test/index.test.js', - 'test/integration/root-optional-revalidate/test/index.test.js', 'test/integration/route-index/test/index.test.js', - 'test/integration/route-indexes/test/index.test.js', - 'test/integration/route-load-cancel-css/test/index.test.js', - 'test/integration/route-load-cancel/test/index.test.js', - 'test/integration/router-hash-navigation/test/index.test.js', - 'test/integration/router-is-ready-app-gip/test/index.test.js', - 'test/integration/router-is-ready/test/index.test.js', - 'test/integration/router-prefetch/test/index.test.js', 'test/integration/router-rerender/test/index.test.js', 'test/integration/script-loader/test/index.test.js', 'test/integration/scroll-back-restoration/test/index.test.js', 'test/integration/scroll-forward-restoration/test/index.test.js', 'test/integration/scss-modules/test/index.test.js', 'test/integration/scss/test/group-1.test.js', - 'test/integration/scss/test/group-2.test.js', 'test/integration/server-asset-modules/test/index.test.js', 'test/integration/server-side-dev-errors/test/index.test.js', - 'test/integration/src-dir-support-double-dir/test/index.test.js', - 'test/integration/src-dir-support/test/index.test.js', - 'test/integration/ssg-data-404/test/index.test.js', - 'test/integration/ssg-dynamic-routes-404-page/test/index.test.js', - 'test/integration/static-404/test/index.test.js', - 'test/integration/static-page-name/test/index.test.js', - 'test/integration/styled-jsx-plugin/test/index.test.js', 'test/integration/telemetry/test/config.test.js', 'test/integration/telemetry/test/index.test.js', 'test/integration/telemetry/test/page-features.test.js', @@ -572,17 +584,10 @@ const disabledTests = [ 'test/integration/trailing-slashes-href-resolving/test/index.test.js', 'test/integration/trailing-slashes-rewrite/test/index.test.js', 'test/integration/trailing-slashes/test/index.test.js', - 'test/integration/tsconfig-verifier/test/index.test.js', 'test/integration/turbopack-unsupported-log/index.test.ts', - 'test/integration/turbotrace-with-webpack-worker/test/index.test.js', - 'test/integration/typeof-window-replace/test/index.test.js', 'test/integration/typescript-app-type-declarations/test/index.test.js', - 'test/integration/typescript-baseurl/test/index.test.js', - 'test/integration/typescript-custom-tsconfig/test/index.test.js', 'test/integration/typescript-external-dir/project/test/index.test.js', - 'test/integration/typescript-filtered-files/test/index.test.js', 'test/integration/typescript-hmr/test/index.test.js', - 'test/integration/typescript-ignore-errors/test/index.test.js', 'test/integration/typescript-only-remove-type-imports/test/index.test.js', 'test/integration/typescript-paths/test/index.test.js', 'test/integration/typescript-version-warning/test/index.test.js', @@ -591,10 +596,6 @@ const disabledTests = [ 'test/integration/undefined-webpack-config/test/index.test.js', 'test/integration/url-imports/test/index.test.js', 'test/integration/url/test/index.test.js', - 'test/integration/webpack-config-extensionalias/test/index.test.js', - 'test/integration/webpack-config-mainjs/test/index.test.js', - 'test/integration/webpack-require-hook/test/index.test.js', - 'test/integration/with-electron/test/index.test.js', 'test/integration/with-router/test/index.test.js', 'test/integration/worker-webpack5/test/index.test.js', 'test/production/app-dir-edge-runtime-with-wasm/index.test.ts', From ba9aa63417f0811a513f55f1d6d382f1ba256f92 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Tue, 23 May 2023 19:34:54 +0000 Subject: [PATCH 14/15] v13.4.4-canary.5 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 +-- packages/eslint-plugin-next/package.json | 2 +- packages/font/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++----- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 29 ++++++++++++++------ 17 files changed, 44 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index e26a55117899c..9ac71b7d97450 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "13.4.4-canary.4" + "version": "13.4.4-canary.5" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 56db1c731f377..815681707d596 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 2d95541f2b6c8..80625d095e0d6 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "13.4.4-canary.4", + "@next/eslint-plugin-next": "13.4.4-canary.5", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.42.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 67b02008557bc..6644b527b90c8 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "ESLint plugin for NextJS.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index a88c6d79f1be2..0b94bcf9edd55 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 0e27d1900adc9..34f72d8bdb494 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 57185bff33a2f..820c3affa65ed 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 419e20fba13cb..d4527a5fd613d 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 96d7f105df726..8a47f9d0303e1 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index b332a03c13c93..eb03e14eb61b2 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index a65f70e752aee..18b2922596266 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 1ab3929a0bf83..64b737694f86f 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 0a9b5e762a69e..5b25f5638b617 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index caf7862f9b902..01885d00ed794 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@next/env": "13.4.4-canary.4", + "@next/env": "13.4.4-canary.5", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -139,11 +139,11 @@ "@jest/types": "29.5.0", "@napi-rs/cli": "2.14.7", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "13.4.4-canary.4", - "@next/polyfill-nomodule": "13.4.4-canary.4", - "@next/react-dev-overlay": "13.4.4-canary.4", - "@next/react-refresh-utils": "13.4.4-canary.4", - "@next/swc": "13.4.4-canary.4", + "@next/polyfill-module": "13.4.4-canary.5", + "@next/polyfill-nomodule": "13.4.4-canary.5", + "@next/react-dev-overlay": "13.4.4-canary.5", + "@next/react-refresh-utils": "13.4.4-canary.5", + "@next/swc": "13.4.4-canary.5", "@opentelemetry/api": "1.4.1", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 0468838a4c297..b0addd5311fab 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 1929036a3078e..a595ac6f7f35f 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "13.4.4-canary.4", + "version": "13.4.4-canary.5", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85ede6ed46aec..97052117f2a55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -460,7 +460,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 13.4.4-canary.4 + '@next/eslint-plugin-next': 13.4.4-canary.5 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.42.0 eslint: ^7.23.0 || ^8.0.0 @@ -536,12 +536,12 @@ importers: '@jest/types': 29.5.0 '@napi-rs/cli': 2.14.7 '@napi-rs/triples': 1.1.0 - '@next/env': 13.4.4-canary.4 - '@next/polyfill-module': 13.4.4-canary.4 - '@next/polyfill-nomodule': 13.4.4-canary.4 - '@next/react-dev-overlay': 13.4.4-canary.4 - '@next/react-refresh-utils': 13.4.4-canary.4 - '@next/swc': 13.4.4-canary.4 + '@next/env': 13.4.4-canary.5 + '@next/polyfill-module': 13.4.4-canary.5 + '@next/polyfill-nomodule': 13.4.4-canary.5 + '@next/react-dev-overlay': 13.4.4-canary.5 + '@next/react-refresh-utils': 13.4.4-canary.5 + '@next/swc': 13.4.4-canary.5 '@opentelemetry/api': 1.4.1 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.5.1 @@ -5997,7 +5997,7 @@ packages: dependencies: '@mdx-js/mdx': 2.2.1 source-map: 0.7.3 - webpack: 5.74.0_@swc+core@1.3.55 + webpack: 5.74.0 transitivePeerDependencies: - supports-color @@ -6669,6 +6669,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: true optional: true /@swc/core-darwin-x64/1.3.55: @@ -6677,6 +6678,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm-gnueabihf/1.3.55: @@ -6685,6 +6687,7 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm64-gnu/1.3.55: @@ -6693,6 +6696,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-arm64-musl/1.3.55: @@ -6701,6 +6705,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-x64-gnu/1.3.55: @@ -6709,6 +6714,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-linux-x64-musl/1.3.55: @@ -6717,6 +6723,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@swc/core-win32-arm64-msvc/1.3.55: @@ -6725,6 +6732,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core-win32-ia32-msvc/1.3.55: @@ -6733,6 +6741,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core-win32-x64-msvc/1.3.55: @@ -6741,6 +6750,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: true optional: true /@swc/core/1.3.55_@swc+helpers@0.5.1: @@ -6765,6 +6775,7 @@ packages: '@swc/core-win32-arm64-msvc': 1.3.55 '@swc/core-win32-ia32-msvc': 1.3.55 '@swc/core-win32-x64-msvc': 1.3.55 + dev: true /@swc/helpers/0.4.14: resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} @@ -23658,6 +23669,7 @@ packages: source-map: 0.6.1 terser: 5.14.1 webpack: 5.74.0_@swc+core@1.3.55 + dev: true /terser-webpack-plugin/5.2.4_webpack@5.74.0: resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==} @@ -25067,6 +25079,7 @@ packages: - '@swc/core' - esbuild - uglify-js + dev: true /websocket-driver/0.7.3: resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==} From ec8bf53907b7b8e60e1100979a2ed267298696d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 24 May 2023 04:38:07 +0900 Subject: [PATCH 15/15] feat(next-swc): Implement CJS optimizer (#49972) ### What? Implement a CJS optimizer for next-swc ### Why? x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1684341093462309 Assuming most CJS files are transpiled from ESM, we can mimic tree-shaking using an AST transform. ### How? Closes WEB-1072 Fixes #48469 fix NEXT-1156 --------- Co-authored-by: Shu Ding --- Cargo.lock | 2 + packages/next-swc/crates/core/Cargo.toml | 2 + .../next-swc/crates/core/src/cjs_optimizer.rs | 279 ++++++++++++++++++ packages/next-swc/crates/core/src/lib.rs | 16 +- .../next-swc/crates/core/tests/fixture.rs | 48 ++- .../tests/fixture/cjs-optimize/1/input.js | 5 + .../tests/fixture/cjs-optimize/1/output.js | 5 + .../tests/fixture/cjs-optimize/2/input.js | 8 + .../tests/fixture/cjs-optimize/2/output.js | 9 + .../cjs-optimize/not-processed-2/input.js | 3 + .../cjs-optimize/not-processed-2/output.js | 3 + .../cjs-optimize/not-processed-3/input.js | 3 + .../cjs-optimize/not-processed-3/output.js | 3 + .../cjs-optimize/not-processed/input.js | 6 + .../cjs-optimize/not-processed/output.js | 5 + packages/next-swc/crates/core/tests/full.rs | 8 +- .../next-swc/crates/napi/src/transform.rs | 7 +- packages/next-swc/crates/wasm/src/lib.rs | 6 +- packages/next/src/build/swc/options.ts | 13 + packages/next/src/build/webpack-config.ts | 2 +- .../app-dir/app-external/app-external.test.ts | 8 + test/e2e/app-dir/app-external/middleware.js | 7 + .../node_modules_bak/cjs-lib/index.js | 8 + .../node_modules_bak/cjs-lib/package.json | 4 + 24 files changed, 452 insertions(+), 8 deletions(-) create mode 100644 packages/next-swc/crates/core/src/cjs_optimizer.rs create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/input.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/output.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/input.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/output.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/input.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/output.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/input.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/output.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/input.js create mode 100644 packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/output.js create mode 100644 test/e2e/app-dir/app-external/middleware.js create mode 100644 test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/index.js create mode 100644 test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/package.json diff --git a/Cargo.lock b/Cargo.lock index fb22dd0d8ff36..0387a35826e35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3335,6 +3335,7 @@ name = "next-swc" version = "0.0.0" dependencies = [ "chrono", + "convert_case 0.5.0", "easy-error", "either", "fxhash", @@ -3343,6 +3344,7 @@ dependencies = [ "once_cell", "pathdiff", "regex", + "rustc-hash", "serde", "serde_json", "sha1 0.10.5", diff --git a/packages/next-swc/crates/core/Cargo.toml b/packages/next-swc/crates/core/Cargo.toml index d7fc2a94ccb32..9ee942057cb29 100644 --- a/packages/next-swc/crates/core/Cargo.toml +++ b/packages/next-swc/crates/core/Cargo.toml @@ -9,6 +9,7 @@ plugin = ["turbopack-binding/__swc_core_binding_napi_plugin"] [dependencies] chrono = "0.4" +convert_case = "0.5.0" easy-error = "1.0.0" either = "1" fxhash = "0.2.1" @@ -17,6 +18,7 @@ once_cell = { workspace = true } next-transform-font = {workspace = true} pathdiff = "0.2.0" regex = "1.5" +rustc-hash = "1" serde = "1" serde_json = "1" sha1 = "0.10.1" diff --git a/packages/next-swc/crates/core/src/cjs_optimizer.rs b/packages/next-swc/crates/core/src/cjs_optimizer.rs new file mode 100644 index 0000000000000..62d06a7df552c --- /dev/null +++ b/packages/next-swc/crates/core/src/cjs_optimizer.rs @@ -0,0 +1,279 @@ +use rustc_hash::{FxHashMap, FxHashSet}; +use serde::Deserialize; +use turbopack_binding::swc::core::{ + common::{util::take::Take, SyntaxContext, DUMMY_SP}, + ecma::{ + ast::{ + CallExpr, Callee, Decl, Expr, Id, Ident, Lit, MemberExpr, MemberProp, Module, + ModuleItem, Pat, Script, Stmt, VarDecl, VarDeclKind, VarDeclarator, + }, + atoms::{Atom, JsWord}, + utils::{prepend_stmts, private_ident, ExprFactory, IdentRenamer}, + visit::{ + as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, + VisitWith, + }, + }, +}; + +pub fn cjs_optimizer(config: Config, unresolved_ctxt: SyntaxContext) -> impl Fold + VisitMut { + as_folder(CjsOptimizer { + data: State::default(), + packages: config.packages, + unresolved_ctxt, + }) +} + +#[derive(Clone, Debug, Deserialize)] +pub struct Config { + pub packages: FxHashMap, +} + +#[derive(Clone, Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct PackageConfig { + pub transforms: FxHashMap, +} + +struct CjsOptimizer { + data: State, + packages: FxHashMap, + unresolved_ctxt: SyntaxContext, +} + +#[derive(Debug, Default)] +struct State { + /// List of `require` calls **which should be replaced**. + /// + /// `(identifier): (module_record)` + imports: FxHashMap, + + /// `(module_specifier, property): (identifier)` + replaced: FxHashMap<(Atom, JsWord), Id>, + + extra_stmts: Vec, + + rename_map: FxHashMap, + + /// Ignored identifiers for `obj` of [MemberExpr]. + ignored: FxHashSet, + + is_prepass: bool, +} + +#[derive(Debug)] +struct ImportRecord { + module_specifier: Atom, +} + +impl CjsOptimizer { + fn should_rewrite(&self, module_specifier: &str) -> Option<&FxHashMap> { + self.packages.get(module_specifier).map(|v| &v.transforms) + } +} + +impl VisitMut for CjsOptimizer { + noop_visit_mut_type!(); + + fn visit_mut_module_items(&mut self, stmts: &mut Vec) { + self.data.is_prepass = true; + stmts.visit_mut_children_with(self); + self.data.is_prepass = false; + stmts.visit_mut_children_with(self); + } + + fn visit_mut_expr(&mut self, e: &mut Expr) { + e.visit_mut_children_with(self); + + if let Expr::Member(n) = e { + if let MemberProp::Ident(prop) = &n.prop { + if let Expr::Ident(obj) = &*n.obj { + let key = obj.to_id(); + if self.data.ignored.contains(&key) { + return; + } + + if let Some(record) = self.data.imports.get(&key) { + let mut replaced = false; + + let new_id = self + .data + .replaced + .entry((record.module_specifier.clone(), prop.sym.clone())) + .or_insert_with(|| private_ident!(prop.sym.clone()).to_id()) + .clone(); + + if let Some(map) = self.should_rewrite(&record.module_specifier) { + if let Some(renamed) = map.get(&prop.sym) { + replaced = true; + if !self.data.is_prepass { + // Transform as `require('foo').bar` + let var = VarDeclarator { + span: DUMMY_SP, + name: Pat::Ident(new_id.clone().into()), + init: Some(Box::new(Expr::Member(MemberExpr { + span: DUMMY_SP, + obj: Box::new(Expr::Call(CallExpr { + span: DUMMY_SP, + callee: Ident::new( + "require".into(), + DUMMY_SP.with_ctxt(self.unresolved_ctxt), + ) + .as_callee(), + args: vec![Expr::Lit(Lit::Str( + renamed.clone().into(), + )) + .as_arg()], + type_args: None, + })), + prop: MemberProp::Ident(Ident::new( + prop.sym.clone(), + DUMMY_SP.with_ctxt(self.unresolved_ctxt), + )), + }))), + definite: false, + }; + + self.data.extra_stmts.push(Stmt::Decl(Decl::Var(Box::new( + VarDecl { + span: DUMMY_SP, + kind: VarDeclKind::Const, + declare: false, + decls: vec![var], + }, + )))); + + *e = Expr::Ident(new_id.into()); + } + } + } + + if !replaced { + self.data.ignored.insert(key); + } + } + } + } + } + } + + fn visit_mut_module(&mut self, n: &mut Module) { + n.visit_children_with(&mut Analyzer { + data: &mut self.data, + in_member_or_var: false, + }); + + n.visit_mut_children_with(self); + + prepend_stmts( + &mut n.body, + self.data.extra_stmts.drain(..).map(ModuleItem::Stmt), + ); + + n.visit_mut_children_with(&mut IdentRenamer::new(&self.data.rename_map)); + } + + fn visit_mut_script(&mut self, n: &mut Script) { + n.visit_children_with(&mut Analyzer { + data: &mut self.data, + in_member_or_var: false, + }); + + n.visit_mut_children_with(self); + + prepend_stmts(&mut n.body, self.data.extra_stmts.drain(..)); + + n.visit_mut_children_with(&mut IdentRenamer::new(&self.data.rename_map)); + } + + fn visit_mut_stmt(&mut self, n: &mut Stmt) { + n.visit_mut_children_with(self); + + if let Stmt::Decl(Decl::Var(v)) = n { + if v.decls.is_empty() { + n.take(); + } + } + } + + fn visit_mut_var_declarator(&mut self, n: &mut VarDeclarator) { + n.visit_mut_children_with(self); + + // Find `require('foo')` + if let Some(Expr::Call(CallExpr { + callee: Callee::Expr(callee), + args, + .. + })) = n.init.as_deref() + { + if let Expr::Ident(ident) = &**callee { + if ident.span.ctxt == self.unresolved_ctxt && ident.sym == *"require" { + if let Some(arg) = args.get(0) { + if let Expr::Lit(Lit::Str(v)) = &*arg.expr { + // TODO: Config + + if let Pat::Ident(name) = &n.name { + if let Some(..) = self.should_rewrite(&v.value) { + let key = name.to_id(); + + if !self.data.is_prepass { + if !self.data.ignored.contains(&key) { + // Drop variable declarator. + n.name.take(); + } + } else { + self.data.imports.insert( + key, + ImportRecord { + module_specifier: v.value.clone().into(), + }, + ); + } + } + } + } + } + } + } + } + } + + fn visit_mut_var_declarators(&mut self, n: &mut Vec) { + n.visit_mut_children_with(self); + + // We make `name` invalid if we should drop it. + n.retain(|v| !v.name.is_invalid()); + } +} + +struct Analyzer<'a> { + in_member_or_var: bool, + data: &'a mut State, +} + +impl Visit for Analyzer<'_> { + noop_visit_type!(); + + fn visit_var_declarator(&mut self, n: &VarDeclarator) { + self.in_member_or_var = true; + n.visit_children_with(self); + self.in_member_or_var = false; + } + + fn visit_member_expr(&mut self, e: &MemberExpr) { + self.in_member_or_var = true; + e.visit_children_with(self); + self.in_member_or_var = false; + + if let (Expr::Ident(obj), MemberProp::Computed(..)) = (&*e.obj, &e.prop) { + self.data.ignored.insert(obj.to_id()); + } + } + + fn visit_ident(&mut self, i: &Ident) { + i.visit_children_with(self); + if !self.in_member_or_var { + self.data.ignored.insert(i.to_id()); + } + } +} diff --git a/packages/next-swc/crates/core/src/lib.rs b/packages/next-swc/crates/core/src/lib.rs index 790492a29ab50..becf6f71687f5 100644 --- a/packages/next-swc/crates/core/src/lib.rs +++ b/packages/next-swc/crates/core/src/lib.rs @@ -38,7 +38,10 @@ use fxhash::FxHashSet; use next_transform_font::next_font_loaders; use serde::Deserialize; use turbopack_binding::swc::core::{ - common::{chain, comments::Comments, pass::Optional, FileName, SourceFile, SourceMap}, + common::{ + chain, comments::Comments, pass::Optional, FileName, Mark, SourceFile, SourceMap, + SyntaxContext, + }, ecma::{ ast::EsVersion, parser::parse_file_as_module, transforms::base::pass::noop, visit::Fold, }, @@ -46,6 +49,7 @@ use turbopack_binding::swc::core::{ pub mod amp_attributes; mod auto_cjs; +pub mod cjs_optimizer; pub mod disallow_re_export_all_in_page; pub mod next_dynamic; pub mod next_ssg; @@ -125,6 +129,9 @@ pub struct TransformOptions { #[serde(default)] pub server_actions: Option, + + #[serde(default)] + pub cjs_require_optimizer: Option, } pub fn custom_before_pass<'a, C: Comments + 'a>( @@ -133,6 +140,7 @@ pub fn custom_before_pass<'a, C: Comments + 'a>( opts: &'a TransformOptions, comments: C, eliminated_packages: Rc>>, + unresolved_mark: Mark, ) -> impl Fold + 'a where C: Clone, @@ -277,6 +285,12 @@ where )), None => Either::Right(noop()), }, + match &opts.cjs_require_optimizer { + Some(config) => { + Either::Left(cjs_optimizer::cjs_optimizer(config.clone(), SyntaxContext::empty().apply_mark(unresolved_mark))) + }, + None => Either::Right(noop()), + }, ) } diff --git a/packages/next-swc/crates/core/tests/fixture.rs b/packages/next-swc/crates/core/tests/fixture.rs index ac7a28d0ec162..43027af140233 100644 --- a/packages/next-swc/crates/core/tests/fixture.rs +++ b/packages/next-swc/crates/core/tests/fixture.rs @@ -2,6 +2,7 @@ use std::{env::current_dir, path::PathBuf}; use next_swc::{ amp_attributes::amp_attributes, + cjs_optimizer::cjs_optimizer, next_dynamic::next_dynamic, next_ssg::next_ssg, page_config::page_config_test, @@ -12,9 +13,10 @@ use next_swc::{ shake_exports::{shake_exports, Config as ShakeExportsConfig}, }; use next_transform_font::{next_font_loaders, Config as FontLoaderConfig}; +use serde::de::DeserializeOwned; use turbopack_binding::swc::{ core::{ - common::{chain, comments::SingleThreadedComments, FileName, Mark}, + common::{chain, comments::SingleThreadedComments, FileName, Mark, SyntaxContext}, ecma::{ parser::{EsConfig, Syntax}, transforms::{ @@ -354,3 +356,47 @@ fn server_actions_client_fixture(input: PathBuf) { Default::default(), ); } + +#[fixture("tests/fixture/cjs-optimize/**/input.js")] +fn cjs_optimize_fixture(input: PathBuf) { + let output = input.parent().unwrap().join("output.js"); + test_fixture( + syntax(), + &|_tr| { + let unresolved_mark = Mark::new(); + let top_level_mark = Mark::new(); + + let unresolved_ctxt = SyntaxContext::empty().apply_mark(unresolved_mark); + + chain!( + resolver(unresolved_mark, top_level_mark, false), + cjs_optimizer( + json( + r###" + { + "packages": { + "next/server": { + "transforms": { + "Response": "next/server/response" + } + } + } + } + "### + ), + unresolved_ctxt + ) + ) + }, + &input, + &output, + Default::default(), + ); +} + +fn json(s: &str) -> T +where + T: DeserializeOwned, +{ + serde_json::from_str(s).expect("failed to deserialize") +} diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/input.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/input.js new file mode 100644 index 0000000000000..2ae2c355a7cd1 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/input.js @@ -0,0 +1,5 @@ +const foo = require('next/server') +const preserved = require('next/unmatched') + +console.log(foo.Response) +console.log(preserved.Preserved) diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/output.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/output.js new file mode 100644 index 0000000000000..b0bd4b27550fe --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/1/output.js @@ -0,0 +1,5 @@ +const Response = require("next/server/response").Response; +; +const preserved = require('next/unmatched'); +console.log(Response); +console.log(preserved.Preserved); diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/input.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/input.js new file mode 100644 index 0000000000000..9984cbbe4b93c --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/input.js @@ -0,0 +1,8 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +const server_1 = require('next/server') +const createResponse = (...args) => { + return new server_1.Response(...args) +} diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/output.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/output.js new file mode 100644 index 0000000000000..5c75490fb5990 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/2/output.js @@ -0,0 +1,9 @@ +'use strict'; +const Response = require("next/server/response").Response; +Object.defineProperty(exports, '__esModule', { + value: true +}); +; +const createResponse = (...args)=>{ + return new Response(...args); +}; diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/input.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/input.js new file mode 100644 index 0000000000000..c2f964a50dd9c --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/input.js @@ -0,0 +1,3 @@ +const foo = require('next/server') + +console.log(foo.bar) diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/output.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/output.js new file mode 100644 index 0000000000000..1196b63767b97 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-2/output.js @@ -0,0 +1,3 @@ +const foo = require('next/server'); + +console.log(foo.bar); diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/input.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/input.js new file mode 100644 index 0000000000000..034aa33d132ea --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/input.js @@ -0,0 +1,3 @@ +const foo = require('next/server') + +console.log(foo) diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/output.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/output.js new file mode 100644 index 0000000000000..7699c791c3f16 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed-3/output.js @@ -0,0 +1,3 @@ +const foo = require('next/server'); + +console.log(foo); diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/input.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/input.js new file mode 100644 index 0000000000000..14c75b0809a2b --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/input.js @@ -0,0 +1,6 @@ +const foo = require('next/server') +const preserved = require('next/unmatched') + +console.log(foo.Response) +console.log(foo['Re' + 'spawn']) +console.log(preserved.Preserved) diff --git a/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/output.js b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/output.js new file mode 100644 index 0000000000000..590e9ef5a14d1 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/cjs-optimize/not-processed/output.js @@ -0,0 +1,5 @@ +const foo = require('next/server'); +const preserved = require('next/unmatched'); +console.log(foo.Response); +console.log(foo['Re' + 'spawn']); +console.log(preserved.Preserved); diff --git a/packages/next-swc/crates/core/tests/full.rs b/packages/next-swc/crates/core/tests/full.rs index 98920786b657f..0c1d5f83731fb 100644 --- a/packages/next-swc/crates/core/tests/full.rs +++ b/packages/next-swc/crates/core/tests/full.rs @@ -5,7 +5,7 @@ use serde::de::DeserializeOwned; use turbopack_binding::swc::{ core::{ base::Compiler, - common::comments::SingleThreadedComments, + common::{comments::SingleThreadedComments, Mark}, ecma::{ parser::{Syntax, TsConfig}, transforms::base::pass::noop, @@ -77,9 +77,12 @@ fn test(input: &Path, minify: bool) { font_loaders: None, app_dir: None, server_actions: None, + cjs_require_optimizer: None, }; - let options = options.patch(&fm); + let unresolved_mark = Mark::new(); + let mut options = options.patch(&fm); + options.swc.unresolved_mark = Some(unresolved_mark); let comments = SingleThreadedComments::default(); match c.process_js_with_custom_pass( @@ -95,6 +98,7 @@ fn test(input: &Path, minify: bool) { &options, comments.clone(), Default::default(), + unresolved_mark, ) }, |_| noop(), diff --git a/packages/next-swc/crates/napi/src/transform.rs b/packages/next-swc/crates/napi/src/transform.rs index 1c52fbd61031d..a3f1bdff562ed 100644 --- a/packages/next-swc/crates/napi/src/transform.rs +++ b/packages/next-swc/crates/napi/src/transform.rs @@ -40,7 +40,7 @@ use napi::bindgen_prelude::*; use next_swc::{custom_before_pass, TransformOptions}; use turbopack_binding::swc::core::{ base::{try_with_handler, Compiler, TransformOutput}, - common::{comments::SingleThreadedComments, errors::ColorConfig, FileName, GLOBALS}, + common::{comments::SingleThreadedComments, errors::ColorConfig, FileName, Mark, GLOBALS}, ecma::transforms::base::pass::noop, }; @@ -107,7 +107,9 @@ impl Task for TransformTask { ) } }; - let options = options.patch(&fm); + let unresolved_mark = Mark::new(); + let mut options = options.patch(&fm); + options.swc.unresolved_mark = Some(unresolved_mark); let cm = self.c.cm.clone(); let file = fm.clone(); @@ -126,6 +128,7 @@ impl Task for TransformTask { &options, comments.clone(), eliminated_packages.clone(), + unresolved_mark, ) }, |_| noop(), diff --git a/packages/next-swc/crates/wasm/src/lib.rs b/packages/next-swc/crates/wasm/src/lib.rs index 32b9d35118f2e..bfd8d42f8694c 100644 --- a/packages/next-swc/crates/wasm/src/lib.rs +++ b/packages/next-swc/crates/wasm/src/lib.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use anyhow::{Context, Error}; use js_sys::JsString; use next_swc::{custom_before_pass, TransformOptions}; +use swc_core::common::Mark; use turbopack_binding::swc::core::{ base::{ config::{JsMinifyOptions, ParseOptions}, @@ -66,7 +67,9 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result { console_error_panic_hook::set_once(); let c = compiler(); - let opts: TransformOptions = serde_wasm_bindgen::from_value(opts)?; + let unresolved_mark = Mark::new(); + let mut opts: TransformOptions = serde_wasm_bindgen::from_value(opts)?; + opts.swc.unresolved_mark = Some(unresolved_mark); let s = s.dyn_into::(); let out = try_with_handler( @@ -103,6 +106,7 @@ pub fn transform_sync(s: JsValue, opts: JsValue) -> Result { &opts, comments.clone(), Default::default(), + unresolved_mark, ) }, |_| noop(), diff --git a/packages/next/src/build/swc/options.ts b/packages/next/src/build/swc/options.ts index 722692f4f8055..0d8ecf6bf773c 100644 --- a/packages/next/src/build/swc/options.ts +++ b/packages/next/src/build/swc/options.ts @@ -330,6 +330,19 @@ export function getLoaderSWCOptions({ ], relativeFilePathFromRoot, } + baseOptions.cjsRequireOptimizer = { + packages: { + 'next/server': { + transforms: { + NextRequest: 'next/dist/server/web/spec-extension/request', + NextResponse: 'next/dist/server/web/spec-extension/response', + ImageResponse: 'next/dist/server/web/spec-extension/image-response', + userAgentFromString: 'next/dist/server/web/spec-extension/user-agent', + userAgent: 'next/dist/server/web/spec-extension/user-agent', + }, + }, + }, + } const isNextDist = nextDistPath.test(filename) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index de1537cd0d98d..615c659e2399a 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1999,7 +1999,7 @@ export default async function getBaseWebpackConfig( use: loaderForAPIRoutes, }, { - ...codeCondition, + test: codeCondition.test, issuerLayer: WEBPACK_LAYERS.middleware, use: defaultLoaders.babel, }, diff --git a/test/e2e/app-dir/app-external/app-external.test.ts b/test/e2e/app-dir/app-external/app-external.test.ts index 5f791b1897a2f..e69b5b80b50ad 100644 --- a/test/e2e/app-dir/app-external/app-external.test.ts +++ b/test/e2e/app-dir/app-external/app-external.test.ts @@ -211,5 +211,13 @@ createNextDescribe( ) }) } + + it('should have proper tree-shaking for known modules in CJS', async () => { + const html = await next.render('/test-middleware') + expect(html).toContain('it works') + + const middlewareBundle = await next.readFile('.next/server/middleware.js') + expect(middlewareBundle).not.toContain('image-response') + }) } ) diff --git a/test/e2e/app-dir/app-external/middleware.js b/test/e2e/app-dir/app-external/middleware.js new file mode 100644 index 0000000000000..bc818e60c7318 --- /dev/null +++ b/test/e2e/app-dir/app-external/middleware.js @@ -0,0 +1,7 @@ +import { createResponse } from 'cjs-lib' + +export function middleware(request) { + if (request.nextUrl.pathname === '/test-middleware') { + return createResponse('it works') + } +} diff --git a/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/index.js b/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/index.js new file mode 100644 index 0000000000000..a6865d191cd98 --- /dev/null +++ b/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/index.js @@ -0,0 +1,8 @@ +Object.defineProperty(exports, '__esModule', { value: true }) +const server_1 = require('next/server') +const createResponse = (...args) => { + return new server_1.NextResponse(...args) +} +exports.createResponse = createResponse + +// Note: this is a CJS library that used the `NextResponse` export from `next/server`. diff --git a/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/package.json b/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/package.json new file mode 100644 index 0000000000000..3b26284716ace --- /dev/null +++ b/test/e2e/app-dir/app-external/node_modules_bak/cjs-lib/package.json @@ -0,0 +1,4 @@ +{ + "name": "cjs-lib", + "exports": "./index.js" +}