Skip to content

Commit

Permalink
fix: disable inlineDynamicImports for ssr.target = node (#8641)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Jun 19, 2022
1 parent a52c6c8 commit 3b41a8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -478,7 +479,7 @@ async function doBuild(
inlineDynamicImports:
output.format === 'umd' ||
output.format === 'iife' ||
(ssr && typeof input === 'string'),
(ssrWorkerBuild && typeof input === 'string'),
...output
}
}
Expand Down

0 comments on commit 3b41a8e

Please sign in to comment.