Open kot-lex opened 3 months ago
Start a new pull request in StackBlitz Codeflow.
After using inline, the code will be converted to base64 encoding, which leads to the relative path after compilation, which is a wrong way to get it, and I will fix this problem
If the intent is to inline an entire worker without code-splitting, then it's possible to use rollupOptions.output.inlineDynamicImports: true
(though probably allowing code-splitting is still useful for inline worker).
This is an updated repro https://stackblitz.com/edit/vitejs-vite-b7pvdf?file=vite.config.ts
@hi-ogawa my goal is to use dynamic imports inside the inline worker without inlining.
@hi-ogawa my goal is to use dynamic imports inside the inline worker without inlining.
@kot-lex Yeah, it's apparent that this pattern is not working and thanks for the reproduction. Btw, can you elaborate more on how it's not ideal to have neither non-inline worker nor fully-bundled inline worker with inlineDynamicImports: true
for your actual use cases?
@hi-ogawa sure:
For your usecase, I'd recommend using this workaround (https://github.com/vitejs/vite/issues/13680#issuecomment-1819274694). IMO the inline worker should inline everything.
Describe the bug
I'm using an inlined (?worker&inline) web worker that dynamically imports some other libraries. It works well in dev mode but fails in the production build since the filenames are relative which doesn't work with the worker's blob url.
Reproduction
https://stackblitz.com/edit/vitejs-vite-2td2he?file=src%2Fworker.ts
Steps to reproduce
System Info
Used Package Manager
npm
Logs
No response
Validations