Skip to content

Commit 3b41a8e

Browse files
authoredJun 19, 2022
fix: disable inlineDynamicImports for ssr.target = node (#8641)
1 parent a52c6c8 commit 3b41a8e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎docs/guide/migration.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Vite v3 uses ESM for the SSR build by default. When using ESM, the [SSR external
6262

6363
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.
6464

65+
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.
66+
6567
## General Changes
6668

6769
- 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.

‎packages/vite/src/node/build.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,11 @@ async function doBuild(
447447
)
448448
}
449449

450+
const ssrWorkerBuild = ssr && config.ssr?.target !== 'webworker'
450451
const cjsSsrBuild = ssr && config.ssr?.format === 'cjs'
451452
const format = output.format || (cjsSsrBuild ? 'cjs' : 'es')
452453
const jsExt =
453-
(ssr && config.ssr?.target !== 'webworker') || libOptions
454+
ssrWorkerBuild || libOptions
454455
? resolveOutputJsExtension(format, getPkgJson(config.root)?.type)
455456
: 'js'
456457
return {
@@ -478,7 +479,7 @@ async function doBuild(
478479
inlineDynamicImports:
479480
output.format === 'umd' ||
480481
output.format === 'iife' ||
481-
(ssr && typeof input === 'string'),
482+
(ssrWorkerBuild && typeof input === 'string'),
482483
...output
483484
}
484485
}

0 commit comments

Comments
 (0)
Please sign in to comment.