Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,12 @@ export function resolveRolldownOptions(
assetFileNames: libOptions
? `[name].[ext]`
: path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
inlineDynamicImports:
codeSplitting: !(
output.format === 'umd' ||
output.format === 'iife' ||
(isSsrTargetWebworkerEnvironment &&
(typeof input === 'string' || Object.keys(input).length === 1)),
(typeof input === 'string' || Object.keys(input).length === 1))
),
legalComments: 'none',
minify:
options.minify === 'oxc'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ async function bundleConfigFile(
return path.resolve(fileName, relative)
},
// we want to generate a single chunk like esbuild does with `splitting: false`
inlineDynamicImports: true,
codeSplitting: false,
})
await bundle.close()

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
},

renderChunk(_, chunk, options) {
if (!options.inlineDynamicImports) {
if (options.codeSplitting !== false) {
for (const id of chunk.moduleIds) {
const module = this.getModuleInfo(id)
if (!module) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from 'vitest'
import { isBuild, serverLogs } from '~utils'

test.runIf(isBuild)(
"don't warn when inlineDynamicImports is set to true",
"don't warn when codeSplitting is set to false",
async () => {
const log = serverLogs.join('\n')
expect(log).not.toContain(
Expand Down
2 changes: 1 addition & 1 deletion playground/dynamic-import-inline/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
sourcemap: true,
rollupOptions: {
output: {
inlineDynamicImports: true,
codeSplitting: false,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion playground/ssr-webworker/__tests__/ssr-webworker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('supports nodejs_compat', async () => {
)
})

test.runIf(isBuild)('inlineDynamicImports', () => {
test.runIf(isBuild)('no code splitting', () => {
const dynamicJsContent = findAssetFile(/dynamic-[-\w]+\.js/, 'worker')
expect(dynamicJsContent).toBeUndefined()
})
Loading