Skip to content

Commit

Permalink
refactor: remove CJS ssr output format (#13944)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
  • Loading branch information
patak-dev and sapphi-red authored Sep 17, 2023
1 parent b8ba9e0 commit db5679b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
9 changes: 0 additions & 9 deletions config/ssr-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,3 @@ Prevent listed dependencies from being externalized for SSR. If `true`, no depen
- **Default:** `node`

Build target for the SSR server.

## ssr.format

- **Experimental:** [CJS support to be removed in Vite 5](https://github.com/vitejs/vite/discussions/13816)
- **Deprecated** Only ESM output will be supported in Vite 5.
- **Type:** `'esm' | 'cjs'`
- **Default:** `esm`

Build format for the SSR server. Since Vite v3 the SSR build generates ESM by default. `'cjs'` can be selected to generate a CJS build, but it isn't recommended. The option is left marked as experimental to give users more time to update to ESM. CJS builds require complex externalization heuristics that aren't present in the ESM format.
8 changes: 0 additions & 8 deletions guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,3 @@ The CLI commands `$ vite dev` and `$ vite preview` can also be used for SSR apps
:::tip Note
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 [in this discussion](https://github.com/vitejs/vite/discussions/13816).
:::

0 comments on commit db5679b

Please sign in to comment.