Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(worker): force rollup to build worker module under watch mode #11919

Merged
merged 1 commit into from
Mar 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions packages/vite/src/node/plugins/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
let server: ViteDevServer
const isWorker = config.isWorker

const isWorkerQueryId = (id: string) => {
const parsedQuery = parseRequest(id)
if (
parsedQuery &&
(parsedQuery.worker ?? parsedQuery.sharedworker) != null
) {
return true
}

return false
}

return {
name: 'vite:worker',

Expand All @@ -217,15 +229,16 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
},

load(id) {
if (isBuild) {
const parsedQuery = parseRequest(id)
if (
parsedQuery &&
(parsedQuery.worker ?? parsedQuery.sharedworker) != null
) {
return ''
}
if (isBuild && isWorkerQueryId(id)) {
return ''
}
},

shouldTransformCachedModule({ id }) {
if (isBuild && isWorkerQueryId(id) && config.build.watch) {
return true
}
return false
},

async transform(raw, id, options) {
Expand Down