Skip to content

Commit

Permalink
fix(worker): fix injectScripts injection
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Aug 6, 2024
1 parent bb2f8bb commit 6b5a840
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand Down
2 changes: 2 additions & 0 deletions playground/worker/classic-worker.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 6b5a840

Please sign in to comment.