diff --git a/.prettierignore b/.prettierignore index 0fc71ddd114101..95541be4525222 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index dcaed0473e13b1..2e614ec7e0fa85 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -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' }), diff --git a/playground/worker/classic-worker.js b/playground/worker/classic-worker.js index be6fa357e70ec4..d68c61c14fd78f 100644 --- a/playground/worker/classic-worker.js +++ b/playground/worker/classic-worker.js @@ -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