vite build
fails when a WebWorker uses import()
: Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.
#18585
Labels
Describe the bug
I am encountering this build issue in an example repository when I run
yarn build
. I have minimized the issue to this bug report.I have the following Javascript simply exporting a class,
constructor.js
:Then, a WebWorker implementation loads this class and then does nothing with it:
The
main.ts
simply mentions the web worker:With this code, I would expect
yarn build
to succeed and build an application that contains a web worker, but does nothing when it starts. However, it fails with the following error:If I move the
module.default
piece to outside the web worker, theyarn build
succeeds, so it must be a combination of the two.Reproduction
https://stackblitz.com/edit/vitejs-vite-7cfaoa?file=index.html&terminal=dev
Steps to reproduce
On the Stackblitz link above, open an additional terminal, and run
yarn build
in it.The same example is available here:
vite-reproduction-scenario.tgz
Or, you can use the code from the description above - use dependency
"comlink": "^4.4.1"
and use/src/main.ts
as main module script.System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: