Skip to content
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
13 changes: 10 additions & 3 deletions src/compiler/bundle/worker-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const workerPlugin = (
name: 'workerPlugin',
transform(_, id) {
if (id.endsWith('?worker') || id.endsWith('?worker-inline')) {
return getMockedWorkerMain();
return {
code: getMockedWorkerMain(),
map: { mappings: '' },
};
}
return null;
},
Expand Down Expand Up @@ -77,6 +80,7 @@ export const workerPlugin = (
dependencies.forEach((id) => this.addWatchFile(id));
return {
code: getWorkerMain(referenceId, workerName, workerMsgId),
map: { mappings: '' },
moduleSideEffects: false,
};
} else if (id.endsWith('?worker-inline')) {
Expand All @@ -98,6 +102,7 @@ export const workerPlugin = (
dependencies.forEach((id) => this.addWatchFile(id));
return {
code: getInlineWorker(referenceId, workerName, workerMsgId),
map: { mappings: '' },
moduleSideEffects: false,
};
}
Expand All @@ -110,11 +115,13 @@ export const workerPlugin = (
if (inlineWorkers) {
return {
code: getInlineWorkerProxy(workerEntryPath, worker.workerMsgId, worker.exports),
map: { mappings: '' },
moduleSideEffects: false,
};
} else {
return {
code: getWorkerProxy(workerEntryPath, worker.exports),
map: { mappings: '' },
moduleSideEffects: false,
};
}
Expand Down Expand Up @@ -405,7 +412,7 @@ const getWorkerMain = (referenceId: string, workerName: string, workerMsgId: str
import { createWorker } from '${WORKER_HELPER_ID}';
export const workerName = '${workerName}';
export const workerMsgId = '${workerMsgId}';
export const workerPath = /*@__PURE__*/import.meta.ROLLUP_FILE_URL_${referenceId};
export const workerPath = import.meta.ROLLUP_FILE_URL_${referenceId};
export const worker = /*@__PURE__*/createWorker(workerPath, workerName, workerMsgId);
`;
};
Expand All @@ -415,7 +422,7 @@ const getInlineWorker = (referenceId: string, workerName: string, workerMsgId: s
import { createWorker } from '${WORKER_HELPER_ID}';
export const workerName = '${workerName}';
export const workerMsgId = '${workerMsgId}';
export const workerPath = /*@__PURE__*/import.meta.ROLLUP_FILE_URL_${referenceId};
export const workerPath = import.meta.ROLLUP_FILE_URL_${referenceId};
export let worker;
try {
// first try directly starting the worker with the URL
Expand Down
Loading