vite
vite copied to clipboard
Improve error message for worker format errors
Description
If using code splitting, vite does not allow using 'iife' for workers. However, googling the message directs me to the wrong place for fixing it.
The error message is:
error during build:
[vite:worker] Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.
However, googling this will mention build.rollupOptions.output.format, which is not the offending value. Rather, I need to set build.worker.format, but the error message does not mention worker.format in any form.
Suggested solution
The error message should say
[vite:worker] Invalid value "iife" for option "worker.format" - IIFE output format is not supported for code-splitting builds.
Alternative
We can leave it as is and maybe include an entry in the documentation about worker.format.
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
It should be a error throwed by Rollup. I have improved the report message in Rolldown btw.
Stumbling upon this issue after 1.5 hours of Googling and leading to the wrong path. I appreciate you!
In my case i was getting error
ERROR [vite-plugin-pwa:build] Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.
I'm using vite-plugin-pwa and using web workers using ?worker import.
Fix:
// vite.config.ts
worker: {
format: "es",
},
Or, if using Vinxi
plugins: () => [
config("custom", {
worker: {
format: "es",
},
}),