From 73c905dc53300b5c22ee69e9988deadce904e40d Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:34:04 -0700 Subject: [PATCH 01/30] feat(next-dev): add a new experimental flag (#51895) ### What? WEB-1239. This is mainly for the code paths to not to cause regressions to existing turbopack. --- packages/next-swc/crates/napi/src/turbopack.rs | 5 +++++ packages/next/src/build/swc/index.ts | 9 +++++++++ packages/next/src/cli/next-dev.ts | 8 ++++++++ packages/next/src/server/lib/start-server.ts | 1 + 4 files changed, 23 insertions(+) diff --git a/packages/next-swc/crates/napi/src/turbopack.rs b/packages/next-swc/crates/napi/src/turbopack.rs index 04e5c18c2e1e..56046e394b0e 100644 --- a/packages/next-swc/crates/napi/src/turbopack.rs +++ b/packages/next-swc/crates/napi/src/turbopack.rs @@ -181,3 +181,8 @@ impl From for RouteHas { pub async fn next_build(ctx: NextBuildContext) -> napi::Result<()> { turbo_next_build(ctx.try_into()?).await.convert_err() } + +#[napi] +pub async fn experimental_turbo(_unused: Buffer) -> napi::Result<()> { + unimplemented!("__experimental_turbo is not yet implemented"); +} diff --git a/packages/next/src/build/swc/index.ts b/packages/next/src/build/swc/index.ts index e08dc42ea1a2..3b779c46ee1d 100644 --- a/packages/next/src/build/swc/index.ts +++ b/packages/next/src/build/swc/index.ts @@ -296,6 +296,9 @@ async function loadWasm(importPath = '', isCustomTurbopack: boolean) { startTrace: () => { Log.error('Wasm binding does not support trace yet') }, + experimentalTurbo: () => { + Log.error('Wasm binding does not support this interface') + }, entrypoints: { stream: ( turboTasks: any, @@ -555,6 +558,12 @@ function loadNative(isCustomTurbopack = false) { ) return ret }, + experimentalTurbo: () => { + initHeapProfiler() + + const ret = bindings.experimentalTurbo() + return ret + }, createTurboTasks: (memoryLimit?: number): unknown => bindings.createTurboTasks(memoryLimit), entrypoints: { diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index c9f16183e27d..e019a0bf6767 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -119,6 +119,7 @@ const nextDev: CliCommand = async (argv) => { '--port': Number, '--hostname': String, '--turbo': Boolean, + '--experimental-turbo': Boolean, // To align current messages with native binary. // Will need to adjust subcommand later. @@ -209,6 +210,7 @@ const nextDev: CliCommand = async (argv) => { // We do not set a default host value here to prevent breaking // some set-ups that rely on listening on other interfaces const host = args['--hostname'] + const experimentalTurbo = args['--experimental-turbo'] const devServerOptions: StartServerOptions = { dir, @@ -218,6 +220,7 @@ const nextDev: CliCommand = async (argv) => { hostname: host, // This is required especially for app dir. useWorkers: true, + isExperimentalTurbo: experimentalTurbo, } if (args['--turbo']) { @@ -311,6 +314,11 @@ const nextDev: CliCommand = async (argv) => { return server } else { + if (experimentalTurbo) { + Log.error('Not supported yet') + process.exit(1) + } + let cleanupFns: (() => Promise | void)[] = [] const runDevServer = async () => { const oldCleanupFns = cleanupFns diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index 50fa905a53ad..e10a34e1fb64 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -22,6 +22,7 @@ export interface StartServerOptions { useWorkers: boolean allowRetry?: boolean isTurbopack?: boolean + isExperimentalTurbo?: boolean keepAliveTimeout?: number onStdout?: (data: any) => void onStderr?: (data: any) => void From a3d3016de866f1ad128bbf13111187eaf999d4b5 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Tue, 27 Jun 2023 12:46:23 -0700 Subject: [PATCH 02/30] next/node-polyfill-web-streams: fix web stream polyfill for Node v16 (#51901) ### What? Slack thread: https://vercel.slack.com/archives/C050WU03V3N/p1687889719318819 In Node 16, the ReadableStream is not on the global but instead under the `stream` package. We should polyfill the global with that implementation, if available ### Why? Fixes passing ReadableStream from the Node.js runtime to the vercel/ai SDK. --- .../src/server/node-polyfill-web-streams.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/next/src/server/node-polyfill-web-streams.ts b/packages/next/src/server/node-polyfill-web-streams.ts index 88e0f9091b87..2d76b62331bb 100644 --- a/packages/next/src/server/node-polyfill-web-streams.ts +++ b/packages/next/src/server/node-polyfill-web-streams.ts @@ -1,11 +1,22 @@ // Polyfill Web Streams for the Node.js runtime. if (!global.ReadableStream) { - const { ReadableStream } = - require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') - global.ReadableStream = ReadableStream + // In Node v16, ReadableStream is available natively but under the `stream` namespace. + // In Node v18+, it's available under global. + if (require('stream').ReadableStream) { + global.ReadableStream = require('stream').ReadableStream + } else { + const { ReadableStream } = + require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') + global.ReadableStream = ReadableStream + } } if (!global.TransformStream) { - const { TransformStream } = - require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') - global.TransformStream = TransformStream + // Same as ReadableStream above. + if (require('stream').TransformStream) { + global.TransformStream = require('stream').TransformStream + } else { + const { TransformStream } = + require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') + global.TransformStream = TransformStream + } } From 25629bb880e14e7f8bf5e0a5ae9124b153e58294 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Tue, 27 Jun 2023 15:09:45 -0700 Subject: [PATCH 03/30] node-polyfill-web-streams: require from stream/web instead of stream (#51906) Follow-up to #51901 --- packages/next/src/server/node-polyfill-web-streams.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/next/src/server/node-polyfill-web-streams.ts b/packages/next/src/server/node-polyfill-web-streams.ts index 2d76b62331bb..fd09f5ecf034 100644 --- a/packages/next/src/server/node-polyfill-web-streams.ts +++ b/packages/next/src/server/node-polyfill-web-streams.ts @@ -2,8 +2,8 @@ if (!global.ReadableStream) { // In Node v16, ReadableStream is available natively but under the `stream` namespace. // In Node v18+, it's available under global. - if (require('stream').ReadableStream) { - global.ReadableStream = require('stream').ReadableStream + if (require('stream/web').ReadableStream) { + global.ReadableStream = require('stream/web').ReadableStream } else { const { ReadableStream } = require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') @@ -12,8 +12,8 @@ if (!global.ReadableStream) { } if (!global.TransformStream) { // Same as ReadableStream above. - if (require('stream').TransformStream) { - global.TransformStream = require('stream').TransformStream + if (require('stream/web').TransformStream) { + global.TransformStream = require('stream/web').TransformStream } else { const { TransformStream } = require('next/dist/compiled/@edge-runtime/ponyfill') as typeof import('next/dist/compiled/@edge-runtime/ponyfill') From 2c856cb256c8cbf271d6fb393260a04469200624 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Tue, 27 Jun 2023 23:04:22 +0000 Subject: [PATCH 04/30] v13.4.8-canary.7 --- 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 | 14 +++++++------- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lerna.json b/lerna.json index 7802fa87580e..bb34fdce6624 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "13.4.8-canary.6" + "version": "13.4.8-canary.7" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index f4eb12c87ba6..da374bb09b28 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.8-canary.6", + "version": "13.4.8-canary.7", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 66c4e818bd9c..ed8e0831efdd 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.8-canary.6", + "version": "13.4.8-canary.7", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "13.4.8-canary.6", + "@next/eslint-plugin-next": "13.4.8-canary.7", "@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 b61b5e4087cd..d6116eef68a9 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.8-canary.6", + "version": "13.4.8-canary.7", "description": "ESLint plugin for NextJS.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 4abc96ac417a..6d595f5b09d7 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "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 24b54590b846..0ed0cce9f330 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.8-canary.6", + "version": "13.4.8-canary.7", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 498e2ac1ca09..6b3bb08bce70 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 85084a3f5cdc..7bc863919375 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index c1214ab0a5e5..f91fc894dc2f 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 4eb1c0e5d758..b7cca611858b 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.8-canary.6", + "version": "13.4.8-canary.7", "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 c489d8978abd..1cf588bcdc32 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.8-canary.6", + "version": "13.4.8-canary.7", "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 d063e727e604..2dc7f355cbd7 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.8-canary.6", + "version": "13.4.8-canary.7", "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 c2b0b52a397c..87b06edaa84e 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index ec5145abfd7f..aa17711c1e62 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "13.4.8-canary.6", + "version": "13.4.8-canary.7", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@next/env": "13.4.8-canary.6", + "@next/env": "13.4.8-canary.7", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -141,11 +141,11 @@ "@jest/types": "29.5.0", "@napi-rs/cli": "2.14.7", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "13.4.8-canary.6", - "@next/polyfill-nomodule": "13.4.8-canary.6", - "@next/react-dev-overlay": "13.4.8-canary.6", - "@next/react-refresh-utils": "13.4.8-canary.6", - "@next/swc": "13.4.8-canary.6", + "@next/polyfill-module": "13.4.8-canary.7", + "@next/polyfill-nomodule": "13.4.8-canary.7", + "@next/react-dev-overlay": "13.4.8-canary.7", + "@next/react-refresh-utils": "13.4.8-canary.7", + "@next/swc": "13.4.8-canary.7", "@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 caffc6ccf776..833adf50191e 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.8-canary.6", + "version": "13.4.8-canary.7", "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 62b1d04ab9ab..c241ab12ba4d 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.8-canary.6", + "version": "13.4.8-canary.7", "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 fe07461f0011..9857f969bcf0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -436,7 +436,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 13.4.8-canary.6 + '@next/eslint-plugin-next': 13.4.8-canary.7 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.42.0 eslint: ^7.23.0 || ^8.0.0 @@ -513,12 +513,12 @@ importers: '@jest/types': 29.5.0 '@napi-rs/cli': 2.14.7 '@napi-rs/triples': 1.1.0 - '@next/env': 13.4.8-canary.6 - '@next/polyfill-module': 13.4.8-canary.6 - '@next/polyfill-nomodule': 13.4.8-canary.6 - '@next/react-dev-overlay': 13.4.8-canary.6 - '@next/react-refresh-utils': 13.4.8-canary.6 - '@next/swc': 13.4.8-canary.6 + '@next/env': 13.4.8-canary.7 + '@next/polyfill-module': 13.4.8-canary.7 + '@next/polyfill-nomodule': 13.4.8-canary.7 + '@next/react-dev-overlay': 13.4.8-canary.7 + '@next/react-refresh-utils': 13.4.8-canary.7 + '@next/swc': 13.4.8-canary.7 '@opentelemetry/api': 1.4.1 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.5.1 From 702d3d291c47a860bb57132a996034d11765547f Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 28 Jun 2023 01:57:06 +0200 Subject: [PATCH 05/30] Add retries and clear message to font fetching (#51890) Improve the problems mentioned in #45080. - Adding error retries (3 attempts) to font fetching. When you have a slow network, it might take >3s to load. - Improve the error message to tell you that you might have unstable network connection. - Do not cause build error (caused by missing `AbortController`) in Node 14 (even if we don't support Node 14, better to pass the build instead of hard error). --- .../src/google/fetch-css-from-google-fonts.ts | 66 ++++++++++++++----- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/packages/font/src/google/fetch-css-from-google-fonts.ts b/packages/font/src/google/fetch-css-from-google-fonts.ts index bf22758c4b3b..5c6fedf21349 100644 --- a/packages/font/src/google/fetch-css-from-google-fonts.ts +++ b/packages/font/src/google/fetch-css-from-google-fonts.ts @@ -3,6 +3,22 @@ import fetch from 'next/dist/compiled/node-fetch' import { nextFontError } from '../next-font-error' import { getProxyAgent } from './get-proxy-agent' +async function retry(fn: () => Promise, attempts: number): Promise { + let cnt = attempts + while (true) { + try { + return await fn() + } catch (err) { + cnt-- + if (cnt <= 0) throw err + console.error( + (err as Error).message + `\n\nRetrying ${attempts - cnt}/3...` + ) + await new Promise((resolve) => setTimeout(resolve, 100)) + } + } +} + /** * Fetches the CSS containing the @font-face declarations from Google Fonts. * The fetch has a user agent header with a modern browser to ensure we'll get .woff2 files. @@ -30,26 +46,40 @@ export async function fetchCSSFromGoogleFonts( // Just use the mocked CSS if it's set cssResponse = mockedResponse } else { - const controller = new AbortController() - const timeoutId = setTimeout(() => controller.abort(), 3000) - const res = await fetch(url, { - agent: getProxyAgent(), - // Add a timeout in dev - signal: isDev ? controller.signal : undefined, - headers: { - // The file format is based off of the user agent, make sure woff2 files are fetched - 'user-agent': - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36', - }, - }).finally(() => { - clearTimeout(timeoutId) - }) + // Retry the fetch a few times in case of network issues as some font files + // are quite large: + // https://github.com/vercel/next.js/issues/45080 + cssResponse = await retry(async () => { + const controller = + isDev && typeof AbortController !== 'undefined' + ? new AbortController() + : undefined + const signal = controller?.signal + const timeoutId = controller + ? setTimeout(() => controller.abort(), 3000) + : undefined - if (!res.ok) { - nextFontError(`Failed to fetch font \`${fontFamily}\`.\nURL: ${url}`) - } + const res = await fetch(url, { + agent: getProxyAgent(), + // Add a timeout in dev + signal, + headers: { + // The file format is based off of the user agent, make sure woff2 files are fetched + 'user-agent': + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36', + }, + }).finally(() => { + timeoutId && clearTimeout(timeoutId) + }) + + if (!res.ok) { + nextFontError( + `Failed to fetch font \`${fontFamily}\`.\nURL: ${url}\n\nPlease check if the network is available.` + ) + } - cssResponse = await res.text() + return res.text() + }, 3) } return cssResponse From 5b5ea47c54ba0440e2154b1366d71938df40a613 Mon Sep 17 00:00:00 2001 From: Milo <49202538+milovangudelj@users.noreply.github.com> Date: Wed, 28 Jun 2023 02:00:14 +0200 Subject: [PATCH 06/30] Avoiding try-catch block on examples/app-dir-i18n-routing (#51786) `Negotiator.languages()` accepts an array of available locales and returns only results that are present in it. This effectively eliminates the need to use a try-catch block when calling `matchLocale`. --------- Co-authored-by: JJ Kasper --- examples/app-dir-i18n-routing/middleware.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/app-dir-i18n-routing/middleware.ts b/examples/app-dir-i18n-routing/middleware.ts index ad11bf2ec059..c0287edb51ca 100644 --- a/examples/app-dir-i18n-routing/middleware.ts +++ b/examples/app-dir-i18n-routing/middleware.ts @@ -11,15 +11,17 @@ function getLocale(request: NextRequest): string | undefined { const negotiatorHeaders: Record = {} request.headers.forEach((value, key) => (negotiatorHeaders[key] = value)) - // Use negotiator and intl-localematcher to get best locale - let languages = new Negotiator({ headers: negotiatorHeaders }).languages() // @ts-ignore locales are readonly const locales: string[] = i18n.locales - try { - return matchLocale(languages, locales, i18n.defaultLocale) - } catch (_e) { - return i18n.defaultLocale - } + + // Use negotiator and intl-localematcher to get best locale + let languages = new Negotiator({ headers: negotiatorHeaders }).languages( + locales + ) + + const locale = matchLocale(languages, locales, i18n.defaultLocale) + + return locale } export function middleware(request: NextRequest) { From 5b883bb5d1de5a2d47d419dd0019e158b5f6896e Mon Sep 17 00:00:00 2001 From: Jimmy Lai Date: Wed, 28 Jun 2023 09:08:17 +0200 Subject: [PATCH 07/30] performance: enable minification for the server bundles (#51831) This PR makes the server code be minified. ## Why This will improve performance of the server code because of the lesser size, lesser time to parse and lesser code via tree sharking. Cons: this should lead to increased build times, so a `disableServerMinification` config was added link NEXT-1319 --- packages/next/src/build/webpack-config.ts | 7 ++++++- .../next/src/build/webpack/config/blocks/base.ts | 1 + packages/next/src/build/webpack/config/index.ts | 3 +++ packages/next/src/build/webpack/config/utils.ts | 1 + packages/next/src/server/config-schema.ts | 6 ++++++ packages/next/src/server/config-shared.ts | 12 ++++++++++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 411f67be8378..31ed619c8b27 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1766,7 +1766,11 @@ export default async function getBaseWebpackConfig( runtimeChunk: isClient ? { name: CLIENT_STATIC_FILES_RUNTIME_WEBPACK } : undefined, - minimize: !dev && (isClient || isEdgeServer), + minimize: + !dev && + (isClient || + isEdgeServer || + (isNodeServer && config.experimental.serverMinification)), minimizer: [ // Minify JavaScript (compiler: webpack.Compiler) => { @@ -2724,6 +2728,7 @@ export default async function getBaseWebpackConfig( experimental: config.experimental, disableStaticImages: config.images.disableStaticImages, transpilePackages: config.transpilePackages, + serverSourceMaps: config.experimental.serverSourceMaps, }) // @ts-ignore Cache exists diff --git a/packages/next/src/build/webpack/config/blocks/base.ts b/packages/next/src/build/webpack/config/blocks/base.ts index a9b43e144b81..ca5f1ce959f6 100644 --- a/packages/next/src/build/webpack/config/blocks/base.ts +++ b/packages/next/src/build/webpack/config/blocks/base.ts @@ -34,6 +34,7 @@ export const base = curry(function base( } else { if ( ctx.isEdgeRuntime || + (ctx.isServer && ctx.serverSourceMaps) || // Enable browser sourcemaps: (ctx.productionBrowserSourceMaps && ctx.isClient) ) { diff --git a/packages/next/src/build/webpack/config/index.ts b/packages/next/src/build/webpack/config/index.ts index b9f0718469b3..4daa1b35696a 100644 --- a/packages/next/src/build/webpack/config/index.ts +++ b/packages/next/src/build/webpack/config/index.ts @@ -25,6 +25,7 @@ export async function buildConfiguration( transpilePackages, experimental, disableStaticImages, + serverSourceMaps, }: { hasAppDir: boolean supportedBrowsers: string[] | undefined @@ -41,6 +42,7 @@ export async function buildConfiguration( future: NextConfigComplete['future'] experimental: NextConfigComplete['experimental'] disableStaticImages: NextConfigComplete['disableStaticImages'] + serverSourceMaps: NextConfigComplete['experimental']['serverSourceMaps'] } ): Promise { const ctx: ConfigurationContext = { @@ -64,6 +66,7 @@ export async function buildConfiguration( transpilePackages, future, experimental, + serverSourceMaps: serverSourceMaps ?? false, } let fns = [base(ctx), css(ctx)] diff --git a/packages/next/src/build/webpack/config/utils.ts b/packages/next/src/build/webpack/config/utils.ts index 0cae76e8a83f..004e0acac5b6 100644 --- a/packages/next/src/build/webpack/config/utils.ts +++ b/packages/next/src/build/webpack/config/utils.ts @@ -22,6 +22,7 @@ export type ConfigurationContext = { sassOptions: any productionBrowserSourceMaps: boolean + serverSourceMaps: boolean transpilePackages: NextConfigComplete['transpilePackages'] diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index b52ad1198793..1439550ee4e3 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -512,6 +512,12 @@ const configSchema = { logging: { type: 'string', }, + serverMinification: { + type: 'boolean', + }, + serverSourceMaps: { + type: 'boolean', + }, }, type: 'object', }, diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index aeed79b241ef..00b56e469a0b 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -287,6 +287,16 @@ export interface ExperimentalConfig { * Allows adjusting body parser size limit for server actions. */ serverActionsBodySizeLimit?: SizeLimit + + /** + * enables the minification of server code. + */ + serverMinification?: boolean + + /** + * Enables source maps generation for the server production bundle. + */ + serverSourceMaps?: boolean } export type ExportPathMap = { @@ -670,6 +680,8 @@ export const defaultConfig: NextConfig = { output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined, modularizeImports: undefined, experimental: { + serverMinification: false, + serverSourceMaps: false, caseSensitiveRoutes: false, useDeploymentId: false, deploymentId: undefined, From ba252d876525e75bb6b410d55c74dc8163cf96d9 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 28 Jun 2023 11:00:39 +0200 Subject: [PATCH 08/30] Simplify module context invalidation (#51905) It _might_ be an overhead to send over a large amount of data over `postMessage` just for diff. HMR and module compilation is way less frequent than evaluation in the sandbox, so maybe we should always invalidate the cache eagerly without any comparison and defer the workload to `evaluateInContext`. Some observations: CleanShot 2023-06-28 at 08 26 23@2x ![CleanShot 2023-06-28 at 08 02 24@2x](https://github.com/vercel/next.js/assets/3676859/b674beb1-d53c-4a1d-a9bf-ca3672e089c8) --- .../nextjs-require-cache-hot-reloader.ts | 18 ++++++++---------- packages/next/src/server/lib/render-server.ts | 4 ++-- packages/next/src/server/next-server.ts | 9 +++------ .../next/src/server/web/sandbox/context.ts | 16 +++------------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/packages/next/src/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts b/packages/next/src/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts index af4726b6a0db..301adda25ecb 100644 --- a/packages/next/src/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts +++ b/packages/next/src/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts @@ -80,18 +80,16 @@ export class NextJsRequireCacheHotReloader implements WebpackPluginInstance { } apply(compiler: Compiler) { - compiler.hooks.assetEmitted.tap( - PLUGIN_NAME, - (_file, { targetPath, content }) => { - deleteCache(targetPath) - const contentStr = content.toString('utf-8') + compiler.hooks.assetEmitted.tap(PLUGIN_NAME, (_file, { targetPath }) => { + deleteCache(targetPath) - if ((global as any)._nextClearModuleContext) { - ;(global as any)._nextClearModuleContext(targetPath, contentStr) - } - clearModuleContext(targetPath, contentStr) + // Clear module context in other processes + if ((global as any)._nextClearModuleContext) { + ;(global as any)._nextClearModuleContext(targetPath) } - ) + // Clear module context in this process + clearModuleContext(targetPath) + }) compiler.hooks.afterEmit.tap(PLUGIN_NAME, (compilation) => { RUNTIME_NAMES.forEach((name) => { diff --git a/packages/next/src/server/lib/render-server.ts b/packages/next/src/server/lib/render-server.ts index 35f22c7792cd..de61d912890e 100644 --- a/packages/next/src/server/lib/render-server.ts +++ b/packages/next/src/server/lib/render-server.ts @@ -34,8 +34,8 @@ if (process.env.NODE_ENV !== 'production') { requireCacheHotReloader = require('../../build/webpack/plugins/nextjs-require-cache-hot-reloader') } -export function clearModuleContext(target: string, content: string) { - sandboxContext?.clearModuleContext(target, content) +export function clearModuleContext(target: string) { + sandboxContext?.clearModuleContext(target) } export function deleteAppClientCache() { diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index fc3a7de62116..70605da0c352 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -326,13 +326,10 @@ export default class NextNodeServer extends BaseServer { console.error(err) } } - ;(global as any)._nextClearModuleContext = ( - targetPath: any, - content: any - ) => { + ;(global as any)._nextClearModuleContext = (targetPath: string) => { try { - this.renderWorkers?.pages?.clearModuleContext(targetPath, content) - this.renderWorkers?.app?.clearModuleContext(targetPath, content) + this.renderWorkers?.pages?.clearModuleContext(targetPath) + this.renderWorkers?.app?.clearModuleContext(targetPath) } catch (err) { console.error(err) } diff --git a/packages/next/src/server/web/sandbox/context.ts b/packages/next/src/server/web/sandbox/context.ts index eb13e922cdf5..c325f856cdce 100644 --- a/packages/next/src/server/web/sandbox/context.ts +++ b/packages/next/src/server/web/sandbox/context.ts @@ -25,9 +25,6 @@ import AssertImplementation from 'node:assert' import UtilImplementation from 'node:util' import AsyncHooksImplementation from 'node:async_hooks' -const WEBPACK_HASH_REGEX = - /__webpack_require__\.h = function\(\) \{ return "[0-9a-f]+"; \}/g - interface ModuleContext { runtime: EdgeRuntime paths: Map @@ -48,20 +45,13 @@ const pendingModuleCaches = new Map>() * context that contains the path with an older content and, if that's the * case, removes the context from the cache. */ -export async function clearModuleContext( - path: string, - content: Buffer | string -) { +export async function clearModuleContext(path: string) { const handleContext = ( key: string, cache: ReturnType<(typeof moduleContexts)['get']>, context: typeof moduleContexts | typeof pendingModuleCaches ) => { - const prev = cache?.paths.get(path)?.replace(WEBPACK_HASH_REGEX, '') - if ( - typeof prev !== 'undefined' && - prev !== content.toString().replace(WEBPACK_HASH_REGEX, '') - ) { + if (cache?.paths.has(path)) { context.delete(key) } } @@ -463,7 +453,7 @@ export async function getModuleContext(options: ModuleContextOptions): Promise<{ moduleContext.paths.set(filepath, content) } catch (error) { if (options.useCache) { - moduleContext?.paths.delete(options.moduleName) + moduleContext?.paths.delete(filepath) } throw error } From e33b87d894a8e80a4328adf1fd3d472896935be0 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Wed, 28 Jun 2023 09:04:46 +0000 Subject: [PATCH 09/30] v13.4.8-canary.8 --- 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 | 14 +++++++------- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lerna.json b/lerna.json index bb34fdce6624..c08ef1ee80c1 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "13.4.8-canary.7" + "version": "13.4.8-canary.8" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index da374bb09b28..3bc8f17b5735 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.8-canary.7", + "version": "13.4.8-canary.8", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index ed8e0831efdd..ce7afacb0296 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.8-canary.7", + "version": "13.4.8-canary.8", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "13.4.8-canary.7", + "@next/eslint-plugin-next": "13.4.8-canary.8", "@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 d6116eef68a9..d4a3ca02df75 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.8-canary.7", + "version": "13.4.8-canary.8", "description": "ESLint plugin for NextJS.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 6d595f5b09d7..3922e73ad571 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "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 0ed0cce9f330..8ac5a374a0c5 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.8-canary.7", + "version": "13.4.8-canary.8", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 6b3bb08bce70..bc6486dba889 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 7bc863919375..6d7c4c77d7ad 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index f91fc894dc2f..d010577981df 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index b7cca611858b..6975e848b19b 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.8-canary.7", + "version": "13.4.8-canary.8", "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 1cf588bcdc32..350a6ec3abd4 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.8-canary.7", + "version": "13.4.8-canary.8", "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 2dc7f355cbd7..7a10fa2c9dfc 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.8-canary.7", + "version": "13.4.8-canary.8", "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 87b06edaa84e..e4f96ea2efcf 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index aa17711c1e62..a25569b56591 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "13.4.8-canary.7", + "version": "13.4.8-canary.8", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -83,7 +83,7 @@ ] }, "dependencies": { - "@next/env": "13.4.8-canary.7", + "@next/env": "13.4.8-canary.8", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -141,11 +141,11 @@ "@jest/types": "29.5.0", "@napi-rs/cli": "2.14.7", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "13.4.8-canary.7", - "@next/polyfill-nomodule": "13.4.8-canary.7", - "@next/react-dev-overlay": "13.4.8-canary.7", - "@next/react-refresh-utils": "13.4.8-canary.7", - "@next/swc": "13.4.8-canary.7", + "@next/polyfill-module": "13.4.8-canary.8", + "@next/polyfill-nomodule": "13.4.8-canary.8", + "@next/react-dev-overlay": "13.4.8-canary.8", + "@next/react-refresh-utils": "13.4.8-canary.8", + "@next/swc": "13.4.8-canary.8", "@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 833adf50191e..49969cb76aa9 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.8-canary.7", + "version": "13.4.8-canary.8", "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 c241ab12ba4d..a06661c8c377 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.8-canary.7", + "version": "13.4.8-canary.8", "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 9857f969bcf0..59fc8fbee697 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -436,7 +436,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 13.4.8-canary.7 + '@next/eslint-plugin-next': 13.4.8-canary.8 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.42.0 eslint: ^7.23.0 || ^8.0.0 @@ -513,12 +513,12 @@ importers: '@jest/types': 29.5.0 '@napi-rs/cli': 2.14.7 '@napi-rs/triples': 1.1.0 - '@next/env': 13.4.8-canary.7 - '@next/polyfill-module': 13.4.8-canary.7 - '@next/polyfill-nomodule': 13.4.8-canary.7 - '@next/react-dev-overlay': 13.4.8-canary.7 - '@next/react-refresh-utils': 13.4.8-canary.7 - '@next/swc': 13.4.8-canary.7 + '@next/env': 13.4.8-canary.8 + '@next/polyfill-module': 13.4.8-canary.8 + '@next/polyfill-nomodule': 13.4.8-canary.8 + '@next/react-dev-overlay': 13.4.8-canary.8 + '@next/react-refresh-utils': 13.4.8-canary.8 + '@next/swc': 13.4.8-canary.8 '@opentelemetry/api': 1.4.1 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.5.1 From e7a692537cb798402990064ab4bbbc41b689804a Mon Sep 17 00:00:00 2001 From: Sukka Date: Wed, 28 Jun 2023 21:32:10 +0800 Subject: [PATCH 10/30] Reduce the client bundle size of App Router (#51806) After migrating a Next.js app from Pages Router to App Router and using as many RSC as possible, I notice that the client js bundle size actually increases by 5%. It turns out that Next.js has introduced a lot of code to the client bundle. image The PR is an attempt to reduce the client bundle size. --- packages/next/src/client/app-bootstrap.ts | 5 +- packages/next/src/client/app-index.tsx | 31 +++--- .../components/app-router-announcer.tsx | 8 +- .../next/src/client/components/app-router.tsx | 94 +++++++++---------- .../client/components/async-local-storage.ts | 20 ++-- .../src/client/components/layout-router.tsx | 41 ++++---- .../src/client/components/match-segments.ts | 20 ++-- .../router-reducer/handle-mutable.ts | 13 +-- .../reducers/navigate-reducer.ts | 11 ++- .../reducers/refresh-reducer.ts | 8 +- .../src/shared/lib/router/utils/app-paths.ts | 4 +- 11 files changed, 121 insertions(+), 134 deletions(-) diff --git a/packages/next/src/client/app-bootstrap.ts b/packages/next/src/client/app-bootstrap.ts index c5da6299965c..5baa7424877d 100644 --- a/packages/next/src/client/app-bootstrap.ts +++ b/packages/next/src/client/app-bootstrap.ts @@ -47,12 +47,11 @@ function loadScriptsInSequence( }) }) }, Promise.resolve()) - .then(() => { - hydrate() - }) .catch((err: Error) => { console.error(err) // Still try to hydrate even if there's an error. + }) + .then(() => { hydrate() }) } diff --git a/packages/next/src/client/app-index.tsx b/packages/next/src/client/app-index.tsx index ccfecd819963..3bc8fb325f46 100644 --- a/packages/next/src/client/app-index.tsx +++ b/packages/next/src/client/app-index.tsx @@ -12,7 +12,6 @@ import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context' import onRecoverableError from './on-recoverable-error' import { callServer } from './app-call-server' import { isNextRouterError } from './components/is-next-router-error' -import { linkGc } from './app-link-gc' // Since React doesn't call onerror for errors caught in error boundaries. const origConsoleError = window.console.error @@ -215,11 +214,12 @@ const StrictModeIfEnabled = process.env.__NEXT_STRICT_MODE_APP : React.Fragment function Root({ children }: React.PropsWithChildren<{}>): React.ReactElement { - React.useEffect(() => { - if (process.env.__NEXT_ANALYTICS_ID) { + if (process.env.__NEXT_ANALYTICS_ID) { + // eslint-disable-next-line react-hooks/rules-of-hooks + React.useEffect(() => { require('./performance-relayer-app')() - } - }, []) + }, []) + } if (process.env.__NEXT_TEST_MODE) { // eslint-disable-next-line react-hooks/rules-of-hooks @@ -236,8 +236,7 @@ function Root({ children }: React.PropsWithChildren<{}>): React.ReactElement { } function RSCComponent(props: any): JSX.Element { - const cacheKey = getCacheKey() - return + return } export function hydrate() { @@ -314,14 +313,18 @@ export function hydrate() { } } - const reactRoot = isError - ? (ReactDOMClient as any).createRoot(appElement, options) - : (React as any).startTransition(() => - (ReactDOMClient as any).hydrateRoot(appElement, reactEl, options) - ) if (isError) { - reactRoot.render(reactEl) + ReactDOMClient.createRoot(appElement as any, options).render(reactEl) + } else { + React.startTransition(() => + (ReactDOMClient as any).hydrateRoot(appElement, reactEl, options) + ) } - linkGc() + // TODO-APP: Remove this logic when Float has GC built-in in development. + if (process.env.NODE_ENV !== 'production') { + const { linkGc } = + require('./app-link-gc') as typeof import('./app-link-gc') + linkGc() + } } diff --git a/packages/next/src/client/components/app-router-announcer.tsx b/packages/next/src/client/components/app-router-announcer.tsx index 4295bf430372..7339498953aa 100644 --- a/packages/next/src/client/components/app-router-announcer.tsx +++ b/packages/next/src/client/components/app-router-announcer.tsx @@ -13,9 +13,9 @@ function getAnnouncerNode() { const container = document.createElement(ANNOUNCER_TYPE) container.style.cssText = 'position:absolute' const announcer = document.createElement('div') - announcer.setAttribute('aria-live', 'assertive') - announcer.setAttribute('id', ANNOUNCER_ID) - announcer.setAttribute('role', 'alert') + announcer.ariaLive = 'assertive' + announcer.id = ANNOUNCER_ID + announcer.role = 'alert' announcer.style.cssText = 'position:absolute;border:0;height:1px;margin:-1px;padding:0;width:1px;clip:rect(0 0 0 0);overflow:hidden;white-space:nowrap;word-wrap:normal' @@ -57,7 +57,7 @@ export function AppRouterAnnouncer({ tree }: { tree: FlightRouterState }) { // Only announce the title change, but not for the first load because screen // readers do that automatically. - if (typeof previousTitle.current !== 'undefined') { + if (previousTitle.current !== undefined) { setRouteAnnouncement(currentTitle) } previousTitle.current = currentTitle diff --git a/packages/next/src/client/components/app-router.tsx b/packages/next/src/client/components/app-router.tsx index 804e648a8215..da8e27b8b7e0 100644 --- a/packages/next/src/client/components/app-router.tsx +++ b/packages/next/src/client/components/app-router.tsx @@ -1,7 +1,14 @@ 'use client' import type { ReactNode } from 'react' -import React, { use, useEffect, useMemo, useCallback } from 'react' +import React, { + use, + useEffect, + useMemo, + useCallback, + startTransition, + useInsertionEffect, +} from 'react' import { AppRouterContext, LayoutRouterContext, @@ -109,8 +116,7 @@ function isExternalURL(url: URL) { } function HistoryUpdater({ tree, pushRef, canonicalUrl, sync }: any) { - // @ts-ignore TODO-APP: useInsertionEffect is available - React.useInsertionEffect(() => { + useInsertionEffect(() => { // Identifier is shortened intentionally. // __NA is used to identify if the history entry can be handled by the app-router. // __N is used to identify if the history entry can be handled by the old router. @@ -133,6 +139,13 @@ function HistoryUpdater({ tree, pushRef, canonicalUrl, sync }: any) { return null } +const createEmptyCacheNode = () => ({ + status: CacheStates.LAZY_INITIALIZED, + data: null, + subTreeData: null, + parallelRoutes: new Map(), +}) + /** * The global router that wraps the application components. */ @@ -203,18 +216,13 @@ function Router({ flightData: FlightData, overrideCanonicalUrl: URL | undefined ) => { - React.startTransition(() => { + startTransition(() => { dispatch({ type: ACTION_SERVER_PATCH, flightData, previousTree, overrideCanonicalUrl, - cache: { - status: CacheStates.LAZY_INITIALIZED, - data: null, - subTreeData: null, - parallelRoutes: new Map(), - }, + cache: createEmptyCacheNode(), mutable: {}, }) }) @@ -237,12 +245,7 @@ function Router({ locationSearch: location.search, forceOptimisticNavigation, navigateType, - cache: { - status: CacheStates.LAZY_INITIALIZED, - data: null, - subTreeData: null, - parallelRoutes: new Map(), - }, + cache: createEmptyCacheNode(), mutable: {}, }) }, @@ -251,7 +254,7 @@ function Router({ const serverActionDispatcher: ServerActionDispatcher = useCallback( (actionPayload) => { - React.startTransition(() => { + startTransition(() => { dispatch({ ...actionPayload, type: ACTION_SERVER_ACTION, @@ -283,8 +286,7 @@ function Router({ if (isExternalURL(url)) { return } - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { dispatch({ type: ACTION_PREFETCH, url, @@ -293,28 +295,20 @@ function Router({ }) }, replace: (href, options = {}) => { - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { navigate(href, 'replace', Boolean(options.forceOptimisticNavigation)) }) }, push: (href, options = {}) => { - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { navigate(href, 'push', Boolean(options.forceOptimisticNavigation)) }) }, refresh: () => { - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { dispatch({ type: ACTION_REFRESH, - cache: { - status: CacheStates.LAZY_INITIALIZED, - data: null, - subTreeData: null, - parallelRoutes: new Map(), - }, + cache: createEmptyCacheNode(), mutable: {}, origin: window.location.origin, }) @@ -327,16 +321,10 @@ function Router({ 'fastRefresh can only be used in development mode. Please use refresh instead.' ) } else { - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { dispatch({ type: ACTION_FAST_REFRESH, - cache: { - status: CacheStates.LAZY_INITIALIZED, - data: null, - subTreeData: null, - parallelRoutes: new Map(), - }, + cache: createEmptyCacheNode(), mutable: {}, origin: window.location.origin, }) @@ -355,17 +343,21 @@ function Router({ } }, [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, - cache, - prefetchCache, - tree, - } - }, [appRouter, cache, prefetchCache, tree]) + if (process.env.NODE_ENV !== 'production') { + // This hook is in a conditional but that is ok because `process.env.NODE_ENV` never changes + // eslint-disable-next-line react-hooks/rules-of-hooks + 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, + cache, + 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 @@ -411,7 +403,7 @@ function Router({ // @ts-ignore useTransition exists // TODO-APP: Ideally the back button should not use startTransition as it should apply the updates synchronously // Without startTransition works if the cache is there for this path - React.startTransition(() => { + startTransition(() => { dispatch({ type: ACTION_RESTORE, url: new URL(window.location.href), diff --git a/packages/next/src/client/components/async-local-storage.ts b/packages/next/src/client/components/async-local-storage.ts index d0fa1e482e92..caa7f7fd59a2 100644 --- a/packages/next/src/client/components/async-local-storage.ts +++ b/packages/next/src/client/components/async-local-storage.ts @@ -1,12 +1,14 @@ import type { AsyncLocalStorage } from 'async_hooks' +const sharedAsyncLocalStorageNotAvailableError = new Error( + 'Invariant: AsyncLocalStorage accessed in runtime where it is not available' +) + class FakeAsyncLocalStorage implements AsyncLocalStorage { disable(): void { - throw new Error( - 'Invariant: AsyncLocalStorage accessed in runtime where it is not available' - ) + throw sharedAsyncLocalStorageNotAvailableError } getStore(): Store | undefined { @@ -15,21 +17,15 @@ class FakeAsyncLocalStorage } run(): R { - throw new Error( - 'Invariant: AsyncLocalStorage accessed in runtime where it is not available' - ) + throw sharedAsyncLocalStorageNotAvailableError } exit(): R { - throw new Error( - 'Invariant: AsyncLocalStorage accessed in runtime where it is not available' - ) + throw sharedAsyncLocalStorageNotAvailableError } enterWith(): void { - throw new Error( - 'Invariant: AsyncLocalStorage accessed in runtime where it is not available' - ) + throw sharedAsyncLocalStorageNotAvailableError } } diff --git a/packages/next/src/client/components/layout-router.tsx b/packages/next/src/client/components/layout-router.tsx index cbc0824bd937..f45ff5af3058 100644 --- a/packages/next/src/client/components/layout-router.tsx +++ b/packages/next/src/client/components/layout-router.tsx @@ -10,7 +10,7 @@ import type { import type { ErrorComponent } from './error-boundary' import type { FocusAndScrollRef } from './router-reducer/router-reducer-types' -import React, { useContext, use } from 'react' +import React, { useContext, use, startTransition, Suspense } from 'react' import ReactDOM from 'react-dom' import { CacheStates, @@ -335,14 +335,14 @@ function InnerLayoutRouter({ if (!childNode) { // Add the segment's subTreeData to the cache. // This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode. - childNodes.set(cacheKey, { + childNode = { status: CacheStates.READY, data: null, subTreeData: childProp.current, parallelRoutes: new Map(), - }) - // In the above case childNode was set on childNodes, so we have to get it from the cacheNodes again. - childNode = childNodes.get(cacheKey) + } + + childNodes.set(cacheKey, childNode) } else { if (childNode.status === CacheStates.LAZY_INITIALIZED) { // @ts-expect-error we're changing it's type! @@ -361,10 +361,7 @@ function InnerLayoutRouter({ // TODO-APP: remove '' const refetchTree = walkAddRefetch(['', ...segmentPath], fullTree) - /** - * Flight data fetch kicked off during render and put into the cache. - */ - childNodes.set(cacheKey, { + childNode = { status: CacheStates.DATA_FETCH, data: fetchServerResponse( new URL(url, location.origin), @@ -381,9 +378,12 @@ function InnerLayoutRouter({ childNode && childNode.status === CacheStates.LAZY_INITIALIZED ? childNode.parallelRoutes : new Map(), - }) - // In the above case childNode was set on childNodes, so we have to get it from the cacheNodes again. - childNode = childNodes.get(cacheKey) + } + + /** + * Flight data fetch kicked off during render and put into the cache. + */ + childNodes.set(cacheKey, childNode) } // This case should never happen so it throws an error. It indicates there's a bug in the Next.js. @@ -409,8 +409,7 @@ function InnerLayoutRouter({ // setTimeout is used to start a new transition during render, this is an intentional hack around React. setTimeout(() => { - // @ts-ignore startTransition exists - React.startTransition(() => { + startTransition(() => { changeByServerResponse(fullTree, flightData, overrideCanonicalUrl) }) }) @@ -458,7 +457,7 @@ function LoadingBoundary({ }): JSX.Element { if (hasLoading) { return ( - {loadingStyles} @@ -467,7 +466,7 @@ function LoadingBoundary({ } > {children} - + ) } @@ -521,8 +520,8 @@ export default function OuterLayoutRouter({ // If the parallel router cache node does not exist yet, create it. // This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode. if (!childNodesForParallelRouter) { - childNodes.set(parallelRouterKey, new Map()) - childNodesForParallelRouter = childNodes.get(parallelRouterKey)! + childNodesForParallelRouter = new Map() + childNodes.set(parallelRouterKey, childNodesForParallelRouter) } // Get the active segment in the tree @@ -596,10 +595,8 @@ export default function OuterLayoutRouter({ } > - <> - {templateStyles} - {template} - + {templateStyles} + {template} ) })} diff --git a/packages/next/src/client/components/match-segments.ts b/packages/next/src/client/components/match-segments.ts index 10d4d75817d5..6fa99c98b299 100644 --- a/packages/next/src/client/components/match-segments.ts +++ b/packages/next/src/client/components/match-segments.ts @@ -5,19 +5,19 @@ export const matchSegment = ( existingSegment: Segment, segment: Segment ): boolean => { - // Common case: segment is just a string - if (typeof existingSegment === 'string' && typeof segment === 'string') { - return existingSegment === segment + // segment is either Array or string + if (typeof existingSegment === 'string') { + if (typeof segment === 'string') { + // Common case: segment is just a string + return existingSegment === segment + } + return false } - // Dynamic parameter case: segment is an array with param/value. Both param and value are compared. - if (Array.isArray(existingSegment) && Array.isArray(segment)) { - return ( - existingSegment[0] === segment[0] && existingSegment[1] === segment[1] - ) + if (typeof segment === 'string') { + return false } - - return false + return existingSegment[0] === segment[0] && existingSegment[1] === segment[1] } /* diff --git a/packages/next/src/client/components/router-reducer/handle-mutable.ts b/packages/next/src/client/components/router-reducer/handle-mutable.ts index 82c829f9be76..91b49c72b4e9 100644 --- a/packages/next/src/client/components/router-reducer/handle-mutable.ts +++ b/packages/next/src/client/components/router-reducer/handle-mutable.ts @@ -13,18 +13,18 @@ export function handleMutable( buildId: state.buildId, // Set href. canonicalUrl: - typeof mutable.canonicalUrl !== 'undefined' + mutable.canonicalUrl != null ? mutable.canonicalUrl === state.canonicalUrl ? state.canonicalUrl : mutable.canonicalUrl : state.canonicalUrl, pushRef: { pendingPush: - typeof mutable.pendingPush !== 'undefined' + mutable.pendingPush != null ? mutable.pendingPush : state.pushRef.pendingPush, mpaNavigation: - typeof mutable.mpaNavigation !== 'undefined' + mutable.mpaNavigation != null ? mutable.mpaNavigation : state.pushRef.mpaNavigation, }, @@ -50,12 +50,9 @@ export function handleMutable( ? mutable.prefetchCache : state.prefetchCache, // Apply patched router state. - tree: - typeof mutable.patchedTree !== 'undefined' - ? mutable.patchedTree - : state.tree, + tree: mutable.patchedTree !== undefined ? mutable.patchedTree : state.tree, nextUrl: - typeof mutable.patchedTree !== 'undefined' + mutable.patchedTree !== undefined ? computeChangedPath(state.tree, mutable.patchedTree) ?? state.canonicalUrl : state.nextUrl, diff --git a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts index d8c83012dc3d..1ef59e2cb1cf 100644 --- a/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts @@ -263,12 +263,15 @@ export function navigateReducer( -4 ) as unknown as FlightSegmentPath // The one before last item is the router state tree patch - const [treePatch] = flightDataPath.slice(-3) as [FlightRouterState] + const treePatch = flightDataPath.slice(-3)[0] as FlightRouterState + + // TODO-APP: remove '' + const flightSegmentPathWithLeadingEmpty = ['', ...flightSegmentPath] // Create new tree based on the flightSegmentPath and router state patch let newTree = applyRouterStatePatchToTree( // TODO-APP: remove '' - ['', ...flightSegmentPath], + flightSegmentPathWithLeadingEmpty, currentTree, treePatch ) @@ -278,7 +281,7 @@ export function navigateReducer( if (newTree === null) { newTree = applyRouterStatePatchToTree( // TODO-APP: remove '' - ['', ...flightSegmentPath], + flightSegmentPathWithLeadingEmpty, treeAtTimeOfPrefetch, treePatch ) @@ -314,7 +317,7 @@ export function navigateReducer( const hardNavigate = shouldHardNavigate( // TODO-APP: remove '' - ['', ...flightSegmentPath], + flightSegmentPathWithLeadingEmpty, currentTree ) diff --git a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts index 89ea0f0f49e5..cd87ef3802b0 100644 --- a/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts +++ b/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts @@ -21,8 +21,10 @@ export function refreshReducer( const { cache, mutable, origin } = action const href = state.canonicalUrl + let currentTree = state.tree + const isForCurrentTree = - JSON.stringify(mutable.previousTree) === JSON.stringify(state.tree) + JSON.stringify(mutable.previousTree) === JSON.stringify(currentTree) if (isForCurrentTree) { return handleMutable(state, mutable) @@ -34,7 +36,7 @@ export function refreshReducer( cache.data = createRecordFromThenable( fetchServerResponse( new URL(href, origin), - [state.tree[0], state.tree[1], state.tree[2], 'refetch'], + [currentTree[0], currentTree[1], currentTree[2], 'refetch'], state.nextUrl, state.buildId ) @@ -55,8 +57,6 @@ export function refreshReducer( // Remove cache.data as it has been resolved at this point. cache.data = null - let currentTree = state.tree - for (const flightDataPath of flightData) { // FlightDataPath with more than two items means unexpected Flight data was returned if (flightDataPath.length !== 3) { diff --git a/packages/next/src/shared/lib/router/utils/app-paths.ts b/packages/next/src/shared/lib/router/utils/app-paths.ts index b53075c99753..59273bdce4ac 100644 --- a/packages/next/src/shared/lib/router/utils/app-paths.ts +++ b/packages/next/src/shared/lib/router/utils/app-paths.ts @@ -28,12 +28,12 @@ export function normalizeAppPath(route: string) { } // Groups are ignored. - if (segment.startsWith('(') && segment.endsWith(')')) { + if (segment[0] === '(' && segment.endsWith(')')) { return pathname } // Parallel segments are ignored. - if (segment.startsWith('@')) { + if (segment[0] === '@') { return pathname } From f1a4f7ad7d2f77bfa189fe66665e999f4b41d6d0 Mon Sep 17 00:00:00 2001 From: Leah Date: Wed, 28 Jun 2023 16:19:33 +0200 Subject: [PATCH 11/30] fix turbopack mdx import map (#51881) I accidentally broke this with #49818 --- packages/next-swc/crates/next-core/src/next_import_map.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next-swc/crates/next-core/src/next_import_map.rs b/packages/next-swc/crates/next-core/src/next_import_map.rs index 4fdfffd45fcd..60ad3de008d5 100644 --- a/packages/next-swc/crates/next-core/src/next_import_map.rs +++ b/packages/next-swc/crates/next-core/src/next_import_map.rs @@ -33,6 +33,7 @@ use crate::{ next_server::context::ServerContextType, }; +// Make sure to not add any external requests here. /// Computes the Next-specific client import map. #[turbo_tasks::function] pub async fn get_next_client_import_map( @@ -426,6 +427,7 @@ pub fn mdx_import_source_file() -> String { format!("{VIRTUAL_PACKAGE_NAME}/mdx-import-source") } +// Make sure to not add any external requests here. pub async fn insert_next_shared_aliases( import_map: &mut ImportMap, project_path: FileSystemPathVc, @@ -441,7 +443,7 @@ pub async fn insert_next_shared_aliases( vec![ request_to_import_mapping(project_path, "./mdx-components"), request_to_import_mapping(project_path, "./src/mdx-components"), - external_request_to_import_mapping("@mdx-js/react"), + request_to_import_mapping(project_path, "@mdx-js/react"), ], ); } From f2dc6c87e9b0e1e7af662f1ffab852ac7295c119 Mon Sep 17 00:00:00 2001 From: Leah Date: Wed, 28 Jun 2023 16:50:04 +0200 Subject: [PATCH 12/30] error recovery during turbopack hydration (#51882) ### What? Makes sure the next.js hydration code can run and that we can open the error overlay when there's an error in the entry page Fixes WEB-1168 --- .../crates/next-core/js/src/entry/next-hydrate.tsx | 10 +++++----- .../crates/next-core/js/src/entry/page-loader.ts | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx b/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx index a5909d331a7e..dd83c3d0c923 100644 --- a/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx +++ b/packages/next-swc/crates/next-core/js/src/entry/next-hydrate.tsx @@ -10,9 +10,6 @@ import { formatWithValidation } from 'next/dist/shared/lib/router/utils/format-u import { initializeHMR } from '../dev/client' import { subscribeToUpdate } from '@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client' -import * as _app from '@vercel/turbopack-next/pages/_app' -import * as page from 'PAGE' - async function loadPageChunk(assetPrefix: string, chunkData: ChunkData) { if (typeof chunkData === 'string') { const fullPath = assetPrefix + chunkData @@ -60,8 +57,11 @@ async function loadPageChunk(assetPrefix: string, chunkData: ChunkData) { } const pagePath = window.__NEXT_DATA__.page - window.__NEXT_P.push(['/_app', () => _app]) - window.__NEXT_P.push([pagePath, () => page]) + window.__NEXT_P.push([ + '/_app', + () => require('@vercel/turbopack-next/pages/_app'), + ]) + window.__NEXT_P.push([pagePath, () => require('PAGE')]) console.debug('Hydrating the page') diff --git a/packages/next-swc/crates/next-core/js/src/entry/page-loader.ts b/packages/next-swc/crates/next-core/js/src/entry/page-loader.ts index caa8a49fbdaa..3e472de785a2 100644 --- a/packages/next-swc/crates/next-core/js/src/entry/page-loader.ts +++ b/packages/next-swc/crates/next-core/js/src/entry/page-loader.ts @@ -1,5 +1,3 @@ -import * as page from 'PAGE' - // inserted by rust code declare const PAGE_PATH: string @@ -7,7 +5,7 @@ declare const PAGE_PATH: string ;(window.__NEXT_P = window.__NEXT_P || []).push([ PAGE_PATH, () => { - return page + return require('PAGE') }, ]) if (module.hot) { From e05c8c2d7e17d0a801ebdd927c62deab28e6ae41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 29 Jun 2023 01:04:35 +0900 Subject: [PATCH 13/30] Update `swc_core` to `v0.78.24` (#51857) ### What? Update SWC crates ### Why? There were many fixes. ### How? Closes WEB-1174 Turbopack counterpart: https://github.com/vercel/turbo/pull/5288 --- Cargo.lock | 1192 ++++++++++++++++++++++++++++++++++++++++------------ Cargo.toml | 4 +- 2 files changed, 917 insertions(+), 279 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60e34b719f90..a6a17381a587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,6 +39,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if 1.0.0", + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "1.0.1" @@ -160,15 +172,15 @@ dependencies = [ [[package]] name = "ast_node" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c704e2f6ee1a98223f5a7629a6ef0f3decb3b552ed282889dc957edff98ce1e6" +checksum = "c09c69dffe06d222d072c878c3afe86eee2179806f20503faec97250268b4c24" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -417,6 +429,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -509,9 +533,9 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "better_scoped_tls" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73e8ecdec39e98aa3b19e8cd0b8ed8f77ccb86a6b0b2dc7cd86d105438a2123" +checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" dependencies = [ "scoped-tls", ] @@ -537,11 +561,11 @@ dependencies = [ "once_cell", "serde", "serde-wasm-bindgen", - "swc", + "swc 0.261.41", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms 0.218.24", + "swc_ecma_visit 0.90.5", "wasm-bindgen", "wasm-bindgen-futures", ] @@ -554,9 +578,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.2.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" +checksum = "6dbe3c979c178231552ecba20214a8272df4e09f232a87aef4320cf06539aded" [[package]] name = "bitreader" @@ -632,7 +656,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef956561c9a03c35af46714efd0c135e21768a2a012f900ca8a59b28e75d0cd1" dependencies = [ - "ahash", + "ahash 0.7.6", "anyhow", "chrono", "either", @@ -699,6 +723,15 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +dependencies = [ + "serde", +] + [[package]] name = "cargo-lock" version = "8.0.3" @@ -711,6 +744,29 @@ dependencies = [ "url", ] +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.17", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cast" version = "0.3.0" @@ -873,7 +929,7 @@ version = "4.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" dependencies = [ - "bitflags 2.2.1", + "bitflags 2.3.2", "clap_derive", "clap_lex 0.3.3", "is-terminal", @@ -1153,7 +1209,7 @@ checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" dependencies = [ "cranelift-entity", "fxhash", - "hashbrown", + "hashbrown 0.12.3", "indexmap", "log", "smallvec", @@ -1476,7 +1532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ "cfg-if 1.0.0", - "hashbrown", + "hashbrown 0.12.3", "lock_api", "once_cell", "parking_lot_core 0.9.7", @@ -1792,23 +1848,23 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] [[package]] name = "from_variant" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d449976075322384507443937df2f1d5577afbf4282f12a5a66ef29fa3e6307" +checksum = "03ec5dc38ee19078d84a692b1c41181ff9f94331c76cee66ff0208c770b5e54f" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -2134,7 +2190,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", ] [[package]] @@ -2403,9 +2468,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2459,7 +2524,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "rayon", "serde", ] @@ -2532,12 +2597,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7d079e129b77477a49c5c4f1cfe9ce6c2c909ef52520693e8e811a714c7b20" dependencies = [ "Inflector", - "pmutil", + "pmutil 0.5.3", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "is-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" +dependencies = [ + "Inflector", + "pmutil 0.6.1", + "proc-macro2", + "quote", + "syn 2.0.18", +] + [[package]] name = "is-terminal" version = "0.4.7" @@ -2878,7 +2956,16 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "lru" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +dependencies = [ + "hashbrown 0.13.2", ] [[package]] @@ -2946,7 +3033,7 @@ checksum = "c88a71be094e8cf4f13b62e6ba304472332f8890e7cdf15098dc6512b812fdab" dependencies = [ "markdown", "serde", - "swc_core", + "swc_core 0.76.48", ] [[package]] @@ -3139,7 +3226,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core", + "swc_core 0.76.48", ] [[package]] @@ -3161,7 +3248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69b29acdc6cc5c918c3eabd51d241b1c6dfa8914f3552fcfd76e1d7536934581" dependencies = [ "anyhow", - "bitflags 2.2.1", + "bitflags 2.3.2", "ctor 0.2.0", "napi-derive", "napi-sys", @@ -3295,7 +3382,7 @@ dependencies = [ "regex", "serde", "serde_json", - "swc_core", + "swc_core 0.78.24", "thiserror", "turbo-tasks", "turbo-tasks-fs", @@ -3422,7 +3509,7 @@ name = "next-transform-dynamic" version = "0.1.0" dependencies = [ "pathdiff", - "swc_core", + "swc_core 0.78.24", "testing", ] @@ -3433,7 +3520,7 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "swc_core", + "swc_core 0.78.24", ] [[package]] @@ -3441,7 +3528,7 @@ name = "next-transform-strip-page-exports" version = "0.1.0" dependencies = [ "rustc-hash", - "swc_core", + "swc_core 0.78.24", "testing", "tracing", ] @@ -3624,9 +3711,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "oorandom" @@ -3815,9 +3902,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -3994,6 +4081,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pmutil" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.18", +] + [[package]] name = "png" version = "0.17.8" @@ -4057,11 +4155,11 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "preset_env_base" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a48d8ea8b031bde7755cdf6f87f7123a0cbefc36b0cd09cbb2de726594393" +checksum = "ae83c5857727636a1f2c7188632c8a57986d2f1d2e2cf45f2642f5856c5b8e85" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", "browserslist-rs", "dashmap", @@ -4069,7 +4167,7 @@ dependencies = [ "once_cell", "semver 1.0.17", "serde", - "st-map", + "st-map 0.2.0", "tracing", ] @@ -4521,7 +4619,7 @@ checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ "bitvec", "bytecheck", - "hashbrown", + "hashbrown 0.12.3", "indexmap", "ptr_meta", "rend", @@ -5212,7 +5310,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f09d891835f076b0d4a58dd4478fb54d47aa3da1f7a4c6e89ad6c791357ab5ed" dependencies = [ "arrayvec", - "static-map-macro", + "static-map-macro 0.2.5", +] + +[[package]] +name = "st-map" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f352d5d14be5a1f956d76ae0c8060c3487aaa2a080f10a4b4ff023c7c05a9047" +dependencies = [ + "arrayvec", + "static-map-macro 0.3.0", ] [[package]] @@ -5249,12 +5357,24 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b862d598fbc9f7085b017890e2e61433f501e7467f2c585323e1aa3c07ef8599" dependencies = [ - "pmutil", + "pmutil 0.5.3", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "static-map-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7628ae0bd92555d3de4303da41a5c8b1c5363e892001325f34e4be9ed024d0d7" +dependencies = [ + "pmutil 0.6.1", + "proc-macro2", + "quote", + "syn 2.0.18", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -5338,15 +5458,15 @@ dependencies = [ [[package]] name = "string_enum" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0090512bdfee4b56d82480d66c0fd8a6f53f0fe0f97e075e949b252acdd482e0" +checksum = "8fa4d4f81d7c05b9161f8de839975d3326328b8ba2831164b465524cc2f55252" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -5365,7 +5485,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core", + "swc_core 0.76.48", "tracing", ] @@ -5376,7 +5496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9154a21e45febf6553717c0f962749669dcf0febd2880543d35ef3f05ef825c1" dependencies = [ "easy-error", - "swc_core", + "swc_core 0.76.48", "tracing", ] @@ -5420,14 +5540,14 @@ version = "0.261.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b59f4e1f5ebb10037de0a3a5c25d2fe7691f8811f42d3549fb81f2b9047205b" dependencies = [ - "ahash", + "ahash 0.7.6", "anyhow", "base64 0.13.1", "dashmap", "either", "indexmap", "jsonc-parser", - "lru", + "lru 0.7.8", "napi", "napi-derive", "once_cell", @@ -5442,20 +5562,20 @@ dependencies = [ "swc_cached", "swc_common", "swc_config", - "swc_ecma_ast", - "swc_ecma_codegen", - "swc_ecma_ext_transforms", - "swc_ecma_lints", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen 0.139.17", + "swc_ecma_ext_transforms 0.103.13", + "swc_ecma_lints 0.82.18", "swc_ecma_loader", - "swc_ecma_minifier", - "swc_ecma_parser", - "swc_ecma_preset_env", - "swc_ecma_transforms", - "swc_ecma_transforms_base", - "swc_ecma_transforms_compat", - "swc_ecma_transforms_optimization", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_minifier 0.181.31", + "swc_ecma_parser 0.134.12", + "swc_ecma_preset_env 0.195.26", + "swc_ecma_transforms 0.218.24", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_compat 0.153.20", + "swc_ecma_transforms_optimization 0.187.24", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", "swc_error_reporters", "swc_node_comments", "swc_plugin_proxy", @@ -5466,6 +5586,54 @@ dependencies = [ "url", ] +[[package]] +name = "swc" +version = "0.263.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0352b9116b87a38d2a693c2c58022edefb075851e3141407617f26bb310f5711" +dependencies = [ + "ahash 0.8.3", + "anyhow", + "base64 0.13.1", + "dashmap", + "either", + "indexmap", + "jsonc-parser", + "lru 0.10.0", + "once_cell", + "parking_lot", + "pathdiff", + "regex", + "rustc-hash", + "serde", + "serde_json", + "sourcemap", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_config", + "swc_ecma_ast 0.106.6", + "swc_ecma_codegen 0.141.11", + "swc_ecma_ext_transforms 0.105.10", + "swc_ecma_lints 0.84.14", + "swc_ecma_loader", + "swc_ecma_minifier 0.183.21", + "swc_ecma_parser 0.136.8", + "swc_ecma_preset_env 0.197.20", + "swc_ecma_transforms 0.220.19", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_compat 0.155.17", + "swc_ecma_transforms_optimization 0.189.19", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", + "swc_error_reporters", + "swc_node_comments", + "swc_timer", + "swc_visit", + "tracing", + "url", +] + [[package]] name = "swc_atoms" version = "0.5.6" @@ -5488,12 +5656,12 @@ version = "0.214.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a22f0573fef09dffc3db7094d29ef9445b4f09b76da650bc870060ca0b8c8a4" dependencies = [ - "ahash", + "ahash 0.7.6", "anyhow", "crc", "dashmap", "indexmap", - "is-macro", + "is-macro 0.2.2", "once_cell", "parking_lot", "petgraph", @@ -5502,14 +5670,14 @@ dependencies = [ "relative-path", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_codegen", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen 0.139.17", "swc_ecma_loader", - "swc_ecma_parser", - "swc_ecma_transforms_base", - "swc_ecma_transforms_optimization", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_parser 0.134.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_optimization 0.187.24", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", "swc_fast_graph", "swc_graph_analyzer", "tracing", @@ -5517,11 +5685,11 @@ dependencies = [ [[package]] name = "swc_cached" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9745d42d167cb60aeb1e85d2ee813ca455c3185bf7417f11fd102d745ae2b9e1" +checksum = "97b8051bbf1c23817f9f2912fce18d9a6efcaaf8f8e1a4c69dbaf72bcaf71136" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", "dashmap", "once_cell", @@ -5531,11 +5699,11 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.31.12" +version = "0.31.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c774005489d2907fb67909cf42af926e72edee1366512777c605ba2ef19c94" +checksum = "c6414bd4e553f5638961d39b07075ffd37a3d63176829592f4a5900260d94ca1" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", "ast_node", "atty", @@ -5565,9 +5733,9 @@ dependencies = [ [[package]] name = "swc_config" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c8fc2c12bb1634c7c32fc3c9b6b963ad8f034cc62c4ecddcf215dc4f6f959d" +checksum = "9ba1c7a40d38f9dd4e9a046975d3faf95af42937b34b2b963be4d8f01239584b" dependencies = [ "indexmap", "serde", @@ -5577,15 +5745,15 @@ dependencies = [ [[package]] name = "swc_config_macro" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dadb9998d4f5fc36ef558ed5a092579441579ee8c6fcce84a5228cca9df4004" +checksum = "e5b5aaca9a0082be4515f0fbbecc191bf5829cd25b5b9c0a2810f6a2bb0d6829" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -5595,7 +5763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05ce227c715f658e5f0367f1c75c908672d76de4dc69646e27f5f62e8380f5de" dependencies = [ "binding_macros", - "swc", + "swc 0.261.41", "swc_atoms", "swc_bundler", "swc_cached", @@ -5608,22 +5776,22 @@ dependencies = [ "swc_css_prefixer", "swc_css_utils", "swc_css_visit", - "swc_ecma_ast", - "swc_ecma_codegen", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen 0.139.17", "swc_ecma_loader", - "swc_ecma_minifier", - "swc_ecma_parser", - "swc_ecma_preset_env", - "swc_ecma_quote_macros", - "swc_ecma_transforms_base", - "swc_ecma_transforms_module", - "swc_ecma_transforms_optimization", - "swc_ecma_transforms_proposal", - "swc_ecma_transforms_react", - "swc_ecma_transforms_testing", - "swc_ecma_transforms_typescript", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_minifier 0.181.31", + "swc_ecma_parser 0.134.12", + "swc_ecma_preset_env 0.195.26", + "swc_ecma_quote_macros 0.45.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_module 0.170.20", + "swc_ecma_transforms_optimization 0.187.24", + "swc_ecma_transforms_proposal 0.161.23", + "swc_ecma_transforms_react 0.173.20", + "swc_ecma_transforms_testing 0.130.18", + "swc_ecma_transforms_typescript 0.177.24", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", "swc_nodejs_common", "swc_plugin_proxy", "swc_plugin_runner", @@ -5632,13 +5800,38 @@ dependencies = [ "vergen", ] +[[package]] +name = "swc_core" +version = "0.78.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9947b392ed7b221b846814f97599d4aee1b8e75fd750f7a772402b59a3d3cec" +dependencies = [ + "swc 0.263.24", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_codegen 0.141.11", + "swc_ecma_parser 0.136.8", + "swc_ecma_preset_env 0.197.20", + "swc_ecma_quote_macros 0.47.8", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_module 0.172.18", + "swc_ecma_transforms_react 0.175.18", + "swc_ecma_transforms_testing 0.132.14", + "swc_ecma_transforms_typescript 0.179.19", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", + "testing", + "vergen", +] + [[package]] name = "swc_css_ast" version = "0.137.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df74aad6d6957b9e9e8b9dde5b4531d0a7f937b79089706bd71f9edcf98e8f34" dependencies = [ - "is-macro", + "is-macro 0.2.2", "serde", "string_enum", "swc_atoms", @@ -5651,8 +5844,8 @@ version = "0.147.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d78b141280c45b9f5686774249f37e7e378105da26420ffbf2c3e89c17844cf" dependencies = [ - "auto_impl", - "bitflags 2.2.1", + "auto_impl 0.5.0", + "bitflags 2.3.2", "rustc-hash", "serde", "swc_atoms", @@ -5668,7 +5861,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01c132d9ba562343f7c49d776c4a09b362a4a4104b7cb0a0f7b785986a492e1b" dependencies = [ - "pmutil", + "pmutil 0.5.3", "proc-macro2", "quote", "swc_macros_common", @@ -5681,7 +5874,7 @@ version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c25d3a2b9059531a42c1af84ff4d2a4367f5f684038ed13583cfc8fcfbc41602" dependencies = [ - "bitflags 2.2.1", + "bitflags 2.3.2", "once_cell", "serde", "serde_json", @@ -5714,7 +5907,7 @@ version = "0.146.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1002e94d2650f470c07ce48bbfc72080163480648766a197fc7b436f10eff10f" dependencies = [ - "bitflags 2.2.1", + "bitflags 2.3.2", "lexical", "serde", "swc_atoms", @@ -5773,9 +5966,9 @@ version = "0.104.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5cf9dd351d0c285dcd36535267953a18995d4dda0cbe34ac9d1df61aa415b26" dependencies = [ - "bitflags 2.2.1", + "bitflags 2.3.2", "bytecheck", - "is-macro", + "is-macro 0.2.2", "num-bigint", "rkyv", "scoped-tls", @@ -5786,6 +5979,23 @@ dependencies = [ "unicode-id", ] +[[package]] +name = "swc_ecma_ast" +version = "0.106.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebf4d6804b1da4146c4c0359d129e3dd43568d321f69d7953d9abbca4ded76ba" +dependencies = [ + "bitflags 2.3.2", + "is-macro 0.3.0", + "num-bigint", + "scoped-tls", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "unicode-id", +] + [[package]] name = "swc_ecma_codegen" version = "0.139.17" @@ -5800,22 +6010,41 @@ dependencies = [ "sourcemap", "swc_atoms", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen_macros", + "tracing", +] + +[[package]] +name = "swc_ecma_codegen" +version = "0.141.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3845e22d8593a617b973b5f65f3567170b41eb964a70a267b1ec4995dfe5013" +dependencies = [ + "memchr", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "sourcemap", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", "swc_ecma_codegen_macros", "tracing", ] [[package]] name = "swc_ecma_codegen_macros" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ee0caee1018808d94ecd09490cb7affd3d504b19aa11c49238f5fc4b54901" +checksum = "dcdff076dccca6cc6a0e0b2a2c8acfb066014382bc6df98ec99e755484814384" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -5827,9 +6056,23 @@ dependencies = [ "phf", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_ext_transforms" +version = "0.105.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3ae43df15bac02f1cded6754041da244a21688fd39cf876984f78b8856c76c" +dependencies = [ + "phf", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -5838,8 +6081,29 @@ version = "0.82.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48d5b6aadff572b212ceadba56da45a6bb9af7d67ce1c234a27073d4ec4e6361" dependencies = [ - "ahash", - "auto_impl", + "ahash 0.7.6", + "auto_impl 0.5.0", + "dashmap", + "parking_lot", + "rayon", + "regex", + "serde", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast 0.104.5", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_lints" +version = "0.84.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300cc5f51b8a3cc81758fdc34192552a97dff46716f9e1d7d6bf73ee922f3431" +dependencies = [ + "ahash 0.8.3", + "auto_impl 1.1.0", "dashmap", "parking_lot", "rayon", @@ -5848,21 +6112,21 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.106.6", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] name = "swc_ecma_loader" -version = "0.43.14" +version = "0.43.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe45f1e5dcc1b005544ff78253b787dea5dfd5e2f712b133964cdc3545c954a4" +checksum = "8d40f8d1626b33ba85ee17f43268b3bb6382278b9d3a3c1faa52c57e71769a60" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", "dashmap", - "lru", + "lru 0.10.0", "normpath", "once_cell", "parking_lot", @@ -5881,7 +6145,7 @@ version = "0.181.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f85eb56b6c5a8ba4e91141602511b9c5a390bad4c8e454bff77d80c2033c265" dependencies = [ - "ahash", + "ahash 0.7.6", "arrayvec", "indexmap", "num-bigint", @@ -5899,14 +6163,49 @@ dependencies = [ "swc_cached", "swc_common", "swc_config", - "swc_ecma_ast", - "swc_ecma_codegen", - "swc_ecma_parser", - "swc_ecma_transforms_base", - "swc_ecma_transforms_optimization", - "swc_ecma_usage_analyzer", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen 0.139.17", + "swc_ecma_parser 0.134.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_optimization 0.187.24", + "swc_ecma_usage_analyzer 0.13.16", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_minifier" +version = "0.183.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "befc43e839f60e0cf38df7f70d39dd79922028efbaf738b511fb5c137fb574b1" +dependencies = [ + "ahash 0.8.3", + "arrayvec", + "indexmap", + "num-bigint", + "num_cpus", + "once_cell", + "parking_lot", + "radix_fmt", + "regex", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_config", + "swc_ecma_ast 0.106.6", + "swc_ecma_codegen 0.141.11", + "swc_ecma_parser 0.136.8", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_optimization 0.189.19", + "swc_ecma_usage_analyzer 0.15.11", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "swc_timer", "tracing", ] @@ -5926,7 +6225,27 @@ dependencies = [ "stacker", "swc_atoms", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_ecma_parser" +version = "0.136.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45d40421c607d7a48334f78a9b24a5cbde1f36250f9986746ec082208d68b39f" +dependencies = [ + "either", + "lexical", + "num-bigint", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", "tracing", "typed-arena", ] @@ -5937,7 +6256,32 @@ version = "0.195.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384802032a00bc0e67993e7c3c9a28b82af19c5685eb9d8f93655376f3f823c2" dependencies = [ - "ahash", + "ahash 0.7.6", + "anyhow", + "dashmap", + "indexmap", + "once_cell", + "preset_env_base", + "semver 1.0.17", + "serde", + "serde_json", + "st-map 0.1.8", + "string_enum", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms 0.218.24", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_preset_env" +version = "0.197.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c4d926e3772345fd2abe5058915f21250e145f9c312462a98ad5201e687f7a" +dependencies = [ + "ahash 0.8.3", "anyhow", "dashmap", "indexmap", @@ -5946,14 +6290,14 @@ dependencies = [ "semver 1.0.17", "serde", "serde_json", - "st-map", + "st-map 0.2.0", "string_enum", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms 0.220.19", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -5963,26 +6307,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eff371cf036e2c5fb7bf404f7c1a30a22ee4b64d04fb9354a9b057cbd4d59c9b" dependencies = [ "anyhow", - "pmutil", + "pmutil 0.5.3", "proc-macro2", "quote", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_parser", + "swc_ecma_ast 0.104.5", + "swc_ecma_parser 0.134.12", "swc_macros_common", "syn 1.0.109", ] +[[package]] +name = "swc_ecma_quote_macros" +version = "0.47.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f583b2bd7fb8d3def4313912008111044bbd16cd9a10ee9c009d69eaa8e558ba" +dependencies = [ + "anyhow", + "pmutil 0.6.1", + "proc-macro2", + "quote", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_parser 0.136.8", + "swc_macros_common", + "syn 2.0.18", +] + [[package]] name = "swc_ecma_testing" -version = "0.20.8" +version = "0.20.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25198f96ef93c4bb4cc8fa13c9b22a018cf2c0c7609ee91f7abc7968ebc2e2df" +checksum = "b90ea04390a92f949fbf2d3c411bc7ab82c0981dea04cc18fe6ae1a4e471f121" dependencies = [ "anyhow", "hex", "sha-1", + "testing", "tracing", ] @@ -5994,16 +6357,36 @@ checksum = "dbe5ca1c16b4ea9ece9f43a24554edce402641c46b2cc4e418be6c40897572b0" dependencies = [ "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms_base", - "swc_ecma_transforms_compat", - "swc_ecma_transforms_module", - "swc_ecma_transforms_optimization", - "swc_ecma_transforms_proposal", - "swc_ecma_transforms_react", - "swc_ecma_transforms_typescript", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_compat 0.153.20", + "swc_ecma_transforms_module 0.170.20", + "swc_ecma_transforms_optimization 0.187.24", + "swc_ecma_transforms_proposal 0.161.23", + "swc_ecma_transforms_react 0.173.20", + "swc_ecma_transforms_typescript 0.177.24", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_transforms" +version = "0.220.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cfb7ec24e83d284b33b30e2b343262078fdb8382b5340858426b12b6aab8d21" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_compat 0.155.17", + "swc_ecma_transforms_module 0.172.18", + "swc_ecma_transforms_optimization 0.189.19", + "swc_ecma_transforms_proposal 0.163.17", + "swc_ecma_transforms_react 0.175.18", + "swc_ecma_transforms_typescript 0.179.19", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -6013,7 +6396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9c33ec5369178f3a0580ab86cfe89ffb9c3fbd122aed379cfb71d469d9d61c1" dependencies = [ "better_scoped_tls", - "bitflags 2.2.1", + "bitflags 2.3.2", "indexmap", "once_cell", "phf", @@ -6023,10 +6406,33 @@ dependencies = [ "smallvec", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_parser", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_parser 0.134.12", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_base" +version = "0.129.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef3d6800cc1500dfb6983cefac6c6dbf0ea8b2af8dcb1d2e25cae01226479744" +dependencies = [ + "better_scoped_tls", + "bitflags 2.3.2", + "indexmap", + "once_cell", + "phf", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_parser 0.136.8", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "tracing", ] @@ -6038,10 +6444,24 @@ checksum = "6e3b0d5f362f0da97be1f1b06d7b0d8667ea70b4adeabff0dcaecb6259c09525" dependencies = [ "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms_base", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_transforms_classes" +version = "0.118.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd5380415af454bcc6dc9de726064186adc65e6be20eb9c9eb49b0b6d518e361" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -6050,10 +6470,10 @@ version = "0.153.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "851739faeec27389fbfe5b170534df7868bbcc5c78f229f22fce43f004858eca" dependencies = [ - "ahash", + "ahash 0.7.6", "arrayvec", "indexmap", - "is-macro", + "is-macro 0.2.2", "num-bigint", "rayon", "serde", @@ -6061,27 +6481,53 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast", - "swc_ecma_transforms_base", - "swc_ecma_transforms_classes", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_classes 0.116.18", + "swc_ecma_transforms_macros", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_compat" +version = "0.155.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900373ed4e2ce81d58152b781f5fe37e0b5ba1989805e8a60d97981c4d189a22" +dependencies = [ + "ahash 0.8.3", + "arrayvec", + "indexmap", + "is-macro 0.3.0", + "num-bigint", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_classes 0.118.14", "swc_ecma_transforms_macros", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_transforms_macros" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984d5ac69b681fc5438f9abf82b0fda34fe04e119bc75f8213b7e01128c7c9a2" +checksum = "f59c4b6ed5d78d3ad9fc7c6f8ab4f85bba99573d31d9a2c0a712077a6b45efd2" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -6091,11 +6537,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1595b0522333346488ad7354ad55d4ed337d4e5d7ded5e4d468c523ecb9a495" dependencies = [ "Inflector", - "ahash", + "ahash 0.7.6", "anyhow", - "bitflags 2.2.1", + "bitflags 2.3.2", "indexmap", - "is-macro", + "is-macro 0.2.2", "path-clean", "pathdiff", "regex", @@ -6103,12 +6549,40 @@ dependencies = [ "swc_atoms", "swc_cached", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", "swc_ecma_loader", - "swc_ecma_parser", - "swc_ecma_transforms_base", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_parser 0.134.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_module" +version = "0.172.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c98365d03820a51eacba68cd703460f1c36b09ed81cd99cb93d1088f92dc35" +dependencies = [ + "Inflector", + "ahash 0.8.3", + "anyhow", + "bitflags 2.3.2", + "indexmap", + "is-macro 0.3.0", + "path-clean", + "pathdiff", + "regex", + "serde", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_loader", + "swc_ecma_parser 0.136.8", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "tracing", ] @@ -6118,7 +6592,7 @@ version = "0.187.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fff2641ba155b3aaa8ef15c1888d75b73e9f10431ec1cb58e66598266199322" dependencies = [ - "ahash", + "ahash 0.7.6", "dashmap", "indexmap", "once_cell", @@ -6128,12 +6602,37 @@ dependencies = [ "serde_json", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_parser", - "swc_ecma_transforms_base", + "swc_ecma_ast 0.104.5", + "swc_ecma_parser 0.134.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_macros", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "swc_fast_graph", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_optimization" +version = "0.189.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89756d0ace7efd6acd7223e19e19d789765f95112f247436b7ab42ac9cfae68b" +dependencies = [ + "ahash 0.8.3", + "dashmap", + "indexmap", + "once_cell", + "petgraph", + "rustc-hash", + "serde_json", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_parser 0.136.8", + "swc_ecma_transforms_base 0.129.14", "swc_ecma_transforms_macros", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "swc_fast_graph", "tracing", ] @@ -6150,12 +6649,32 @@ dependencies = [ "smallvec", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms_base", - "swc_ecma_transforms_classes", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_classes 0.116.18", + "swc_ecma_transforms_macros", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_transforms_proposal" +version = "0.163.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6492a52ff1a98f36a12155f865db58bbfcae5fca77e76545cccd5ebcc77bd780" +dependencies = [ + "either", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_classes 0.118.14", "swc_ecma_transforms_macros", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -6164,7 +6683,7 @@ version = "0.173.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fb9481ad4e2acba34c6fbb6d4ccc64efe9f1821675e883dcfa732d7220f4b1e" dependencies = [ - "ahash", + "ahash 0.7.6", "base64 0.13.1", "dashmap", "indexmap", @@ -6176,12 +6695,37 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast", - "swc_ecma_parser", - "swc_ecma_transforms_base", + "swc_ecma_ast 0.104.5", + "swc_ecma_parser 0.134.12", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_macros", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_transforms_react" +version = "0.175.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67bc38b58cb66cbfd1ad9440073289a3d827b8b1fd2831126f1a3bfae99ec430" +dependencies = [ + "ahash 0.8.3", + "base64 0.13.1", + "dashmap", + "indexmap", + "once_cell", + "serde", + "sha-1", + "string_enum", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast 0.106.6", + "swc_ecma_parser 0.136.8", + "swc_ecma_transforms_base 0.129.14", "swc_ecma_transforms_macros", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -6199,13 +6743,39 @@ dependencies = [ "sha-1", "sourcemap", "swc_common", - "swc_ecma_ast", - "swc_ecma_codegen", - "swc_ecma_parser", + "swc_ecma_ast 0.104.5", + "swc_ecma_codegen 0.139.17", + "swc_ecma_parser 0.134.12", + "swc_ecma_testing", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "tempfile", + "testing", +] + +[[package]] +name = "swc_ecma_transforms_testing" +version = "0.132.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857ed24bc19b38c311c6e479685d00d32052babc8a25db4cef26f0aa28c2b5d8" +dependencies = [ + "ansi_term", + "anyhow", + "base64 0.13.1", + "hex", + "serde", + "serde_json", + "sha-1", + "sourcemap", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_codegen 0.141.11", + "swc_ecma_parser 0.136.8", "swc_ecma_testing", - "swc_ecma_transforms_base", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "tempfile", "testing", ] @@ -6219,11 +6789,27 @@ dependencies = [ "serde", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_transforms_base", - "swc_ecma_transforms_react", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_transforms_base 0.127.18", + "swc_ecma_transforms_react 0.173.20", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", +] + +[[package]] +name = "swc_ecma_transforms_typescript" +version = "0.179.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e235c8b8fdac92de7255b40912077680106ff89de5d8595415d516f389fb9d0" +dependencies = [ + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_transforms_base 0.129.14", + "swc_ecma_transforms_react 0.175.18", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", ] [[package]] @@ -6232,14 +6818,32 @@ version = "0.13.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7da59ebce19380671e76cfe7e9b0cdd6f430b3090c65c24aefcc07ed63739f2" dependencies = [ - "ahash", + "ahash 0.7.6", "indexmap", "rustc-hash", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_utils", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_utils 0.117.13", + "swc_ecma_visit 0.90.5", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_usage_analyzer" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1112dc11f631433c8794b1a46908d146f82af347a1a1aa434291f9f5bcbbac" +dependencies = [ + "ahash 0.8.3", + "indexmap", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_utils 0.119.10", + "swc_ecma_visit 0.92.5", "swc_timer", "tracing", ] @@ -6257,8 +6861,26 @@ dependencies = [ "rustc-hash", "swc_atoms", "swc_common", - "swc_ecma_ast", - "swc_ecma_visit", + "swc_ecma_ast 0.104.5", + "swc_ecma_visit 0.90.5", + "tracing", + "unicode-id", +] + +[[package]] +name = "swc_ecma_utils" +version = "0.119.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "452c66399edeb88a97bfdc3bbf11e45db85fdf883bfd4fc8bdd93abb92152b9b" +dependencies = [ + "indexmap", + "num_cpus", + "once_cell", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", + "swc_ecma_visit 0.92.5", "tracing", "unicode-id", ] @@ -6272,7 +6894,21 @@ dependencies = [ "num-bigint", "swc_atoms", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_visit" +version = "0.92.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f61da6cac0ec3b7e62d367cfbd9e38e078a4601271891ad94f0dac5ff69f839" +dependencies = [ + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast 0.106.6", "swc_visit", "tracing", ] @@ -6291,27 +6927,27 @@ dependencies = [ "regex", "serde", "sourcemap", - "swc_core", + "swc_core 0.76.48", "tracing", ] [[package]] name = "swc_eq_ignore_macros" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c20468634668c2bbab581947bb8c75c97158d5a6959f4ba33df20983b20b4f6" +checksum = "05a95d367e228d52484c53336991fdcf47b6b553ef835d9159db4ba40efb0ee8" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "swc_error_reporters" -version = "0.15.12" +version = "0.15.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ce9ba211e75848f6aff1c64ee16c71006bd93e45a37f4e149c22625f26d8c" +checksum = "108322b719696e8c368c39dc6d8748494ea2aa870e7d80ea5956078aa6b4dd4d" dependencies = [ "anyhow", "miette", @@ -6322,9 +6958,9 @@ dependencies = [ [[package]] name = "swc_fast_graph" -version = "0.19.12" +version = "0.19.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6291149aec4ba55076fd54a12ceb84cac1f703b2f571c3b2f19aa66ab9ec3009" +checksum = "b19b76468219b923c34efdeff812fa951fe1a1ecaba78118b013d034a1669ff5" dependencies = [ "indexmap", "petgraph", @@ -6338,8 +6974,8 @@ version = "0.20.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6575adec8b200801d429ffa79166224a6e298292a1b307750f4763aec5aa16c3" dependencies = [ - "ahash", - "auto_impl", + "ahash 0.7.6", + "auto_impl 0.5.0", "petgraph", "swc_fast_graph", "tracing", @@ -6347,23 +6983,23 @@ dependencies = [ [[package]] name = "swc_macros_common" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e582c3e3c2269238524923781df5be49e011dbe29cf7683a2215d600a562ea6" +checksum = "7a273205ccb09b51fabe88c49f3b34c5a4631c4c00a16ae20e03111d6a42e832" dependencies = [ - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "swc_node_comments" -version = "0.18.12" +version = "0.18.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "800d308508c0517a04f115c769cf398c23a62bcb8bfa186b7d15c42861b7448a" +checksum = "61839f8a936b5c95ce644d539914bb944b094eee9bd156c3dc41fe8e7eaa84ea" dependencies = [ - "ahash", + "ahash 0.8.3", "dashmap", "swc_atoms", "swc_common", @@ -6392,7 +7028,7 @@ dependencies = [ "better_scoped_tls", "rkyv", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", "swc_trace_macro", "tracing", ] @@ -6410,7 +7046,7 @@ dependencies = [ "serde", "serde_json", "swc_common", - "swc_ecma_ast", + "swc_ecma_ast 0.104.5", "swc_plugin_proxy", "tokio", "tracing", @@ -6431,35 +7067,35 @@ dependencies = [ "serde", "serde_json", "swc_common", - "swc_core", + "swc_core 0.76.48", "tracing", ] [[package]] name = "swc_timer" -version = "0.19.13" +version = "0.19.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0dd693178fc91bfac6f380f312f9adcb2dbe753e439ecf929289dfe7a30a893" +checksum = "9889bf48909289e13e0f343eb8d1238e674e9380a4dd6c6346f62b83cb30236f" dependencies = [ "tracing", ] [[package]] name = "swc_trace_macro" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4795c8d23e0de62eef9cac0a20ae52429ee2ffc719768e838490f195b7d7267" +checksum = "ff9719b6085dd2824fd61938a881937be14b08f95e2d27c64c825a9f65e052ba" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "swc_visit" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f412dd4fbc58f509a04e64f5c8038333142fc139e8232f01b883db0094b3b51" +checksum = "e87c337fbb2d191bf371173dea6a957f01899adb8f189c6c31b122a6cfc98fc3" dependencies = [ "either", "swc_visit_macros", @@ -6467,16 +7103,16 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfc226380ba54a5feed2c12f3ccd33f1ae8e959160290e5d2d9b4e918b6472a" +checksum = "0f322730fb82f3930a450ac24de8c98523af7d34ab8cb2f46bcb405839891a99" dependencies = [ "Inflector", - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "swc_macros_common", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -6541,15 +7177,16 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -6592,11 +7229,12 @@ dependencies = [ [[package]] name = "testing" -version = "0.33.13" +version = "0.33.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0901b02da634d6e420bc20716d86c2ee679ee852e126b23b6a478d6c83361956" +checksum = "359d2548f4919624af6cd1001e0a3ac9f081f8312e47fdca7650c11c9935981b" dependencies = [ "ansi_term", + "cargo_metadata", "difference", "once_cell", "pretty_assertions", @@ -6611,19 +7249,19 @@ dependencies = [ [[package]] name = "testing_macros" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5315a85a7262fe1a8898890b616de62c152dd43cb5974752c0927aaabe48891" +checksum = "d1c15b796025051a07f1ac695ee0cac0883f05a0d510c9d171ef8d31a992e6a5" dependencies = [ "anyhow", "glob", "once_cell", - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", "regex", "relative-path", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -7370,7 +8008,7 @@ dependencies = [ "node-file-trace", "styled_components", "styled_jsx", - "swc_core", + "swc_core 0.76.48", "swc_emotion", "swc_relay", "testing", @@ -7464,7 +8102,7 @@ dependencies = [ "serde_json", "serde_qs", "sourcemap", - "swc_core", + "swc_core 0.76.48", "tracing", "turbo-tasks", "turbo-tasks-build", @@ -7498,7 +8136,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core", + "swc_core 0.76.48", "turbo-tasks", "turbo-tasks-build", "turbo-tasks-fs", @@ -7519,7 +8157,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "swc_core", + "swc_core 0.76.48", "tracing", "turbo-tasks", "turbo-tasks-build", @@ -7588,7 +8226,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "swc_core", + "swc_core 0.76.48", "tokio", "tracing", "turbo-tasks", @@ -7613,7 +8251,7 @@ dependencies = [ "serde_json", "styled_components", "styled_jsx", - "swc_core", + "swc_core 0.76.48", "swc_emotion", "swc_relay", "turbo-tasks", @@ -7631,7 +8269,7 @@ dependencies = [ "anyhow", "indoc", "serde", - "swc_core", + "swc_core 0.76.48", "turbo-tasks", "turbo-tasks-build", "turbo-tasks-fs", @@ -7762,7 +8400,7 @@ name = "turbopack-swc-utils" version = "0.1.0" source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230622.2#08aba99a2796b37324cabf18b6ea9eff886d93b4" dependencies = [ - "swc_core", + "swc_core 0.76.48", "turbo-tasks", "turbo-tasks-build", "turbopack-core", @@ -7789,7 +8427,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] @@ -7872,7 +8510,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", "regex", ] @@ -7917,9 +8555,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -8181,7 +8819,7 @@ dependencies = [ "serde", "serde-wasm-bindgen", "serde_json", - "swc_core", + "swc_core 0.78.24", "tracing", "turbopack-binding", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 40e3989b9b62..1441f3e75ed6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-tran # SWC crates # Keep consistent with preset_env_base through swc_core -swc_core = { version = "0.76.46" } -testing = { version = "0.33.13" } +swc_core = { version = "0.78.24" } +testing = { version = "0.33.19" } # Turbo crates turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230622.2" } From 525ecf41580127cdf3646594b5acac081e50faf5 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Wed, 28 Jun 2023 12:50:45 -0400 Subject: [PATCH 14/30] Ensure `edge` runtime Pages API/App Route handlers `AbortSignal` aborts on client disconnect (#51727) ### What? This ensures the `request.signal` `AbortSignal` that every Pages API and App Route handler receives aborts when the client disconnects. ### Why? Now that we [support cancelling](https://github.com/vercel/next.js/pull/51594) responses mid-stream, it's important that we can communicate that abort to developer code. Eg, for AI endpoints that have an streaming `fetch` connection to the some 3p AI service, it's important that they're able to abort that stream when the client's browser disconnects. ### How? Just need to listen for `error` events on Node's `IncomingMessage` request object, and forward that to an `AbortController`. After that, propagate the signal through the server to web-style handlers. --- packages/next/src/server/next-server.ts | 7 +++++++ packages/next/src/server/web/adapter.ts | 1 + .../web/spec-extension/adapters/next-request.ts | 13 +++++++++++++ .../next/src/server/web/spec-extension/request.ts | 3 ++- packages/next/src/server/web/types.ts | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index 70605da0c352..2d6470d948bc 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -110,6 +110,7 @@ import { filterReqHeaders } from './lib/server-ipc/utils' import { createRequestResponseMocks } from './lib/mock-request' import chalk from 'next/dist/compiled/chalk' import { NEXT_RSC_UNION_QUERY } from '../client/components/app-router-headers' +import { signalFromNodeRequest } from './web/spec-extension/adapters/next-request' export * from './base-server' @@ -2342,6 +2343,9 @@ export default class NextNodeServer extends BaseServer { url: url, page: page, body: getRequestMeta(params.request, '__NEXT_CLONABLE_BODY'), + signal: signalFromNodeRequest( + (params.request as NodeNextRequest).originalRequest + ), }, useCache: true, onWarning: params.onWarning, @@ -2851,6 +2855,9 @@ export default class NextNodeServer extends BaseServer { ...(params.params && { params: params.params }), }, body: getRequestMeta(params.req, '__NEXT_CLONABLE_BODY'), + signal: signalFromNodeRequest( + (params.req as NodeNextRequest).originalRequest + ), }, useCache: true, onWarning: params.onWarning, diff --git a/packages/next/src/server/web/adapter.ts b/packages/next/src/server/web/adapter.ts index 60c2abfcd5e5..5a8c953ad71a 100644 --- a/packages/next/src/server/web/adapter.ts +++ b/packages/next/src/server/web/adapter.ts @@ -132,6 +132,7 @@ export async function adapter( ip: params.request.ip, method: params.request.method, nextConfig: params.request.nextConfig, + signal: params.request.signal, }, }) diff --git a/packages/next/src/server/web/spec-extension/adapters/next-request.ts b/packages/next/src/server/web/spec-extension/adapters/next-request.ts index 2248629df1e2..3efe37370b34 100644 --- a/packages/next/src/server/web/spec-extension/adapters/next-request.ts +++ b/packages/next/src/server/web/spec-extension/adapters/next-request.ts @@ -1,11 +1,22 @@ import type { BaseNextRequest } from '../../../base-http' import type { NodeNextRequest } from '../../../base-http/node' import type { WebNextRequest } from '../../../base-http/web' +import type { IncomingMessage } from 'node:http' import { getRequestMeta } from '../../../request-meta' import { fromNodeOutgoingHttpHeaders } from '../../utils' import { NextRequest } from '../request' +export function signalFromNodeRequest(request: IncomingMessage) { + const { errored } = request + if (errored) return AbortSignal.abort(errored) + const controller = new AbortController() + request.on('error', (e) => { + controller.abort(e) + }) + return controller.signal +} + export class NextRequestAdapter { public static fromBaseNextRequest(request: BaseNextRequest): NextRequest { // TODO: look at refining this check @@ -46,6 +57,7 @@ export class NextRequestAdapter { headers: fromNodeOutgoingHttpHeaders(request.headers), // @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457 duplex: 'half', + signal: signalFromNodeRequest(request.originalRequest), // geo // ip // nextConfig @@ -65,6 +77,7 @@ export class NextRequestAdapter { headers: fromNodeOutgoingHttpHeaders(request.headers), // @ts-expect-error - see https://github.com/whatwg/fetch/pull/1457 duplex: 'half', + signal: request.request.signal, // geo // ip // nextConfig diff --git a/packages/next/src/server/web/spec-extension/request.ts b/packages/next/src/server/web/spec-extension/request.ts index 84cdba908e0c..de893ce522d7 100644 --- a/packages/next/src/server/web/spec-extension/request.ts +++ b/packages/next/src/server/web/spec-extension/request.ts @@ -16,7 +16,7 @@ export class NextRequest extends Request { nextUrl: NextURL } - constructor(input: URL | RequestInfo, init: RequestInit = {}) { + constructor(input: URL | RequestInfo, init: RequestInit) { const url = typeof input !== 'string' && 'url' in input ? input.url : String(input) validateURL(url) @@ -111,4 +111,5 @@ export interface RequestInit extends globalThis.RequestInit { i18n?: I18NConfig | null trailingSlash?: boolean } + signal?: AbortSignal } diff --git a/packages/next/src/server/web/types.ts b/packages/next/src/server/web/types.ts index 6d4cb7f6f89a..4ca61bb6c644 100644 --- a/packages/next/src/server/web/types.ts +++ b/packages/next/src/server/web/types.ts @@ -27,6 +27,7 @@ export interface RequestData { } url: string body?: ReadableStream + signal: AbortSignal } export type NodejsRequestData = Omit & { From fd13fb5e645c5bdc874040fee7a8ef95d0ce10f8 Mon Sep 17 00:00:00 2001 From: Leah Date: Wed, 28 Jun 2023 19:35:04 +0200 Subject: [PATCH 15/30] Revert "Update `swc_core` to `v0.78.24`" (#51940) Reverts vercel/next.js#51857 Because a turbopack update with the matching swc versions wasn't included, this would increase the binary size --- Cargo.lock | 1192 ++++++++++++---------------------------------------- Cargo.toml | 4 +- 2 files changed, 279 insertions(+), 917 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6a17381a587..60e34b719f90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,18 +39,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if 1.0.0", - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "1.0.1" @@ -172,15 +160,15 @@ dependencies = [ [[package]] name = "ast_node" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c09c69dffe06d222d072c878c3afe86eee2179806f20503faec97250268b4c24" +checksum = "c704e2f6ee1a98223f5a7629a6ef0f3decb3b552ed282889dc957edff98ce1e6" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -429,18 +417,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "auto_impl" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -533,9 +509,9 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "better_scoped_tls" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" +checksum = "b73e8ecdec39e98aa3b19e8cd0b8ed8f77ccb86a6b0b2dc7cd86d105438a2123" dependencies = [ "scoped-tls", ] @@ -561,11 +537,11 @@ dependencies = [ "once_cell", "serde", "serde-wasm-bindgen", - "swc 0.261.41", + "swc", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms 0.218.24", - "swc_ecma_visit 0.90.5", + "swc_ecma_ast", + "swc_ecma_transforms", + "swc_ecma_visit", "wasm-bindgen", "wasm-bindgen-futures", ] @@ -578,9 +554,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.2" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbe3c979c178231552ecba20214a8272df4e09f232a87aef4320cf06539aded" +checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" [[package]] name = "bitreader" @@ -656,7 +632,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef956561c9a03c35af46714efd0c135e21768a2a012f900ca8a59b28e75d0cd1" dependencies = [ - "ahash 0.7.6", + "ahash", "anyhow", "chrono", "either", @@ -723,15 +699,6 @@ dependencies = [ "serde", ] -[[package]] -name = "camino" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" -dependencies = [ - "serde", -] - [[package]] name = "cargo-lock" version = "8.0.3" @@ -744,29 +711,6 @@ dependencies = [ "url", ] -[[package]] -name = "cargo-platform" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.17", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cast" version = "0.3.0" @@ -929,7 +873,7 @@ version = "4.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" dependencies = [ - "bitflags 2.3.2", + "bitflags 2.2.1", "clap_derive", "clap_lex 0.3.3", "is-terminal", @@ -1209,7 +1153,7 @@ checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" dependencies = [ "cranelift-entity", "fxhash", - "hashbrown 0.12.3", + "hashbrown", "indexmap", "log", "smallvec", @@ -1532,7 +1476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ "cfg-if 1.0.0", - "hashbrown 0.12.3", + "hashbrown", "lock_api", "once_cell", "parking_lot_core 0.9.7", @@ -1848,23 +1792,23 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ "percent-encoding", ] [[package]] name = "from_variant" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ec5dc38ee19078d84a692b1c41181ff9f94331c76cee66ff0208c770b5e54f" +checksum = "1d449976075322384507443937df2f1d5577afbf4282f12a5a66ef29fa3e6307" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -2190,16 +2134,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", + "ahash", ] [[package]] @@ -2468,9 +2403,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2524,7 +2459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.12.3", + "hashbrown", "rayon", "serde", ] @@ -2597,25 +2532,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7d079e129b77477a49c5c4f1cfe9ce6c2c909ef52520693e8e811a714c7b20" dependencies = [ "Inflector", - "pmutil 0.5.3", + "pmutil", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "is-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" -dependencies = [ - "Inflector", - "pmutil 0.6.1", - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "is-terminal" version = "0.4.7" @@ -2956,16 +2878,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" dependencies = [ - "hashbrown 0.12.3", -] - -[[package]] -name = "lru" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" -dependencies = [ - "hashbrown 0.13.2", + "hashbrown", ] [[package]] @@ -3033,7 +2946,7 @@ checksum = "c88a71be094e8cf4f13b62e6ba304472332f8890e7cdf15098dc6512b812fdab" dependencies = [ "markdown", "serde", - "swc_core 0.76.48", + "swc_core", ] [[package]] @@ -3226,7 +3139,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core 0.76.48", + "swc_core", ] [[package]] @@ -3248,7 +3161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69b29acdc6cc5c918c3eabd51d241b1c6dfa8914f3552fcfd76e1d7536934581" dependencies = [ "anyhow", - "bitflags 2.3.2", + "bitflags 2.2.1", "ctor 0.2.0", "napi-derive", "napi-sys", @@ -3382,7 +3295,7 @@ dependencies = [ "regex", "serde", "serde_json", - "swc_core 0.78.24", + "swc_core", "thiserror", "turbo-tasks", "turbo-tasks-fs", @@ -3509,7 +3422,7 @@ name = "next-transform-dynamic" version = "0.1.0" dependencies = [ "pathdiff", - "swc_core 0.78.24", + "swc_core", "testing", ] @@ -3520,7 +3433,7 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "swc_core 0.78.24", + "swc_core", ] [[package]] @@ -3528,7 +3441,7 @@ name = "next-transform-strip-page-exports" version = "0.1.0" dependencies = [ "rustc-hash", - "swc_core 0.78.24", + "swc_core", "testing", "tracing", ] @@ -3711,9 +3624,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -3902,9 +3815,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" @@ -4081,17 +3994,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "pmutil" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "png" version = "0.17.8" @@ -4155,11 +4057,11 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "preset_env_base" -version = "0.4.5" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae83c5857727636a1f2c7188632c8a57986d2f1d2e2cf45f2642f5856c5b8e85" +checksum = "b09a48d8ea8b031bde7755cdf6f87f7123a0cbefc36b0cd09cbb2de726594393" dependencies = [ - "ahash 0.8.3", + "ahash", "anyhow", "browserslist-rs", "dashmap", @@ -4167,7 +4069,7 @@ dependencies = [ "once_cell", "semver 1.0.17", "serde", - "st-map 0.2.0", + "st-map", "tracing", ] @@ -4619,7 +4521,7 @@ checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ "bitvec", "bytecheck", - "hashbrown 0.12.3", + "hashbrown", "indexmap", "ptr_meta", "rend", @@ -5310,17 +5212,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f09d891835f076b0d4a58dd4478fb54d47aa3da1f7a4c6e89ad6c791357ab5ed" dependencies = [ "arrayvec", - "static-map-macro 0.2.5", -] - -[[package]] -name = "st-map" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f352d5d14be5a1f956d76ae0c8060c3487aaa2a080f10a4b4ff023c7c05a9047" -dependencies = [ - "arrayvec", - "static-map-macro 0.3.0", + "static-map-macro", ] [[package]] @@ -5357,24 +5249,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b862d598fbc9f7085b017890e2e61433f501e7467f2c585323e1aa3c07ef8599" dependencies = [ - "pmutil 0.5.3", + "pmutil", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "static-map-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7628ae0bd92555d3de4303da41a5c8b1c5363e892001325f34e4be9ed024d0d7" -dependencies = [ - "pmutil 0.6.1", - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -5458,15 +5338,15 @@ dependencies = [ [[package]] name = "string_enum" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa4d4f81d7c05b9161f8de839975d3326328b8ba2831164b465524cc2f55252" +checksum = "0090512bdfee4b56d82480d66c0fd8a6f53f0fe0f97e075e949b252acdd482e0" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -5485,7 +5365,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core 0.76.48", + "swc_core", "tracing", ] @@ -5496,7 +5376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9154a21e45febf6553717c0f962749669dcf0febd2880543d35ef3f05ef825c1" dependencies = [ "easy-error", - "swc_core 0.76.48", + "swc_core", "tracing", ] @@ -5540,14 +5420,14 @@ version = "0.261.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b59f4e1f5ebb10037de0a3a5c25d2fe7691f8811f42d3549fb81f2b9047205b" dependencies = [ - "ahash 0.7.6", + "ahash", "anyhow", "base64 0.13.1", "dashmap", "either", "indexmap", "jsonc-parser", - "lru 0.7.8", + "lru", "napi", "napi-derive", "once_cell", @@ -5562,20 +5442,20 @@ dependencies = [ "swc_cached", "swc_common", "swc_config", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen 0.139.17", - "swc_ecma_ext_transforms 0.103.13", - "swc_ecma_lints 0.82.18", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_ext_transforms", + "swc_ecma_lints", "swc_ecma_loader", - "swc_ecma_minifier 0.181.31", - "swc_ecma_parser 0.134.12", - "swc_ecma_preset_env 0.195.26", - "swc_ecma_transforms 0.218.24", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_compat 0.153.20", - "swc_ecma_transforms_optimization 0.187.24", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_preset_env", + "swc_ecma_transforms", + "swc_ecma_transforms_base", + "swc_ecma_transforms_compat", + "swc_ecma_transforms_optimization", + "swc_ecma_utils", + "swc_ecma_visit", "swc_error_reporters", "swc_node_comments", "swc_plugin_proxy", @@ -5586,54 +5466,6 @@ dependencies = [ "url", ] -[[package]] -name = "swc" -version = "0.263.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0352b9116b87a38d2a693c2c58022edefb075851e3141407617f26bb310f5711" -dependencies = [ - "ahash 0.8.3", - "anyhow", - "base64 0.13.1", - "dashmap", - "either", - "indexmap", - "jsonc-parser", - "lru 0.10.0", - "once_cell", - "parking_lot", - "pathdiff", - "regex", - "rustc-hash", - "serde", - "serde_json", - "sourcemap", - "swc_atoms", - "swc_cached", - "swc_common", - "swc_config", - "swc_ecma_ast 0.106.6", - "swc_ecma_codegen 0.141.11", - "swc_ecma_ext_transforms 0.105.10", - "swc_ecma_lints 0.84.14", - "swc_ecma_loader", - "swc_ecma_minifier 0.183.21", - "swc_ecma_parser 0.136.8", - "swc_ecma_preset_env 0.197.20", - "swc_ecma_transforms 0.220.19", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_compat 0.155.17", - "swc_ecma_transforms_optimization 0.189.19", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", - "swc_error_reporters", - "swc_node_comments", - "swc_timer", - "swc_visit", - "tracing", - "url", -] - [[package]] name = "swc_atoms" version = "0.5.6" @@ -5656,12 +5488,12 @@ version = "0.214.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a22f0573fef09dffc3db7094d29ef9445b4f09b76da650bc870060ca0b8c8a4" dependencies = [ - "ahash 0.7.6", + "ahash", "anyhow", "crc", "dashmap", "indexmap", - "is-macro 0.2.2", + "is-macro", "once_cell", "parking_lot", "petgraph", @@ -5670,14 +5502,14 @@ dependencies = [ "relative-path", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen 0.139.17", + "swc_ecma_ast", + "swc_ecma_codegen", "swc_ecma_loader", - "swc_ecma_parser 0.134.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_optimization 0.187.24", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_optimization", + "swc_ecma_utils", + "swc_ecma_visit", "swc_fast_graph", "swc_graph_analyzer", "tracing", @@ -5685,11 +5517,11 @@ dependencies = [ [[package]] name = "swc_cached" -version = "0.3.17" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b8051bbf1c23817f9f2912fce18d9a6efcaaf8f8e1a4c69dbaf72bcaf71136" +checksum = "9745d42d167cb60aeb1e85d2ee813ca455c3185bf7417f11fd102d745ae2b9e1" dependencies = [ - "ahash 0.8.3", + "ahash", "anyhow", "dashmap", "once_cell", @@ -5699,11 +5531,11 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.31.16" +version = "0.31.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6414bd4e553f5638961d39b07075ffd37a3d63176829592f4a5900260d94ca1" +checksum = "19c774005489d2907fb67909cf42af926e72edee1366512777c605ba2ef19c94" dependencies = [ - "ahash 0.8.3", + "ahash", "anyhow", "ast_node", "atty", @@ -5733,9 +5565,9 @@ dependencies = [ [[package]] name = "swc_config" -version = "0.1.7" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba1c7a40d38f9dd4e9a046975d3faf95af42937b34b2b963be4d8f01239584b" +checksum = "89c8fc2c12bb1634c7c32fc3c9b6b963ad8f034cc62c4ecddcf215dc4f6f959d" dependencies = [ "indexmap", "serde", @@ -5745,15 +5577,15 @@ dependencies = [ [[package]] name = "swc_config_macro" -version = "0.1.2" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b5aaca9a0082be4515f0fbbecc191bf5829cd25b5b9c0a2810f6a2bb0d6829" +checksum = "7dadb9998d4f5fc36ef558ed5a092579441579ee8c6fcce84a5228cca9df4004" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -5763,7 +5595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05ce227c715f658e5f0367f1c75c908672d76de4dc69646e27f5f62e8380f5de" dependencies = [ "binding_macros", - "swc 0.261.41", + "swc", "swc_atoms", "swc_bundler", "swc_cached", @@ -5776,22 +5608,22 @@ dependencies = [ "swc_css_prefixer", "swc_css_utils", "swc_css_visit", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen 0.139.17", + "swc_ecma_ast", + "swc_ecma_codegen", "swc_ecma_loader", - "swc_ecma_minifier 0.181.31", - "swc_ecma_parser 0.134.12", - "swc_ecma_preset_env 0.195.26", - "swc_ecma_quote_macros 0.45.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_module 0.170.20", - "swc_ecma_transforms_optimization 0.187.24", - "swc_ecma_transforms_proposal 0.161.23", - "swc_ecma_transforms_react 0.173.20", - "swc_ecma_transforms_testing 0.130.18", - "swc_ecma_transforms_typescript 0.177.24", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_preset_env", + "swc_ecma_quote_macros", + "swc_ecma_transforms_base", + "swc_ecma_transforms_module", + "swc_ecma_transforms_optimization", + "swc_ecma_transforms_proposal", + "swc_ecma_transforms_react", + "swc_ecma_transforms_testing", + "swc_ecma_transforms_typescript", + "swc_ecma_utils", + "swc_ecma_visit", "swc_nodejs_common", "swc_plugin_proxy", "swc_plugin_runner", @@ -5800,38 +5632,13 @@ dependencies = [ "vergen", ] -[[package]] -name = "swc_core" -version = "0.78.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9947b392ed7b221b846814f97599d4aee1b8e75fd750f7a772402b59a3d3cec" -dependencies = [ - "swc 0.263.24", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_codegen 0.141.11", - "swc_ecma_parser 0.136.8", - "swc_ecma_preset_env 0.197.20", - "swc_ecma_quote_macros 0.47.8", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_module 0.172.18", - "swc_ecma_transforms_react 0.175.18", - "swc_ecma_transforms_testing 0.132.14", - "swc_ecma_transforms_typescript 0.179.19", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", - "testing", - "vergen", -] - [[package]] name = "swc_css_ast" version = "0.137.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df74aad6d6957b9e9e8b9dde5b4531d0a7f937b79089706bd71f9edcf98e8f34" dependencies = [ - "is-macro 0.2.2", + "is-macro", "serde", "string_enum", "swc_atoms", @@ -5844,8 +5651,8 @@ version = "0.147.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d78b141280c45b9f5686774249f37e7e378105da26420ffbf2c3e89c17844cf" dependencies = [ - "auto_impl 0.5.0", - "bitflags 2.3.2", + "auto_impl", + "bitflags 2.2.1", "rustc-hash", "serde", "swc_atoms", @@ -5861,7 +5668,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01c132d9ba562343f7c49d776c4a09b362a4a4104b7cb0a0f7b785986a492e1b" dependencies = [ - "pmutil 0.5.3", + "pmutil", "proc-macro2", "quote", "swc_macros_common", @@ -5874,7 +5681,7 @@ version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c25d3a2b9059531a42c1af84ff4d2a4367f5f684038ed13583cfc8fcfbc41602" dependencies = [ - "bitflags 2.3.2", + "bitflags 2.2.1", "once_cell", "serde", "serde_json", @@ -5907,7 +5714,7 @@ version = "0.146.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1002e94d2650f470c07ce48bbfc72080163480648766a197fc7b436f10eff10f" dependencies = [ - "bitflags 2.3.2", + "bitflags 2.2.1", "lexical", "serde", "swc_atoms", @@ -5966,9 +5773,9 @@ version = "0.104.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5cf9dd351d0c285dcd36535267953a18995d4dda0cbe34ac9d1df61aa415b26" dependencies = [ - "bitflags 2.3.2", + "bitflags 2.2.1", "bytecheck", - "is-macro 0.2.2", + "is-macro", "num-bigint", "rkyv", "scoped-tls", @@ -5979,23 +5786,6 @@ dependencies = [ "unicode-id", ] -[[package]] -name = "swc_ecma_ast" -version = "0.106.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf4d6804b1da4146c4c0359d129e3dd43568d321f69d7953d9abbca4ded76ba" -dependencies = [ - "bitflags 2.3.2", - "is-macro 0.3.0", - "num-bigint", - "scoped-tls", - "serde", - "string_enum", - "swc_atoms", - "swc_common", - "unicode-id", -] - [[package]] name = "swc_ecma_codegen" version = "0.139.17" @@ -6010,41 +5800,22 @@ dependencies = [ "sourcemap", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen_macros", - "tracing", -] - -[[package]] -name = "swc_ecma_codegen" -version = "0.141.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3845e22d8593a617b973b5f65f3567170b41eb964a70a267b1ec4995dfe5013" -dependencies = [ - "memchr", - "num-bigint", - "once_cell", - "rustc-hash", - "serde", - "sourcemap", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", + "swc_ecma_ast", "swc_ecma_codegen_macros", "tracing", ] [[package]] name = "swc_ecma_codegen_macros" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcdff076dccca6cc6a0e0b2a2c8acfb066014382bc6df98ec99e755484814384" +checksum = "bf4ee0caee1018808d94ecd09490cb7affd3d504b19aa11c49238f5fc4b54901" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -6056,23 +5827,9 @@ dependencies = [ "phf", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_ext_transforms" -version = "0.105.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3ae43df15bac02f1cded6754041da244a21688fd39cf876984f78b8856c76c" -dependencies = [ - "phf", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6081,29 +5838,8 @@ version = "0.82.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48d5b6aadff572b212ceadba56da45a6bb9af7d67ce1c234a27073d4ec4e6361" dependencies = [ - "ahash 0.7.6", - "auto_impl 0.5.0", - "dashmap", - "parking_lot", - "rayon", - "regex", - "serde", - "swc_atoms", - "swc_common", - "swc_config", - "swc_ecma_ast 0.104.5", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_lints" -version = "0.84.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300cc5f51b8a3cc81758fdc34192552a97dff46716f9e1d7d6bf73ee922f3431" -dependencies = [ - "ahash 0.8.3", - "auto_impl 1.1.0", + "ahash", + "auto_impl", "dashmap", "parking_lot", "rayon", @@ -6112,21 +5848,21 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast 0.106.6", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] name = "swc_ecma_loader" -version = "0.43.18" +version = "0.43.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d40f8d1626b33ba85ee17f43268b3bb6382278b9d3a3c1faa52c57e71769a60" +checksum = "fe45f1e5dcc1b005544ff78253b787dea5dfd5e2f712b133964cdc3545c954a4" dependencies = [ - "ahash 0.8.3", + "ahash", "anyhow", "dashmap", - "lru 0.10.0", + "lru", "normpath", "once_cell", "parking_lot", @@ -6145,7 +5881,7 @@ version = "0.181.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f85eb56b6c5a8ba4e91141602511b9c5a390bad4c8e454bff77d80c2033c265" dependencies = [ - "ahash 0.7.6", + "ahash", "arrayvec", "indexmap", "num-bigint", @@ -6163,49 +5899,14 @@ dependencies = [ "swc_cached", "swc_common", "swc_config", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen 0.139.17", - "swc_ecma_parser 0.134.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_optimization 0.187.24", - "swc_ecma_usage_analyzer 0.13.16", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "swc_timer", - "tracing", -] - -[[package]] -name = "swc_ecma_minifier" -version = "0.183.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "befc43e839f60e0cf38df7f70d39dd79922028efbaf738b511fb5c137fb574b1" -dependencies = [ - "ahash 0.8.3", - "arrayvec", - "indexmap", - "num-bigint", - "num_cpus", - "once_cell", - "parking_lot", - "radix_fmt", - "regex", - "rustc-hash", - "ryu-js", - "serde", - "serde_json", - "swc_atoms", - "swc_cached", - "swc_common", - "swc_config", - "swc_ecma_ast 0.106.6", - "swc_ecma_codegen 0.141.11", - "swc_ecma_parser 0.136.8", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_optimization 0.189.19", - "swc_ecma_usage_analyzer 0.15.11", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_optimization", + "swc_ecma_usage_analyzer", + "swc_ecma_utils", + "swc_ecma_visit", "swc_timer", "tracing", ] @@ -6225,27 +5926,7 @@ dependencies = [ "stacker", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "tracing", - "typed-arena", -] - -[[package]] -name = "swc_ecma_parser" -version = "0.136.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d40421c607d7a48334f78a9b24a5cbde1f36250f9986746ec082208d68b39f" -dependencies = [ - "either", - "lexical", - "num-bigint", - "serde", - "smallvec", - "smartstring", - "stacker", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", + "swc_ecma_ast", "tracing", "typed-arena", ] @@ -6256,32 +5937,7 @@ version = "0.195.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384802032a00bc0e67993e7c3c9a28b82af19c5685eb9d8f93655376f3f823c2" dependencies = [ - "ahash 0.7.6", - "anyhow", - "dashmap", - "indexmap", - "once_cell", - "preset_env_base", - "semver 1.0.17", - "serde", - "serde_json", - "st-map 0.1.8", - "string_enum", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms 0.218.24", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_preset_env" -version = "0.197.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c4d926e3772345fd2abe5058915f21250e145f9c312462a98ad5201e687f7a" -dependencies = [ - "ahash 0.8.3", + "ahash", "anyhow", "dashmap", "indexmap", @@ -6290,14 +5946,14 @@ dependencies = [ "semver 1.0.17", "serde", "serde_json", - "st-map 0.2.0", + "st-map", "string_enum", "swc_atoms", "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms 0.220.19", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_transforms", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6307,45 +5963,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eff371cf036e2c5fb7bf404f7c1a30a22ee4b64d04fb9354a9b057cbd4d59c9b" dependencies = [ "anyhow", - "pmutil 0.5.3", + "pmutil", "proc-macro2", "quote", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_parser 0.134.12", + "swc_ecma_ast", + "swc_ecma_parser", "swc_macros_common", "syn 1.0.109", ] -[[package]] -name = "swc_ecma_quote_macros" -version = "0.47.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f583b2bd7fb8d3def4313912008111044bbd16cd9a10ee9c009d69eaa8e558ba" -dependencies = [ - "anyhow", - "pmutil 0.6.1", - "proc-macro2", - "quote", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_parser 0.136.8", - "swc_macros_common", - "syn 2.0.18", -] - [[package]] name = "swc_ecma_testing" -version = "0.20.13" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90ea04390a92f949fbf2d3c411bc7ab82c0981dea04cc18fe6ae1a4e471f121" +checksum = "25198f96ef93c4bb4cc8fa13c9b22a018cf2c0c7609ee91f7abc7968ebc2e2df" dependencies = [ "anyhow", "hex", "sha-1", - "testing", "tracing", ] @@ -6357,36 +5994,16 @@ checksum = "dbe5ca1c16b4ea9ece9f43a24554edce402641c46b2cc4e418be6c40897572b0" dependencies = [ "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_compat 0.153.20", - "swc_ecma_transforms_module 0.170.20", - "swc_ecma_transforms_optimization 0.187.24", - "swc_ecma_transforms_proposal 0.161.23", - "swc_ecma_transforms_react 0.173.20", - "swc_ecma_transforms_typescript 0.177.24", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_transforms" -version = "0.220.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cfb7ec24e83d284b33b30e2b343262078fdb8382b5340858426b12b6aab8d21" -dependencies = [ - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_compat 0.155.17", - "swc_ecma_transforms_module 0.172.18", - "swc_ecma_transforms_optimization 0.189.19", - "swc_ecma_transforms_proposal 0.163.17", - "swc_ecma_transforms_react 0.175.18", - "swc_ecma_transforms_typescript 0.179.19", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_compat", + "swc_ecma_transforms_module", + "swc_ecma_transforms_optimization", + "swc_ecma_transforms_proposal", + "swc_ecma_transforms_react", + "swc_ecma_transforms_typescript", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6396,7 +6013,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9c33ec5369178f3a0580ab86cfe89ffb9c3fbd122aed379cfb71d469d9d61c1" dependencies = [ "better_scoped_tls", - "bitflags 2.3.2", + "bitflags 2.2.1", "indexmap", "once_cell", "phf", @@ -6406,33 +6023,10 @@ dependencies = [ "smallvec", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_parser 0.134.12", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "tracing", -] - -[[package]] -name = "swc_ecma_transforms_base" -version = "0.129.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef3d6800cc1500dfb6983cefac6c6dbf0ea8b2af8dcb1d2e25cae01226479744" -dependencies = [ - "better_scoped_tls", - "bitflags 2.3.2", - "indexmap", - "once_cell", - "phf", - "rustc-hash", - "serde", - "smallvec", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_parser 0.136.8", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", "tracing", ] @@ -6444,24 +6038,10 @@ checksum = "6e3b0d5f362f0da97be1f1b06d7b0d8667ea70b4adeabff0dcaecb6259c09525" dependencies = [ "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_transforms_classes" -version = "0.118.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd5380415af454bcc6dc9de726064186adc65e6be20eb9c9eb49b0b6d518e361" -dependencies = [ - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6470,10 +6050,10 @@ version = "0.153.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "851739faeec27389fbfe5b170534df7868bbcc5c78f229f22fce43f004858eca" dependencies = [ - "ahash 0.7.6", + "ahash", "arrayvec", "indexmap", - "is-macro 0.2.2", + "is-macro", "num-bigint", "rayon", "serde", @@ -6481,53 +6061,27 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_classes 0.116.18", - "swc_ecma_transforms_macros", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "swc_trace_macro", - "tracing", -] - -[[package]] -name = "swc_ecma_transforms_compat" -version = "0.155.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900373ed4e2ce81d58152b781f5fe37e0b5ba1989805e8a60d97981c4d189a22" -dependencies = [ - "ahash 0.8.3", - "arrayvec", - "indexmap", - "is-macro 0.3.0", - "num-bigint", - "serde", - "smallvec", - "swc_atoms", - "swc_common", - "swc_config", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_classes 0.118.14", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", "swc_ecma_transforms_macros", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_utils", + "swc_ecma_visit", "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_transforms_macros" -version = "0.5.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59c4b6ed5d78d3ad9fc7c6f8ab4f85bba99573d31d9a2c0a712077a6b45efd2" +checksum = "984d5ac69b681fc5438f9abf82b0fda34fe04e119bc75f8213b7e01128c7c9a2" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -6537,11 +6091,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1595b0522333346488ad7354ad55d4ed337d4e5d7ded5e4d468c523ecb9a495" dependencies = [ "Inflector", - "ahash 0.7.6", + "ahash", "anyhow", - "bitflags 2.3.2", + "bitflags 2.2.1", "indexmap", - "is-macro 0.2.2", + "is-macro", "path-clean", "pathdiff", "regex", @@ -6549,40 +6103,12 @@ dependencies = [ "swc_atoms", "swc_cached", "swc_common", - "swc_ecma_ast 0.104.5", + "swc_ecma_ast", "swc_ecma_loader", - "swc_ecma_parser 0.134.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "tracing", -] - -[[package]] -name = "swc_ecma_transforms_module" -version = "0.172.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c98365d03820a51eacba68cd703460f1c36b09ed81cd99cb93d1088f92dc35" -dependencies = [ - "Inflector", - "ahash 0.8.3", - "anyhow", - "bitflags 2.3.2", - "indexmap", - "is-macro 0.3.0", - "path-clean", - "pathdiff", - "regex", - "serde", - "swc_atoms", - "swc_cached", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_loader", - "swc_ecma_parser 0.136.8", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", "tracing", ] @@ -6592,7 +6118,7 @@ version = "0.187.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fff2641ba155b3aaa8ef15c1888d75b73e9f10431ec1cb58e66598266199322" dependencies = [ - "ahash 0.7.6", + "ahash", "dashmap", "indexmap", "once_cell", @@ -6602,37 +6128,12 @@ dependencies = [ "serde_json", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_parser 0.134.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_macros", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "swc_fast_graph", - "tracing", -] - -[[package]] -name = "swc_ecma_transforms_optimization" -version = "0.189.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89756d0ace7efd6acd7223e19e19d789765f95112f247436b7ab42ac9cfae68b" -dependencies = [ - "ahash 0.8.3", - "dashmap", - "indexmap", - "once_cell", - "petgraph", - "rustc-hash", - "serde_json", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_parser 0.136.8", - "swc_ecma_transforms_base 0.129.14", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", "swc_ecma_transforms_macros", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_utils", + "swc_ecma_visit", "swc_fast_graph", "tracing", ] @@ -6649,32 +6150,12 @@ dependencies = [ "smallvec", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_classes 0.116.18", - "swc_ecma_transforms_macros", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_transforms_proposal" -version = "0.163.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6492a52ff1a98f36a12155f865db58bbfcae5fca77e76545cccd5ebcc77bd780" -dependencies = [ - "either", - "rustc-hash", - "serde", - "smallvec", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_classes 0.118.14", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", "swc_ecma_transforms_macros", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6683,7 +6164,7 @@ version = "0.173.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fb9481ad4e2acba34c6fbb6d4ccc64efe9f1821675e883dcfa732d7220f4b1e" dependencies = [ - "ahash 0.7.6", + "ahash", "base64 0.13.1", "dashmap", "indexmap", @@ -6695,37 +6176,12 @@ dependencies = [ "swc_atoms", "swc_common", "swc_config", - "swc_ecma_ast 0.104.5", - "swc_ecma_parser 0.134.12", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_macros", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_transforms_react" -version = "0.175.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67bc38b58cb66cbfd1ad9440073289a3d827b8b1fd2831126f1a3bfae99ec430" -dependencies = [ - "ahash 0.8.3", - "base64 0.13.1", - "dashmap", - "indexmap", - "once_cell", - "serde", - "sha-1", - "string_enum", - "swc_atoms", - "swc_common", - "swc_config", - "swc_ecma_ast 0.106.6", - "swc_ecma_parser 0.136.8", - "swc_ecma_transforms_base 0.129.14", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", "swc_ecma_transforms_macros", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6743,39 +6199,13 @@ dependencies = [ "sha-1", "sourcemap", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_codegen 0.139.17", - "swc_ecma_parser 0.134.12", - "swc_ecma_testing", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "tempfile", - "testing", -] - -[[package]] -name = "swc_ecma_transforms_testing" -version = "0.132.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857ed24bc19b38c311c6e479685d00d32052babc8a25db4cef26f0aa28c2b5d8" -dependencies = [ - "ansi_term", - "anyhow", - "base64 0.13.1", - "hex", - "serde", - "serde_json", - "sha-1", - "sourcemap", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_codegen 0.141.11", - "swc_ecma_parser 0.136.8", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", "swc_ecma_testing", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", "tempfile", "testing", ] @@ -6789,27 +6219,11 @@ dependencies = [ "serde", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_transforms_base 0.127.18", - "swc_ecma_transforms_react 0.173.20", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", -] - -[[package]] -name = "swc_ecma_transforms_typescript" -version = "0.179.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e235c8b8fdac92de7255b40912077680106ff89de5d8595415d516f389fb9d0" -dependencies = [ - "serde", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_transforms_base 0.129.14", - "swc_ecma_transforms_react 0.175.18", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_react", + "swc_ecma_utils", + "swc_ecma_visit", ] [[package]] @@ -6818,32 +6232,14 @@ version = "0.13.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7da59ebce19380671e76cfe7e9b0cdd6f430b3090c65c24aefcc07ed63739f2" dependencies = [ - "ahash 0.7.6", + "ahash", "indexmap", "rustc-hash", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_utils 0.117.13", - "swc_ecma_visit 0.90.5", - "swc_timer", - "tracing", -] - -[[package]] -name = "swc_ecma_usage_analyzer" -version = "0.15.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce1112dc11f631433c8794b1a46908d146f82af347a1a1aa434291f9f5bcbbac" -dependencies = [ - "ahash 0.8.3", - "indexmap", - "rustc-hash", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_utils 0.119.10", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", "swc_timer", "tracing", ] @@ -6861,26 +6257,8 @@ dependencies = [ "rustc-hash", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_ecma_visit 0.90.5", - "tracing", - "unicode-id", -] - -[[package]] -name = "swc_ecma_utils" -version = "0.119.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "452c66399edeb88a97bfdc3bbf11e45db85fdf883bfd4fc8bdd93abb92152b9b" -dependencies = [ - "indexmap", - "num_cpus", - "once_cell", - "rustc-hash", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", - "swc_ecma_visit 0.92.5", + "swc_ecma_ast", + "swc_ecma_visit", "tracing", "unicode-id", ] @@ -6894,21 +6272,7 @@ dependencies = [ "num-bigint", "swc_atoms", "swc_common", - "swc_ecma_ast 0.104.5", - "swc_visit", - "tracing", -] - -[[package]] -name = "swc_ecma_visit" -version = "0.92.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f61da6cac0ec3b7e62d367cfbd9e38e078a4601271891ad94f0dac5ff69f839" -dependencies = [ - "num-bigint", - "swc_atoms", - "swc_common", - "swc_ecma_ast 0.106.6", + "swc_ecma_ast", "swc_visit", "tracing", ] @@ -6927,27 +6291,27 @@ dependencies = [ "regex", "serde", "sourcemap", - "swc_core 0.76.48", + "swc_core", "tracing", ] [[package]] name = "swc_eq_ignore_macros" -version = "0.1.2" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a95d367e228d52484c53336991fdcf47b6b553ef835d9159db4ba40efb0ee8" +checksum = "0c20468634668c2bbab581947bb8c75c97158d5a6959f4ba33df20983b20b4f6" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] name = "swc_error_reporters" -version = "0.15.16" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "108322b719696e8c368c39dc6d8748494ea2aa870e7d80ea5956078aa6b4dd4d" +checksum = "4e4ce9ba211e75848f6aff1c64ee16c71006bd93e45a37f4e149c22625f26d8c" dependencies = [ "anyhow", "miette", @@ -6958,9 +6322,9 @@ dependencies = [ [[package]] name = "swc_fast_graph" -version = "0.19.16" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19b76468219b923c34efdeff812fa951fe1a1ecaba78118b013d034a1669ff5" +checksum = "6291149aec4ba55076fd54a12ceb84cac1f703b2f571c3b2f19aa66ab9ec3009" dependencies = [ "indexmap", "petgraph", @@ -6974,8 +6338,8 @@ version = "0.20.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6575adec8b200801d429ffa79166224a6e298292a1b307750f4763aec5aa16c3" dependencies = [ - "ahash 0.7.6", - "auto_impl 0.5.0", + "ahash", + "auto_impl", "petgraph", "swc_fast_graph", "tracing", @@ -6983,23 +6347,23 @@ dependencies = [ [[package]] name = "swc_macros_common" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a273205ccb09b51fabe88c49f3b34c5a4631c4c00a16ae20e03111d6a42e832" +checksum = "3e582c3e3c2269238524923781df5be49e011dbe29cf7683a2215d600a562ea6" dependencies = [ - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] name = "swc_node_comments" -version = "0.18.16" +version = "0.18.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61839f8a936b5c95ce644d539914bb944b094eee9bd156c3dc41fe8e7eaa84ea" +checksum = "800d308508c0517a04f115c769cf398c23a62bcb8bfa186b7d15c42861b7448a" dependencies = [ - "ahash 0.8.3", + "ahash", "dashmap", "swc_atoms", "swc_common", @@ -7028,7 +6392,7 @@ dependencies = [ "better_scoped_tls", "rkyv", "swc_common", - "swc_ecma_ast 0.104.5", + "swc_ecma_ast", "swc_trace_macro", "tracing", ] @@ -7046,7 +6410,7 @@ dependencies = [ "serde", "serde_json", "swc_common", - "swc_ecma_ast 0.104.5", + "swc_ecma_ast", "swc_plugin_proxy", "tokio", "tracing", @@ -7067,35 +6431,35 @@ dependencies = [ "serde", "serde_json", "swc_common", - "swc_core 0.76.48", + "swc_core", "tracing", ] [[package]] name = "swc_timer" -version = "0.19.19" +version = "0.19.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9889bf48909289e13e0f343eb8d1238e674e9380a4dd6c6346f62b83cb30236f" +checksum = "d0dd693178fc91bfac6f380f312f9adcb2dbe753e439ecf929289dfe7a30a893" dependencies = [ "tracing", ] [[package]] name = "swc_trace_macro" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff9719b6085dd2824fd61938a881937be14b08f95e2d27c64c825a9f65e052ba" +checksum = "a4795c8d23e0de62eef9cac0a20ae52429ee2ffc719768e838490f195b7d7267" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] name = "swc_visit" -version = "0.5.7" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c337fbb2d191bf371173dea6a957f01899adb8f189c6c31b122a6cfc98fc3" +checksum = "5f412dd4fbc58f509a04e64f5c8038333142fc139e8232f01b883db0094b3b51" dependencies = [ "either", "swc_visit_macros", @@ -7103,16 +6467,16 @@ dependencies = [ [[package]] name = "swc_visit_macros" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f322730fb82f3930a450ac24de8c98523af7d34ab8cb2f46bcb405839891a99" +checksum = "4cfc226380ba54a5feed2c12f3ccd33f1ae8e959160290e5d2d9b4e918b6472a" dependencies = [ "Inflector", - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -7177,16 +6541,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.6.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ - "autocfg", "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.45.0", ] [[package]] @@ -7229,12 +6592,11 @@ dependencies = [ [[package]] name = "testing" -version = "0.33.19" +version = "0.33.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "359d2548f4919624af6cd1001e0a3ac9f081f8312e47fdca7650c11c9935981b" +checksum = "0901b02da634d6e420bc20716d86c2ee679ee852e126b23b6a478d6c83361956" dependencies = [ "ansi_term", - "cargo_metadata", "difference", "once_cell", "pretty_assertions", @@ -7249,19 +6611,19 @@ dependencies = [ [[package]] name = "testing_macros" -version = "0.2.11" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c15b796025051a07f1ac695ee0cac0883f05a0d510c9d171ef8d31a992e6a5" +checksum = "a5315a85a7262fe1a8898890b616de62c152dd43cb5974752c0927aaabe48891" dependencies = [ "anyhow", "glob", "once_cell", - "pmutil 0.6.1", + "pmutil", "proc-macro2", "quote", "regex", "relative-path", - "syn 2.0.18", + "syn 1.0.109", ] [[package]] @@ -8008,7 +7370,7 @@ dependencies = [ "node-file-trace", "styled_components", "styled_jsx", - "swc_core 0.76.48", + "swc_core", "swc_emotion", "swc_relay", "testing", @@ -8102,7 +7464,7 @@ dependencies = [ "serde_json", "serde_qs", "sourcemap", - "swc_core 0.76.48", + "swc_core", "tracing", "turbo-tasks", "turbo-tasks-build", @@ -8136,7 +7498,7 @@ dependencies = [ "once_cell", "regex", "serde", - "swc_core 0.76.48", + "swc_core", "turbo-tasks", "turbo-tasks-build", "turbo-tasks-fs", @@ -8157,7 +7519,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "swc_core 0.76.48", + "swc_core", "tracing", "turbo-tasks", "turbo-tasks-build", @@ -8226,7 +7588,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "swc_core 0.76.48", + "swc_core", "tokio", "tracing", "turbo-tasks", @@ -8251,7 +7613,7 @@ dependencies = [ "serde_json", "styled_components", "styled_jsx", - "swc_core 0.76.48", + "swc_core", "swc_emotion", "swc_relay", "turbo-tasks", @@ -8269,7 +7631,7 @@ dependencies = [ "anyhow", "indoc", "serde", - "swc_core 0.76.48", + "swc_core", "turbo-tasks", "turbo-tasks-build", "turbo-tasks-fs", @@ -8400,7 +7762,7 @@ name = "turbopack-swc-utils" version = "0.1.0" source = "git+https://github.com/vercel/turbo.git?tag=turbopack-230622.2#08aba99a2796b37324cabf18b6ea9eff886d93b4" dependencies = [ - "swc_core 0.76.48", + "swc_core", "turbo-tasks", "turbo-tasks-build", "turbopack-core", @@ -8427,7 +7789,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "rand 0.8.5", "static_assertions", ] @@ -8510,7 +7872,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" dependencies = [ - "hashbrown 0.12.3", + "hashbrown", "regex", ] @@ -8555,9 +7917,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", "idna", @@ -8819,7 +8181,7 @@ dependencies = [ "serde", "serde-wasm-bindgen", "serde_json", - "swc_core 0.78.24", + "swc_core", "tracing", "turbopack-binding", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 1441f3e75ed6..40e3989b9b62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-tran # SWC crates # Keep consistent with preset_env_base through swc_core -swc_core = { version = "0.78.24" } -testing = { version = "0.33.19" } +swc_core = { version = "0.76.46" } +testing = { version = "0.33.13" } # Turbo crates turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230622.2" } From e7b9b9a8161c88b85942be70a5218f2a554595d9 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Wed, 28 Jun 2023 21:17:41 +0200 Subject: [PATCH 16/30] Update codeowners (#51935) revert to the previous version of codeowners before vercel spaces is applied --- .github/CODEOWNERS | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ad71ad89226c..f7ef8d310ca7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,13 +1,35 @@ # Learn how to add code owners here: # https://help.github.com/en/articles/about-code-owners -# Codeowners now use Vercel Spaces -# Search .vercel.approvers for all files * @timneutkens @ijjk @shuding @huozhi @feedthejim +/.git* @vercel/next-js +/docs/ @vercel/next-js @leerob +/errors/ @vercel/next-js @leerob +/examples/ @vercel/next-js @leerob @steven-tey +/scripts/ @vercel/next-js +/.alex* @vercel/next-js @leerob +/.eslint* @vercel/next-js @leerob +/.prettier* @vercel/next-js @leerob +/*.md @vercel/next-js @leerob +/packages/create-next-app/ @vercel/next-js +/pnpm-lock.yaml @vercel/next-js @vercel/web-tooling # Image Component (@styfle) /**/*image* @timneutkens @ijjk @shuding @styfle @huozhi @vercel/devex /**/*image*/** @timneutkens @ijjk @shuding @styfle @huozhi @vercel/devex +/packages/next/client/use-intersection.tsx @timneutkens @ijjk @shuding @styfle +/packages/next/server/lib/squoosh/ @timneutkens @ijjk @shuding @styfle +/packages/next/server/serve-static.ts @timneutkens @ijjk @shuding @styfle @huozhi +/packages/next/server/config.ts @timneutkens @ijjk @shuding @styfle @huozhi +# Tooling & Telemetry + +/packages/next/src/build/ @timneutkens @ijjk @shuding @huozhi @vercel/web-tooling +/packages/next/src/telemetry/ @timneutkens @ijjk @shuding @padmaia +/packages/next-swc/ @timneutkens @ijjk @shuding @vercel/web-tooling +Cargo.toml @timneutkens @ijjk @shuding @vercel/web-tooling +Cargo.lock @timneutkens @ijjk @shuding @vercel/web-tooling +/.cargo/config.toml @timneutkens @ijjk @shuding @vercel/web-tooling +/.config/nextest.toml @timneutkens @ijjk @shuding @vercel/web-tooling \ No newline at end of file From d206c68ad715595aea211376342b48330af3af5e Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Wed, 28 Jun 2023 16:03:08 -0400 Subject: [PATCH 17/30] adds payload to server-external-packages.json (#51933) ### What? Adds `payload` to the external package list ### Why? To prevent developers using [Payload](https://github.com/payloadcms/payload) modules within Next.js from having to add this in their next config. --- .../05-next-config-js/serverComponentsExternalPackages.mdx | 1 + packages/next/src/lib/server-external-packages.json | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/02-app/02-api-reference/05-next-config-js/serverComponentsExternalPackages.mdx b/docs/02-app/02-api-reference/05-next-config-js/serverComponentsExternalPackages.mdx index 709c962afa01..2f5835e5d2b2 100644 --- a/docs/02-app/02-api-reference/05-next-config-js/serverComponentsExternalPackages.mdx +++ b/docs/02-app/02-api-reference/05-next-config-js/serverComponentsExternalPackages.mdx @@ -35,6 +35,7 @@ Next.js includes a [short list of popular packages](https://github.com/vercel/ne - `mongodb` - `next-mdx-remote` - `next-seo` +- `payload` - `postcss` - `prettier` - `prisma` diff --git a/packages/next/src/lib/server-external-packages.json b/packages/next/src/lib/server-external-packages.json index 7ed606365109..2bd2cae212f1 100644 --- a/packages/next/src/lib/server-external-packages.json +++ b/packages/next/src/lib/server-external-packages.json @@ -25,6 +25,7 @@ "mongoose", "next-mdx-remote", "next-seo", + "payload", "pg", "playwright", "postcss", From 0bd9b4bbdff3c38bfa9c59d0c1e99d7003c94f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Wed, 28 Jun 2023 15:40:35 -0700 Subject: [PATCH 18/30] fix(next): improve error for using outside of document (#45056) ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added -> this is a pretty niche edge case, do you want me to? - [x] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) Fixes #45024 Co-authored-by: JJ Kasper --- packages/next/src/pages/_document.tsx | 12 ++++++------ packages/next/src/shared/lib/html-context.ts | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/next/src/pages/_document.tsx b/packages/next/src/pages/_document.tsx index 48a845299b10..5f61547a0036 100644 --- a/packages/next/src/pages/_document.tsx +++ b/packages/next/src/pages/_document.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, ReactNode, useContext } from 'react' +import React, { ReactElement, ReactNode } from 'react' import { OPTIMIZED_FONT_PROVIDERS, NEXT_BUILTIN_DOCUMENT, @@ -17,7 +17,7 @@ import { BuildManifest, getPageFiles } from '../server/get-page-files' import { htmlEscapeJsonString } from '../server/htmlescape' import isError from '../lib/is-error' -import { HtmlContext } from '../shared/lib/html-context' +import { HtmlContext, useHtmlContext } from '../shared/lib/html-context' import type { HtmlProps } from '../shared/lib/html-context' export { DocumentContext, DocumentInitialProps, DocumentProps } @@ -424,7 +424,7 @@ function getNextFontLinkTags( export class Head extends React.Component { static contextType = HtmlContext - context!: React.ContextType + context!: HtmlProps getCssLinks(files: DocumentFiles): JSX.Element[] | null { const { @@ -995,7 +995,7 @@ function handleDocumentScriptLoaderItems( export class NextScript extends React.Component { static contextType = HtmlContext - context!: React.ContextType + context!: HtmlProps getDynamicChunks(files: DocumentFiles) { return getDynamicChunks(this.context, this.props, files) @@ -1174,7 +1174,7 @@ export function Html( locale, scriptLoader, __NEXT_DATA__, - } = useContext(HtmlContext) + } = useHtmlContext() docComponentsRendered.Html = true handleDocumentScriptLoaderItems(scriptLoader, __NEXT_DATA__, props) @@ -1196,7 +1196,7 @@ export function Html( } export function Main() { - const { docComponentsRendered } = useContext(HtmlContext) + const { docComponentsRendered } = useHtmlContext() docComponentsRendered.Main = true // @ts-ignore return diff --git a/packages/next/src/shared/lib/html-context.ts b/packages/next/src/shared/lib/html-context.ts index 064110d70175..33b2dce0f06b 100644 --- a/packages/next/src/shared/lib/html-context.ts +++ b/packages/next/src/shared/lib/html-context.ts @@ -4,7 +4,7 @@ import type { NEXT_DATA } from './utils' import type { FontConfig } from '../../server/font-utils' import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin' -import { createContext } from 'react' +import { createContext, useContext } from 'react' export type HtmlProps = { __NEXT_DATA__: NEXT_DATA @@ -48,7 +48,20 @@ export type HtmlProps = { nextFontManifest?: NextFontManifest } -export const HtmlContext = createContext(null as any) +export const HtmlContext = createContext(undefined) if (process.env.NODE_ENV !== 'production') { HtmlContext.displayName = 'HtmlContext' } + +export function useHtmlContext() { + const context = useContext(HtmlContext) + + if (!context) { + throw new Error( + ` should not be imported outside of pages/_document.\n` + + 'Read more: https://nextjs.org/docs/messages/no-document-import-in-page' + ) + } + + return context +} From d390d75e1ff6c741ebf21f30f339eb58030be789 Mon Sep 17 00:00:00 2001 From: VelociRaptor <77036902+zignis@users.noreply.github.com> Date: Thu, 29 Jun 2023 04:31:24 +0530 Subject: [PATCH 19/30] [docs] fix angle bracket in mdx (#51920) --- .../01-building-your-application/06-configuring/05-mdx.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx index d1158a6ab633..7c244e4b54fb 100644 --- a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx @@ -366,7 +366,7 @@ async function main() { .use(rehypeStringify) // Convert AST into serialized HTML .process('Hello, Next.js!') - console.log(String(file)) //

>Hello, Next.js!

+ console.log(String(file)) //

Hello, Next.js!

} ``` From 73491308b4ef0303e93cf0d69a0b0c2d030bd293 Mon Sep 17 00:00:00 2001 From: Christian Ivicevic Date: Thu, 29 Jun 2023 01:07:15 +0200 Subject: [PATCH 20/30] [docs] Replace the term "hole" with "slot" (#51919) It feels more natural to use the actual term "slot" when describing how to interweave server and client components since it's used in other frameworks as well. Co-authored-by: JJ Kasper --- docs/01-getting-started/03-react-essentials.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/01-getting-started/03-react-essentials.mdx b/docs/01-getting-started/03-react-essentials.mdx index 9c1fc4fb35ae..77eb9056a8ea 100644 --- a/docs/01-getting-started/03-react-essentials.mdx +++ b/docs/01-getting-started/03-react-essentials.mdx @@ -242,11 +242,11 @@ export default function ExampleClientComponent({ children }) { #### Recommended Pattern: Passing Server Components to Client Components as Props -Instead, when designing Client Components you can use React props to mark _"holes"_ for Server Components. +Instead, when designing Client Components you can use React props to mark _"slots"_ for Server Components. -The Server Component will be rendered on the server, and when the Client Component is rendered on the client, the _"hole"_ will be filled in with the rendered result of the Server Component. +The Server Component will be rendered on the server, and when the Client Component is rendered on the client, the _"slot"_ will be filled in with the rendered result of the Server Component. -A common pattern is to use the React `children` prop to create the _"hole"_. We can refactor `` to accept a generic `children` prop and move the import and explicit nesting of `` up to a parent component. +A common pattern is to use the React `children` prop to create the _"slot"_. We can refactor `` to accept a generic `children` prop and move the import and explicit nesting of `` up to a parent component. ```tsx filename="app/example-client-component.tsx" switcher highlight={6,16} 'use client' From 64c297f194cf0d90272804d4f53a9cf3fcfa38d5 Mon Sep 17 00:00:00 2001 From: VelociRaptor <77036902+zignis@users.noreply.github.com> Date: Thu, 29 Jun 2023 04:49:49 +0530 Subject: [PATCH 21/30] [docs] fix curly brackets in mdx (#51916) Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com> --- .../06-configuring/05-mdx.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx index 7c244e4b54fb..64f130628883 100644 --- a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx @@ -314,13 +314,17 @@ const withMDX = require('@next/mdx')({ Then setup the provider in your page ```jsx filename="pages/index.js" - import { MDXProvider } from '@mdx-js/react' import Image from 'next/image' import { Heading, InlineCode, Pre, Table, Text } from 'my-components' const ResponsiveImage = (props) => ( - {props.alt} + {props.alt} ) const components = { From 1f19a5b810c65279e94e9aea73319e8f06c30be1 Mon Sep 17 00:00:00 2001 From: Tyler Lutz <66930763+tyler-lutz@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:37:56 -0500 Subject: [PATCH 22/30] Add separate links in shared documentation (#51733) ### What? - Added separate links for the app and pages router in the shared documentation. - Added comment at the top of all shared documentation. - Fixed typos in pages documentation comment. ### Why? - To limit the switching between the different routers in shared documentation when clicking the links. --- .../01-routing/11-middleware.mdx | 15 ++++++++ .../02-edge-and-nodejs-runtimes.mdx | 2 + .../04-styling/01-css-modules.mdx | 2 + .../04-styling/02-tailwind-css.mdx | 2 + .../04-styling/03-css-in-js.mdx | 2 + .../04-styling/04-sass.mdx | 2 + .../04-styling/index.mdx | 2 + .../05-optimizing/01-images.mdx | 2 + .../05-optimizing/02-fonts.mdx | 2 + .../05-optimizing/03-scripts.mdx | 2 + .../05-optimizing/05-static-assets.mdx | 2 + .../05-optimizing/06-lazy-loading.mdx | 2 + .../05-optimizing/07-analytics.mdx | 2 + .../05-optimizing/08-open-telemetry.mdx | 26 +++++++++++++ .../05-optimizing/09-instrumentation.mdx | 17 +++++++++ .../05-optimizing/index.mdx | 2 + .../06-configuring/01-typescript.mdx | 13 +++++++ .../06-configuring/02-eslint.mdx | 26 ++++++++++++- .../03-environment-variables.mdx | 4 ++ ...04-absolute-imports-and-module-aliases.mdx | 2 + .../06-configuring/05-mdx.mdx | 2 + .../06-configuring/06-src-directory.mdx | 2 + .../06-configuring/11-draft-mode.mdx | 2 +- .../06-configuring/index.mdx | 2 + .../07-deploying/01-static-exports.mdx | 2 + .../07-deploying/index.mdx | 2 + .../08-upgrading/01-codemods.mdx | 10 +++++ .../01-building-your-application/index.mdx | 2 + .../02-api-reference/01-components/font.mdx | 2 + .../02-api-reference/01-components/image.mdx | 2 + .../02-api-reference/01-components/index.mdx | 2 + .../02-api-reference/01-components/link.mdx | 12 ++++++ .../02-api-reference/01-components/script.mdx | 2 + .../02-api-reference/04-functions/index.mdx | 2 + .../04-functions/revalidatePath.mdx | 14 +++++++ .../04-functions/revalidateTag.mdx | 12 ++++++ .../04-functions/use-report-web-vitals.mdx | 2 + .../04-functions/use-router.mdx | 2 +- .../05-next-config-js/appDir.mdx | 2 +- .../05-next-config-js/assetPrefix.mdx | 23 ++++++++++++ .../05-next-config-js/basePath.mdx | 12 ++++++ .../05-next-config-js/compress.mdx | 2 + .../05-next-config-js/devIndicators.mdx | 2 + .../05-next-config-js/distDir.mdx | 2 + .../05-next-config-js/env.mdx | 22 +++++++++++ .../05-next-config-js/eslint.mdx | 2 + .../05-next-config-js/exportPathMap.mdx | 12 ++++++ .../05-next-config-js/generateBuildId.mdx | 2 + .../05-next-config-js/generateEtags.mdx | 2 + .../05-next-config-js/headers.mdx | 22 +++++++++++ .../05-next-config-js/httpAgentOptions.mdx | 2 + .../05-next-config-js/images.mdx | 12 ++++++ .../05-next-config-js/index.mdx | 2 + .../05-next-config-js/onDemandEntries.mdx | 2 + .../05-next-config-js/output.mdx | 15 ++++++++ .../05-next-config-js/pageExtensions.mdx | 2 + .../05-next-config-js/poweredByHeader.mdx | 2 + .../productionBrowserSourceMaps.mdx | 2 + .../05-next-config-js/reactStrictMode.mdx | 2 + .../05-next-config-js/redirects.mdx | 12 ++++++ .../05-next-config-js/rewrites.mdx | 37 +++++++++++++++++++ .../runtime-configuration.mdx | 2 + .../05-next-config-js/trailingSlash.mdx | 2 + .../05-next-config-js/transpilePackages.mdx | 2 + .../05-next-config-js/turbo.mdx | 2 + .../05-next-config-js/typescript.mdx | 2 + .../05-next-config-js/urlImports.mdx | 2 + .../webVitalsAttribution.mdx | 2 + .../05-next-config-js/webpack.mdx | 16 ++++++++ .../02-api-reference/06-create-next-app.mdx | 2 + docs/02-app/02-api-reference/07-edge.mdx | 2 + docs/02-app/02-api-reference/08-next-cli.mdx | 2 + .../01-routing/10-middleware.mdx | 2 +- .../06-edge-and-nodejs-runtimes.mdx | 2 +- .../04-styling/01-css-modules.mdx | 2 +- .../04-styling/02-tailwind-css.mdx | 2 +- .../04-styling/03-css-in-js.mdx | 2 +- .../04-styling/04-sass.mdx | 2 +- .../04-styling/index.mdx | 2 +- .../05-optimizing/01-images.mdx | 2 +- .../05-optimizing/02-fonts.mdx | 2 +- .../05-optimizing/03-scripts.mdx | 2 +- .../05-optimizing/05-static-assets.mdx | 2 +- .../05-optimizing/06-lazy-loading.mdx | 2 +- .../05-optimizing/07-analytics.mdx | 2 +- .../05-optimizing/08-open-telemetry.mdx | 2 +- .../05-optimizing/09-instrumentation.mdx | 2 +- .../05-optimizing/index.mdx | 2 +- .../06-configuring/01-typescript.mdx | 2 +- .../06-configuring/02-eslint.mdx | 2 +- .../03-environment-variables.mdx | 2 +- ...04-absolute-imports-and-module-aliases.mdx | 2 +- .../06-configuring/05-src-directory.mdx | 2 +- .../06-configuring/06-mdx.mdx | 2 +- .../06-configuring/index.mdx | 2 +- .../07-deploying/02-static-exports.mdx | 2 +- .../07-deploying/index.mdx | 2 +- .../08-upgrading/01-codemods.mdx | 2 +- .../08-upgrading/02-app-router-migration.mdx | 2 +- .../08-upgrading/index.mdx | 2 +- .../01-building-your-application/index.mdx | 2 +- .../02-api-reference/01-components/font.mdx | 2 +- .../02-api-reference/01-components/image.mdx | 2 +- .../02-api-reference/01-components/index.mdx | 2 +- .../02-api-reference/01-components/link.mdx | 2 +- .../02-api-reference/01-components/script.mdx | 2 +- .../02-api-reference/02-functions/index.mdx | 2 +- .../02-functions/use-report-web-vitals.mdx | 2 +- .../03-next-config-js/assetPrefix.mdx | 2 +- .../03-next-config-js/basePath.mdx | 2 +- .../03-next-config-js/compress.mdx | 2 +- .../03-next-config-js/devIndicators.mdx | 2 +- .../03-next-config-js/distDir.mdx | 2 +- .../03-next-config-js/env.mdx | 2 +- .../03-next-config-js/eslint.mdx | 2 +- .../03-next-config-js/exportPathMap.mdx | 2 +- .../03-next-config-js/generateBuildId.mdx | 2 +- .../03-next-config-js/generateEtags.mdx | 2 +- .../03-next-config-js/headers.mdx | 2 +- .../03-next-config-js/httpAgentOptions.mdx | 2 +- .../03-next-config-js/images.mdx | 2 +- .../03-next-config-js/index.mdx | 2 +- .../03-next-config-js/onDemandEntries.mdx | 2 +- .../03-next-config-js/output.mdx | 2 +- .../03-next-config-js/pageExtensions.mdx | 2 +- .../03-next-config-js/poweredByHeader.mdx | 2 +- .../productionBrowserSourceMaps.mdx | 2 +- .../03-next-config-js/reactStrictMode.mdx | 2 +- .../03-next-config-js/redirects.mdx | 2 +- .../03-next-config-js/rewrites.mdx | 2 +- .../runtime-configuration.mdx | 2 +- .../03-next-config-js/trailingSlash.mdx | 2 +- .../03-next-config-js/transpilePackages.mdx | 2 +- .../03-next-config-js/turbo.mdx | 2 +- .../03-next-config-js/typescript.mdx | 2 +- .../03-next-config-js/urlImports.mdx | 2 +- .../webVitalsAttribution.mdx | 2 +- .../03-next-config-js/webpack.mdx | 2 +- .../02-api-reference/04-create-next-app.mdx | 2 +- .../03-pages/02-api-reference/05-next-cli.mdx | 2 +- docs/03-pages/02-api-reference/06-edge.mdx | 2 +- 141 files changed, 500 insertions(+), 74 deletions(-) diff --git a/docs/02-app/01-building-your-application/01-routing/11-middleware.mdx b/docs/02-app/01-building-your-application/01-routing/11-middleware.mdx index 03edf864d006..03e62d8e6915 100644 --- a/docs/02-app/01-building-your-application/01-routing/11-middleware.mdx +++ b/docs/02-app/01-building-your-application/01-routing/11-middleware.mdx @@ -3,6 +3,8 @@ title: Middleware description: Learn how to use Middleware to run code before a request is completed. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Middleware allows you to run code before a request is completed. Then, based on the incoming request, you can modify the response by rewriting, redirecting, modifying the request or response headers, or responding directly. Middleware runs before cached content and routes are matched. See [Matching Paths](#matching-paths) for more details. @@ -121,11 +123,24 @@ The `NextResponse` API allows you to: - Set response cookies - Set response headers + + +To produce a response from Middleware, you can: + +1. `rewrite` to a route ([Page](/docs/app/building-your-application/routing/pages-and-layouts) or [Route Handler](/docs/app/building-your-application/routing/router-handlers)) that produces a response +2. return a `NextResponse` directly. See [Producing a Response](#producing-a-response) + + + + + To produce a response from Middleware, you can: 1. `rewrite` to a route ([Page](/docs/pages/building-your-application/routing/pages-and-layouts) or [Edge API Route](/docs/pages/building-your-application/routing/api-routes)) that produces a response 2. return a `NextResponse` directly. See [Producing a Response](#producing-a-response) + + ## Using Cookies Cookies are regular headers. On a `Request`, they are stored in the `Cookie` header. On a `Response` they are in the `Set-Cookie` header. Next.js provides a convenient way to access and manipulate these cookies through the `cookies` extension on `NextRequest` and `NextResponse`. diff --git a/docs/02-app/01-building-your-application/02-rendering/02-edge-and-nodejs-runtimes.mdx b/docs/02-app/01-building-your-application/02-rendering/02-edge-and-nodejs-runtimes.mdx index 55b798b6693b..849d6b10ca82 100644 --- a/docs/02-app/01-building-your-application/02-rendering/02-edge-and-nodejs-runtimes.mdx +++ b/docs/02-app/01-building-your-application/02-rendering/02-edge-and-nodejs-runtimes.mdx @@ -3,6 +3,8 @@ title: Edge and Node.js Runtimes description: Learn about the switchable runtimes (Edge and Node.js) in Next.js. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + In the context of Next.js, "runtime" refers to the set of libraries, APIs, and general functionality available to your code during execution. Next.js has two server runtimes where you can render parts of your application code: diff --git a/docs/02-app/01-building-your-application/04-styling/01-css-modules.mdx b/docs/02-app/01-building-your-application/04-styling/01-css-modules.mdx index 41063ff0889a..ae41e8fc74b7 100644 --- a/docs/02-app/01-building-your-application/04-styling/01-css-modules.mdx +++ b/docs/02-app/01-building-your-application/04-styling/01-css-modules.mdx @@ -3,6 +3,8 @@ title: CSS Modules description: Style your Next.js Application with CSS Modules. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
diff --git a/docs/02-app/01-building-your-application/04-styling/02-tailwind-css.mdx b/docs/02-app/01-building-your-application/04-styling/02-tailwind-css.mdx index ae5c2343c123..ad7b9a519562 100644 --- a/docs/02-app/01-building-your-application/04-styling/02-tailwind-css.mdx +++ b/docs/02-app/01-building-your-application/04-styling/02-tailwind-css.mdx @@ -3,6 +3,8 @@ title: Tailwind CSS description: Style your Next.js Application using Tailwind CSS. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
diff --git a/docs/02-app/01-building-your-application/04-styling/03-css-in-js.mdx b/docs/02-app/01-building-your-application/04-styling/03-css-in-js.mdx index df539c6888dc..115a639bfe0b 100644 --- a/docs/02-app/01-building-your-application/04-styling/03-css-in-js.mdx +++ b/docs/02-app/01-building-your-application/04-styling/03-css-in-js.mdx @@ -3,6 +3,8 @@ title: CSS-in-JS description: Use CSS-in-JS libraries with Next.js --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + > **Warning:** CSS-in-JS libraries which require runtime JavaScript are not currently supported in Server Components. Using CSS-in-JS with newer React features like Server Components and Streaming requires library authors to support the latest version of React, including [concurrent rendering](https://react.dev/blog/2022/03/29/react-v18#what-is-concurrent-react). diff --git a/docs/02-app/01-building-your-application/04-styling/04-sass.mdx b/docs/02-app/01-building-your-application/04-styling/04-sass.mdx index 326fc39c49a6..04582cd79297 100644 --- a/docs/02-app/01-building-your-application/04-styling/04-sass.mdx +++ b/docs/02-app/01-building-your-application/04-styling/04-sass.mdx @@ -3,6 +3,8 @@ title: Sass description: Style your Next.js application using Sass. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js has built-in support for Sass using both the `.scss` and `.sass` extensions. You can use component-level Sass via CSS Modules and the `.module.scss`or `.module.sass` extension. First, install [`sass`](https://github.com/sass/sass): diff --git a/docs/02-app/01-building-your-application/04-styling/index.mdx b/docs/02-app/01-building-your-application/04-styling/index.mdx index c02464f5d625..20cf28d2676b 100644 --- a/docs/02-app/01-building-your-application/04-styling/index.mdx +++ b/docs/02-app/01-building-your-application/04-styling/index.mdx @@ -3,6 +3,8 @@ title: Styling description: Learn the different ways you can style your Next.js application. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js supports different ways of styling your application, including: - **Global CSS**: Simple to use and familiar for those experienced with traditional CSS, but can lead to larger CSS bundles and difficulty managing styles as the application grows. diff --git a/docs/02-app/01-building-your-application/05-optimizing/01-images.mdx b/docs/02-app/01-building-your-application/05-optimizing/01-images.mdx index 83bb2cffa347..65ebaeb7796a 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/01-images.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/01-images.mdx @@ -9,6 +9,8 @@ related: - app/api-reference/components/image --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
Examples diff --git a/docs/02-app/01-building-your-application/05-optimizing/02-fonts.mdx b/docs/02-app/01-building-your-application/05-optimizing/02-fonts.mdx index b1c06c129bdd..50a56a33c135 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/02-fonts.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/02-fonts.mdx @@ -9,6 +9,8 @@ related: - app/api-reference/components/font --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + [**`next/font`**](/docs/app/api-reference/components/font) will automatically optimize your fonts (including custom fonts) and remove external network requests for improved privacy and performance. > **🎥 Watch:** Learn more about how to use `next/font` → [YouTube (6 minutes)](https://www.youtube.com/watch?v=L8_98i_bMMA). diff --git a/docs/02-app/01-building-your-application/05-optimizing/03-scripts.mdx b/docs/02-app/01-building-your-application/05-optimizing/03-scripts.mdx index 65c0388c29c5..a6be9fb23e63 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/03-scripts.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/03-scripts.mdx @@ -9,6 +9,8 @@ related: - app/api-reference/components/script --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + ### Layout Scripts diff --git a/docs/02-app/01-building-your-application/05-optimizing/05-static-assets.mdx b/docs/02-app/01-building-your-application/05-optimizing/05-static-assets.mdx index 450a0c9872f2..5809f1a589a9 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/05-static-assets.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/05-static-assets.mdx @@ -3,6 +3,8 @@ title: Static Assets description: Next.js allows you to serve static files, like images, in the public directory. You can learn how it works here. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js can serve static files, like images, under a folder called `public` in the root directory. Files inside `public` can then be referenced by your code starting from the base URL (`/`). For example, if you add `me.png` inside `public`, the following code will access the image: diff --git a/docs/02-app/01-building-your-application/05-optimizing/06-lazy-loading.mdx b/docs/02-app/01-building-your-application/05-optimizing/06-lazy-loading.mdx index 89e0983064ab..25ff08aaf540 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/06-lazy-loading.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/06-lazy-loading.mdx @@ -3,6 +3,8 @@ title: Lazy Loading description: Lazy load imported libraries and React Components to improve your application's loading performance. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + [Lazy loading](https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading) in Next.js helps improve the initial loading performance of an application by decreasing the amount of JavaScript needed to render a route. It allows you to defer loading of **Client Components** and imported libraries, and only include them in the client bundle when they're needed. For example, you might want to defer loading a modal until a user clicks to open it. diff --git a/docs/02-app/01-building-your-application/05-optimizing/07-analytics.mdx b/docs/02-app/01-building-your-application/05-optimizing/07-analytics.mdx index c15323a8cdde..ffdc6fd194a7 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/07-analytics.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/07-analytics.mdx @@ -3,6 +3,8 @@ title: Analytics description: Measure and track page performance using Next.js Speed Insights --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + [Next.js Speed Insights](https://nextjs.org/analytics) allows you to analyze and measure the performance of pages using different metrics. diff --git a/docs/02-app/01-building-your-application/05-optimizing/08-open-telemetry.mdx b/docs/02-app/01-building-your-application/05-optimizing/08-open-telemetry.mdx index 0cb825bcb1b5..83ec143e4d94 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/08-open-telemetry.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/08-open-telemetry.mdx @@ -3,6 +3,8 @@ title: OpenTelemetry description: Learn how to instrument your Next.js app with OpenTelemetry. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + > **Good to know**: This feature is **experimental**, you need to explicitly opt-in by providing `experimental.instrumentationHook = true;` in your `next.config.js`. Observability is crucial for understanding and optimizing the behavior and performance of your Next.js app. @@ -35,8 +37,18 @@ To get started, you must install `@vercel/otel`: npm install @vercel/otel ``` + + +Next, create a custom [`instrumentation.ts`](/docs/app/building-your-application/optimizing/instrumentation) (or `.js`) file in the **root directory** of the project (or inside `src` folder if using one): + + + + + Next, create a custom [`instrumentation.ts`](/docs/pages/building-your-application/optimizing/instrumentation) (or `.js`) file in the **root directory** of the project (or inside `src` folder if using one): + + ```ts filename="your-project/instrumentation.ts" switcher import { registerOTel } from '@vercel/otel' @@ -53,12 +65,26 @@ export function register() { } ``` + + +> **Good to know** +> +> - The `instrumentation` file should be in the root of your project and not inside the `app` or `pages` directory. If you're using the `src` folder, then place the file inside `src` alongside `pages` and `app`. +> - If you use the [`pagesExtension` config option](/docs/app/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match. +> - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use. + + + + + > **Good to know** > > - The `instrumentation` file should be in the root of your project and not inside the `app` or `pages` directory. If you're using the `src` folder, then place the file inside `src` alongside `pages` and `app`. > - If you use the [`pagesExtension` config option](/docs/pages/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match. > - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use. + + ### Manual OpenTelemetry configuration If our wrapper `@vercel/otel` doesn't suit your needs, you can configure OpenTelemetry manually. diff --git a/docs/02-app/01-building-your-application/05-optimizing/09-instrumentation.mdx b/docs/02-app/01-building-your-application/05-optimizing/09-instrumentation.mdx index 04237c48a42d..8e3b95ad80b9 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/09-instrumentation.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/09-instrumentation.mdx @@ -3,8 +3,23 @@ title: Instrumentation description: Learn how to use instrumentation to run code at server startup in your Next.js app --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + If you export a function named `register` from a `instrumentation.ts` (or `.js`) file in the **root directory** of your project (or inside the `src` folder if using one), we will call that function whenever a new Next.js server instance is bootstrapped. + + +> **Good to know** +> +> - This feature is **experimental**. To use it, you must explicitly opt in by defining `experimental.instrumentationHook = true;` in your `next.config.js`. +> - The `instrumentation` file should be in the root of your project and not inside the `app` or `pages` directory. If you're using the `src` folder, then place the file inside `src` alongside `pages` and `app`. +> - If you use the [`pagesExtension` config option](/docs/app/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match. +> - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use. + + + + + > **Good to know** > > - This feature is **experimental**. To use it, you must explicitly opt in by defining `experimental.instrumentationHook = true;` in your `next.config.js`. @@ -12,6 +27,8 @@ If you export a function named `register` from a `instrumentation.ts` (or `.js`) > - If you use the [`pagesExtension` config option](/docs/pages/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match. > - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use. + + When your `register` function is deployed, it will be called on each cold boot (but exactly once in each environment). Sometimes, it may be useful to import a file in your code because of the side effects it will cause. For example, you might import a file that defines a set of global variables, but never explicitly use the imported file in your code. You would still have access to the global variables the package has declared. diff --git a/docs/02-app/01-building-your-application/05-optimizing/index.mdx b/docs/02-app/01-building-your-application/05-optimizing/index.mdx index 2cb80df4200b..1d120a110719 100644 --- a/docs/02-app/01-building-your-application/05-optimizing/index.mdx +++ b/docs/02-app/01-building-your-application/05-optimizing/index.mdx @@ -4,6 +4,8 @@ nav_title: Optimizing description: Optimize your Next.js application for best performance and user experience. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js comes with a variety of built-in optimizations designed to improve your application's speed and [Core Web Vitals](https://web.dev/vitals/). This guide will cover the optimizations you can leverage to enhance your user experience. ## Built-in Components diff --git a/docs/02-app/01-building-your-application/06-configuring/01-typescript.mdx b/docs/02-app/01-building-your-application/06-configuring/01-typescript.mdx index e2c87b4c6aa6..0259b5151727 100644 --- a/docs/02-app/01-building-your-application/06-configuring/01-typescript.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/01-typescript.mdx @@ -3,11 +3,14 @@ title: TypeScript description: Next.js provides a TypeScript-first development experience for building your React application. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js provides a TypeScript-first development experience for building your React application. It comes with built-in TypeScript support for automatically installing the necessary packages and configuring the proper settings. + As well as a [TypeScript Plugin](#typescript-plugin) for your editor. > **🎥 Watch:** Learn about the built-in TypeScript plugin → [YouTube (3 minutes)](https://www.youtube.com/watch?v=pqMqn9fKEf8) @@ -242,8 +245,18 @@ export default function MyApp({ Component, pageProps }: AppProps) { Next.js automatically supports the `tsconfig.json` `"paths"` and `"baseUrl"` options. + + +You can learn more about this feature on the [Module Path aliases documentation](/docs/app/building-your-application/configuring/absolute-imports-and-module-aliases). + + + + + You can learn more about this feature on the [Module Path aliases documentation](/docs/pages/building-your-application/configuring/absolute-imports-and-module-aliases). + + ## Type checking next.config.js The `next.config.js` file must be a JavaScript file as it does not get parsed by Babel or TypeScript, however you can add some type checking in your IDE using JSDoc as below: diff --git a/docs/02-app/01-building-your-application/06-configuring/02-eslint.mdx b/docs/02-app/01-building-your-application/06-configuring/02-eslint.mdx index f32817faf8bb..5d7971484916 100644 --- a/docs/02-app/01-building-your-application/06-configuring/02-eslint.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/02-eslint.mdx @@ -3,6 +3,8 @@ title: ESLint description: Next.js provides an integrated ESLint experience by default. These conformance rules help you use Next.js in an optimal way. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js provides an integrated [ESLint](https://eslint.org/) experience out of the box. Add `next lint` as a script to `package.json`: ```json filename="package.json" @@ -35,7 +37,7 @@ yarn lint One of the following three options can be selected: -- **Strict**: Includes Next.js' base ESLint configuration along with a stricter [Core Web Vitals rule-set](/docs/pages/building-your-application/configuring/eslint#core-web-vitals). This is the recommended configuration for developers setting up ESLint for the first time. +- **Strict**: Includes Next.js' base ESLint configuration along with a stricter [Core Web Vitals rule-set](#core-web-vitals). This is the recommended configuration for developers setting up ESLint for the first time. ```json filename=".eslintrc.json" { @@ -57,8 +59,18 @@ If either of the two configuration options are selected, Next.js will automatica You can now run `next lint` every time you want to run ESLint to catch errors. Once ESLint has been set up, it will also automatically run during every build (`next build`). Errors will fail the build, while warnings will not. + + +> If you do not want ESLint to run during `next build`, refer to the documentation for [Ignoring ESLint](/docs/app/api-reference/next-config-js/eslint). + + + + + > If you do not want ESLint to run during `next build`, refer to the documentation for [Ignoring ESLint](/docs/pages/api-reference/next-config-js/eslint). + + We recommend using an appropriate [integration](https://eslint.org/docs/user-guide/integrations#editors) to view warnings and errors directly in your code editor during development. ## ESLint Config @@ -105,7 +117,7 @@ Next.js provides an ESLint plugin, [`eslint-plugin-next`](https://www.npmjs.com/ | | @next/next/no-typos | Prevent common typos in [Next.js's data fetching functions](/docs/pages/building-your-application/data-fetching) | | | [@next/next/no-unwanted-polyfillio](/docs/messages/no-unwanted-polyfillio) | Prevent duplicate polyfills from Polyfill.io. | -If you already have ESLint configured in your application, we recommend extending from this plugin directly instead of including `eslint-config-next` unless a few conditions are met. Refer to the [Recommended Plugin Ruleset](/docs/pages/building-your-application/configuring/eslint#recommended-plugin-ruleset) to learn more. +If you already have ESLint configured in your application, we recommend extending from this plugin directly instead of including `eslint-config-next` unless a few conditions are met. Refer to the [Recommended Plugin Ruleset](#recommended-plugin-ruleset) to learn more. ### Custom Settings @@ -146,8 +158,18 @@ next lint --dir pages --dir utils --file bar.js ## Caching + + +To improve performance, information of files processed by ESLint are cached by default. This is stored in `.next/cache` or in your defined [build directory](/docs/app/api-reference/next-config-js/distDir). If you include any ESLint rules that depend on more than the contents of a single source file and need to disable the cache, use the `--no-cache` flag with `next lint`. + + + + + To improve performance, information of files processed by ESLint are cached by default. This is stored in `.next/cache` or in your defined [build directory](/docs/pages/api-reference/next-config-js/distDir). If you include any ESLint rules that depend on more than the contents of a single source file and need to disable the cache, use the `--no-cache` flag with `next lint`. + + ```bash filename="Terminal" next lint --no-cache ``` diff --git a/docs/02-app/01-building-your-application/06-configuring/03-environment-variables.mdx b/docs/02-app/01-building-your-application/06-configuring/03-environment-variables.mdx index b1da6dce6514..b5040cf42759 100644 --- a/docs/02-app/01-building-your-application/06-configuring/03-environment-variables.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/03-environment-variables.mdx @@ -3,6 +3,8 @@ title: Environment Variables description: Learn to add and access environment variables in your Next.js application. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
Examples @@ -26,6 +28,7 @@ DB_PASS=mypassword ``` + This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Next.js data fetching methods](/docs/pages/building-your-application/data-fetching) and [API routes](/docs/pages/building-your-application/routing/api-routes). For example, using [`getStaticProps`](/docs/pages/building-your-application/data-fetching/get-static-props): @@ -44,6 +47,7 @@ export async function getStaticProps() { + This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in Route Handlers. {/* TODO: App Router Example */} diff --git a/docs/02-app/01-building-your-application/06-configuring/04-absolute-imports-and-module-aliases.mdx b/docs/02-app/01-building-your-application/06-configuring/04-absolute-imports-and-module-aliases.mdx index 278b7e8adcd9..ff9a06d66795 100644 --- a/docs/02-app/01-building-your-application/06-configuring/04-absolute-imports-and-module-aliases.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/04-absolute-imports-and-module-aliases.mdx @@ -3,6 +3,8 @@ title: Absolute Imports and Module Path Aliases description: Configure module path aliases that allow you to remap certain import paths. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
Examples diff --git a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx index 64f130628883..43c407498115 100644 --- a/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/05-mdx.mdx @@ -3,6 +3,8 @@ title: MDX description: Learn how to configure MDX to write JSX in your markdown files. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + [Markdown](https://daringfireball.net/projects/markdown/syntax) is a lightweight markup language used to format text. It allows you to write using plain text syntax and convert it to structurally valid HTML. It's commonly used for writing content on websites and blogs. You write... diff --git a/docs/02-app/01-building-your-application/06-configuring/06-src-directory.mdx b/docs/02-app/01-building-your-application/06-configuring/06-src-directory.mdx index 534e43db1c65..babc8381477d 100644 --- a/docs/02-app/01-building-your-application/06-configuring/06-src-directory.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/06-src-directory.mdx @@ -6,6 +6,8 @@ related: - app/building-your-application/routing/colocation --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + As an alternative to having the special Next.js `app` or `pages` directories in the root of your project, Next.js also supports the common pattern of placing application code under the `src` directory. This separates application code from project configuration files which mostly live in the root of a project. Which is preferred by some individuals and teams. diff --git a/docs/02-app/01-building-your-application/06-configuring/11-draft-mode.mdx b/docs/02-app/01-building-your-application/06-configuring/11-draft-mode.mdx index a997e5b94de3..f4014b7a3c14 100644 --- a/docs/02-app/01-building-your-application/06-configuring/11-draft-mode.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/11-draft-mode.mdx @@ -233,7 +233,7 @@ export async function GET(request) { } ``` -Then, send a request to `/api/disable-draft` to invoke the Route Handler. If calling this route using [`next/link`](/docs/pages/api-reference/components/link), you must pass `prefetch={false}` to prevent accidentally deleting the cookie on prefetch. +Then, send a request to `/api/disable-draft` to invoke the Route Handler. If calling this route using [`next/link`](/docs/app/api-reference/components/link), you must pass `prefetch={false}` to prevent accidentally deleting the cookie on prefetch. ### Unique per `next build` diff --git a/docs/02-app/01-building-your-application/06-configuring/index.mdx b/docs/02-app/01-building-your-application/06-configuring/index.mdx index 326ea00a2151..1cbae5fdfb26 100644 --- a/docs/02-app/01-building-your-application/06-configuring/index.mdx +++ b/docs/02-app/01-building-your-application/06-configuring/index.mdx @@ -3,4 +3,6 @@ title: Configuring description: Learn how to configure your Next.js application. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js allows you to customize your project to meet specific requirements. This includes integrations with TypeScript, ESlint, and more, as well as internal configuration options such as Absolute Imports and Environment Variables. diff --git a/docs/02-app/01-building-your-application/07-deploying/01-static-exports.mdx b/docs/02-app/01-building-your-application/07-deploying/01-static-exports.mdx index 2798695dd034..4803dd29e95a 100644 --- a/docs/02-app/01-building-your-application/07-deploying/01-static-exports.mdx +++ b/docs/02-app/01-building-your-application/07-deploying/01-static-exports.mdx @@ -3,6 +3,8 @@ title: Static Exports description: Next.js enables starting as a static site or Single-Page Application (SPA), then later optionally upgrading to use features that require a server. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js enables starting as a static site or Single-Page Application (SPA), then later optionally upgrading to use features that require a server. When running `next build`, Next.js generates an HTML file per route. By breaking a strict SPA into individual HTML files, Next.js can avoid loading unnecessary JavaScript code on the client-side, reducing the bundle size and enabling faster page loads. diff --git a/docs/02-app/01-building-your-application/07-deploying/index.mdx b/docs/02-app/01-building-your-application/07-deploying/index.mdx index ac8e140f47de..796da4f146d1 100644 --- a/docs/02-app/01-building-your-application/07-deploying/index.mdx +++ b/docs/02-app/01-building-your-application/07-deploying/index.mdx @@ -3,6 +3,8 @@ title: Deploying description: Learn how to deploy your Next.js app to production, either managed or self-hosted. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Congratulations! You're here because you are ready to deploy your Next.js application. This page will show how to deploy either managed or self-hosted using the [Next.js Build API](#nextjs-build-api). ## Next.js Build API diff --git a/docs/02-app/01-building-your-application/08-upgrading/01-codemods.mdx b/docs/02-app/01-building-your-application/08-upgrading/01-codemods.mdx index 63b4579526ca..8a6522114d5c 100644 --- a/docs/02-app/01-building-your-application/08-upgrading/01-codemods.mdx +++ b/docs/02-app/01-building-your-application/08-upgrading/01-codemods.mdx @@ -118,8 +118,18 @@ Dangerously migrates from `next/legacy/image` to the new `next/image` by adding npx @next/codemod@latest new-link . ``` + + Remove `` tags inside [Link Components](/docs/app/api-reference/components/link), or add a `legacyBehavior` prop to Links that cannot be auto-fixed. + + + + +Remove `` tags inside [Link Components](/docs/pages/api-reference/components/link), or add a `legacyBehavior` prop to Links that cannot be auto-fixed. + + + For example: ```jsx diff --git a/docs/02-app/01-building-your-application/index.mdx b/docs/02-app/01-building-your-application/index.mdx index b16d54ebbbce..e70cf74a13b3 100644 --- a/docs/02-app/01-building-your-application/index.mdx +++ b/docs/02-app/01-building-your-application/index.mdx @@ -3,6 +3,8 @@ title: Building Your Application description: Learn how to use Next.js features to build your application. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + Next.js provides the building blocks to create flexible, full-stack web applications. The guides in **Building Your Application** explain how to use these features and how to customize your application's behavior. The sections and pages are organized sequentially, from basic to advanced, so you can follow them step-by-step when building your Next.js application. However, you can read them in any order or skip to the pages that apply to your use case. diff --git a/docs/02-app/02-api-reference/01-components/font.mdx b/docs/02-app/02-api-reference/01-components/font.mdx index 03d6e1195949..7bbb073a2036 100644 --- a/docs/02-app/02-api-reference/01-components/font.mdx +++ b/docs/02-app/02-api-reference/01-components/font.mdx @@ -4,6 +4,8 @@ nav_title: Font description: Optimizing loading web fonts with the built-in `next/font` loaders. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} + This API reference will help you understand how to use [`next/font/google`](/docs/app/building-your-application/optimizing/fonts#google-fonts) and [`next/font/local`](/docs/app/building-your-application/optimizing/fonts#local-fonts). For features and usage, please see the [Optimizing Fonts](/docs/app/building-your-application/optimizing/fonts) page. ### Font Function Arguments diff --git a/docs/02-app/02-api-reference/01-components/image.mdx b/docs/02-app/02-api-reference/01-components/image.mdx index ad2ed9c11a9b..c077f871f725 100644 --- a/docs/02-app/02-api-reference/01-components/image.mdx +++ b/docs/02-app/02-api-reference/01-components/image.mdx @@ -3,6 +3,8 @@ title: description: Optimize Images in your Next.js Application using the built-in `next/image` Component. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
Examples diff --git a/docs/02-app/02-api-reference/01-components/index.mdx b/docs/02-app/02-api-reference/01-components/index.mdx index ede175519732..ebbdf4bd444a 100644 --- a/docs/02-app/02-api-reference/01-components/index.mdx +++ b/docs/02-app/02-api-reference/01-components/index.mdx @@ -2,3 +2,5 @@ title: Components description: API Reference for Next.js built-in components. --- + +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} diff --git a/docs/02-app/02-api-reference/01-components/link.mdx b/docs/02-app/02-api-reference/01-components/link.mdx index b484240480f9..eb4d10e1cfa4 100644 --- a/docs/02-app/02-api-reference/01-components/link.mdx +++ b/docs/02-app/02-api-reference/01-components/link.mdx @@ -3,6 +3,8 @@ title: description: Enable fast client-side navigation with the built-in `next/link` component. --- +{/* The content of this doc is shared between the app and pages router. You can use the `Content` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} +
Examples @@ -243,8 +245,18 @@ function Page({ posts }) { ### If the child is a custom component that wraps an `` tag + + +If the child of `Link` is a custom component that wraps an `` tag, you must add `passHref` to `Link`. This is necessary if you’re using libraries like [styled-components](https://styled-components.com/). Without this, the `` tag will not have the `href` attribute, which hurts your site's accessibility and might affect SEO. If you're using [ESLint](/docs/app/building-your-application/configuring/eslint#eslint-plugin), there is a built-in rule `next/link-passhref` to ensure correct usage of `passHref`. + + + + + If the child of `Link` is a custom component that wraps an `` tag, you must add `passHref` to `Link`. This is necessary if you’re using libraries like [styled-components](https://styled-components.com/). Without this, the `` tag will not have the `href` attribute, which hurts your site's accessibility and might affect SEO. If you're using [ESLint](/docs/pages/building-your-application/configuring/eslint#eslint-plugin), there is a built-in rule `next/link-passhref` to ensure correct usage of `passHref`. + + ```jsx import Link from 'next/link' import styled from 'styled-components' diff --git a/docs/02-app/02-api-reference/01-components/script.mdx b/docs/02-app/02-api-reference/01-components/script.mdx index 56601e993b03..777b8ba04be1 100644 --- a/docs/02-app/02-api-reference/01-components/script.mdx +++ b/docs/02-app/02-api-reference/01-components/script.mdx @@ -3,6 +3,8 @@ title: