From 897da850ecdd6afb3b0f58d16206ae31ab6516fc Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 13 Jul 2023 21:49:48 +0200 Subject: [PATCH 1/3] chore: warning about ssr cjs format removal --- docs/guide/ssr.md | 4 ++++ packages/vite/src/node/config.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index 93830d1d8e5aaa..e2b311f54b43a7 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -270,3 +270,7 @@ Use a post hook so that your SSR middleware runs _after_ Vite's middlewares. ## SSR Format By default, Vite generates the SSR bundle in ESM. There is experimental support for configuring `ssr.format`, but it isn't recommended. Future efforts around SSR development will be based on ESM, and CommonJS remains available for backward compatibility. If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics: true` to generate a CJS bundle using the same [externalization heuristics of Vite v2](https://v2.vitejs.dev/guide/ssr.html#ssr-externals). + +:::warning Warning +Experimental `legacy.buildSsrCjsExternalHeuristics` and `ssr.format: 'cjs'` are going to be removed in Vite 5. Find more information and give feedback at [in this discussion](https://github.com/vitejs/vite/discussions/13816). +::: diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index b9442a3305b743..448a03e939945e 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -837,6 +837,19 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter } } + // Warn about removal of experimental features + if ( + config.legacy?.buildSsrCjsExternalHeuristics || + config.ssr?.format === 'cjs' + ) { + resolved.logger.warn( + colors.yellow(` +(!) Experimental legacy.buildSsrCjsExternalHeuristics and ssr.format: 'cjs' are going to be removed in Vite 5. + Find more information and give feedback at https://github.com/vitejs/vite/discussions/13816. +`), + ) + } + return resolved } From 4d872369b091c4f0c2fffbba91463363edf1cde2 Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 14 Jul 2023 08:44:35 +0200 Subject: [PATCH 2/3] chore: typo Co-authored-by: Bjorn Lu --- docs/guide/ssr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index e2b311f54b43a7..f70b0385a4096a 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -272,5 +272,5 @@ Use a post hook so that your SSR middleware runs _after_ Vite's middlewares. By default, Vite generates the SSR bundle in ESM. There is experimental support for configuring `ssr.format`, but it isn't recommended. Future efforts around SSR development will be based on ESM, and CommonJS remains available for backward compatibility. If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics: true` to generate a CJS bundle using the same [externalization heuristics of Vite v2](https://v2.vitejs.dev/guide/ssr.html#ssr-externals). :::warning Warning -Experimental `legacy.buildSsrCjsExternalHeuristics` and `ssr.format: 'cjs'` are going to be removed in Vite 5. Find more information and give feedback at [in this discussion](https://github.com/vitejs/vite/discussions/13816). +Experimental `legacy.buildSsrCjsExternalHeuristics` and `ssr.format: 'cjs'` are going to be removed in Vite 5. Find more information and give feedback [in this discussion](https://github.com/vitejs/vite/discussions/13816). ::: From d9d5713d5b1d4544077bbcd808d4d7aaa2661a10 Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 14 Jul 2023 08:50:27 +0200 Subject: [PATCH 3/3] chore: deprecate ssr format --- docs/config/ssr-options.md | 1 + packages/vite/src/node/ssr/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/config/ssr-options.md b/docs/config/ssr-options.md index 886b5f4bb4fca3..8d597ad59a0cd7 100644 --- a/docs/config/ssr-options.md +++ b/docs/config/ssr-options.md @@ -24,6 +24,7 @@ Build target for the SSR server. ## ssr.format - **Experimental** +- **Deprecated** Only ESM output will be supported in Vite 5. - **Type:** `'esm' | 'cjs'` - **Default:** `esm` diff --git a/packages/vite/src/node/ssr/index.ts b/packages/vite/src/node/ssr/index.ts index caf85dab072aa1..ba4597177170c0 100644 --- a/packages/vite/src/node/ssr/index.ts +++ b/packages/vite/src/node/ssr/index.ts @@ -20,6 +20,7 @@ export interface SSROptions { * left marked as experimental to give users more time to update to ESM. CJS builds requires * complex externalization heuristics that aren't present in the ESM format. * @experimental + * @deprecated * @default 'esm' */ format?: SSRFormat