Repository navigation
Pass a literal worker type so Vite can bundle the ESM build - #124
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
The PR fixes a Vite bundling failure by changing the worker type from a variable (WORKER_TYPE) to a literal string ("module") in the ESM build's bundled worker branch. Vite requires the type option to be a literal for static analysis. The UMD build is unaffected and continues to use the classic worker pattern. Testing confirms the fix works with Vite 6 and 8, and both pnpm build and pnpm lint pass.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
vite buildfails on any app that imports@project516/ffmpeg-wasm0.17.0:Vite only bundles
new Worker(new URL(...), { type })whentypeis a literal. The ESM build has passedWORKER_TYPE, a variable, since #6. The bundled worker branch inclasses.tsnow passestype: "module".The UMD build keeps its classic worker. Webpack's worker plugin replaces the
typeof a worker it bundles withundefinedwhen the output is not ESM, sodist/umd/ffmpeg.jsstill has{type:void 0}, the same as before. TheclassWorkerURLbranch still usesWORKER_TYPE, because neither bundler handles that call.Testing
pnpm buildandpnpm lintpass.dist/esm/classes.jshastype: "module", anddist/umd/ffmpeg.jshas{type:void 0}for the bundled worker.apps/sveltekit-appwith Vite 8 failsvite buildagainst the published 0.17.0 with the error above. With this one-line change applied to the installedclasses.js, it builds and emits the worker chunk. On master the same app with Vite 6 fails the same way.