diff --git a/docs/guide/migration.md b/docs/guide/migration.md index 8eb8718aeb5c69..ca18af47e011fa 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -62,6 +62,8 @@ Vite v3 uses ESM for the SSR build by default. When using ESM, the [SSR external If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics` to generate a CJS bundle using the same externalization strategy of Vite v2. +Also [`build.rollupOptions.output.inlineDynamicImports`](https://rollupjs.org/guide/en/#outputinlinedynamicimports) now defaults to `false` when `ssr.target` is `'node'`. `inlineDynamicImports` changes execution order and bundling to a single file is not needed for node builds. + ## General Changes - JS file extensions in SSR and lib mode now use a valid extension (`js`, `mjs`, or `cjs`) for output JS entries and chunks based on their format and the package type. diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index d12542d35200f1..710c7218513018 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -447,10 +447,11 @@ async function doBuild( ) } + const ssrWorkerBuild = ssr && config.ssr?.target !== 'webworker' const cjsSsrBuild = ssr && config.ssr?.format === 'cjs' const format = output.format || (cjsSsrBuild ? 'cjs' : 'es') const jsExt = - (ssr && config.ssr?.target !== 'webworker') || libOptions + ssrWorkerBuild || libOptions ? resolveOutputJsExtension(format, getPkgJson(config.root)?.type) : 'js' return { @@ -478,7 +479,7 @@ async function doBuild( inlineDynamicImports: output.format === 'umd' || output.format === 'iife' || - (ssr && typeof input === 'string'), + (ssrWorkerBuild && typeof input === 'string'), ...output } }