mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
fix(worker): fix importScripts
injection breaking iife code (#17827)
This commit is contained in:
parent
6ae0615416
commit
bb4ba9f448
@ -11,3 +11,4 @@ playground/html/invalid.html
|
||||
playground/html/valid.html
|
||||
playground/external/public/slash@3.0.0.js
|
||||
playground/ssr-html/public/slash@3.0.0.js
|
||||
playground/worker/classic-worker.js
|
||||
|
@ -265,7 +265,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
|
||||
}
|
||||
if (injectEnv) {
|
||||
const s = new MagicString(raw)
|
||||
s.prepend(injectEnv)
|
||||
s.prepend(injectEnv + ';\n')
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ hires: 'boundary' }),
|
||||
|
@ -1,3 +1,5 @@
|
||||
(() => {})() // this is to test `importScripts` injection doesn't break the code
|
||||
|
||||
let base = `/${self.location.pathname.split('/')[1]}`
|
||||
if (base.endsWith('.js') || base === `/worker-entries`) base = '' // for dev
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user