Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR webworker output options are set too early in Vite 6 #18825

Closed
6 of 7 tasks
bluwy opened this issue Nov 28, 2024 · 0 comments · Fixed by #18827
Closed
6 of 7 tasks

SSR webworker output options are set too early in Vite 6 #18825

bluwy opened this issue Nov 28, 2024 · 0 comments · Fixed by #18827
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) regression The issue only appears after a new release

Comments

@bluwy
Copy link
Member

bluwy commented Nov 28, 2024

Describe the bug

Particularly this code:

if (isSsrTargetWebworkerEnvironment) {
resolved.rollupOptions ??= {}
resolved.rollupOptions.output ??= {}
const output = resolved.rollupOptions.output
for (const out of arraify(output)) {
out.entryFileNames ??= `[name].js`
out.chunkFileNames ??= `[name]-[hash].js`
const input = resolved.rollupOptions.input
out.inlineDynamicImports ??=
!input || typeof input === 'string' || Object.keys(input).length === 1
}
}

We're computing the output options when resolving the config, however plugins could change the output options, or even the input options (that affects how inlineDynamicImports is computed) during the config() or options() hooks.

In Vite 5, we were computing only at the last step when generating the outputs:

chunkFileNames: libOptions
? `[name]-[hash].${jsExt}`
: path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
assetFileNames: libOptions
? `[name].[ext]`
: path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
inlineDynamicImports:
output.format === 'umd' ||
output.format === 'iife' ||
(ssrWorkerBuild &&
(typeof input === 'string' || Object.keys(input).length === 1)),


This was affecting Astro's Cloudflare integration where it uses SSR webworker and manualChunks, but since inlineDynamicImports is computed early and set as true (should be false as Astro later adds inputs in config() hook), it causes Rollup to throw with:

Invalid value for option "output.manualChunks" - this option is not supported for "output.inlineDynamicImports".

Reproduction

Sorry none for now

Steps to reproduce

No response

System Info

n/a

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red sapphi-red added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) regression The issue only appears after a new release labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants