Skip to content

Commit 3c5672e

Browse files
authored
fix: Worker detection (#948)
* fix: Worker detection * docs: Adding changset
1 parent ab4b512 commit 3c5672e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/moody-shirts-smash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'wmr': patch
3+
---
4+
5+
Corrects worker regex pattern to avoid false positives

packages/wmr/src/plugins/worker-plugin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export function workerPlugin(options) {
8585
}
8686
// Check if a worker is referenced anywhere in the file
8787
else if (/\.(?:[tj]sx?|mjs|cjs)$/.test(id)) {
88-
const WORKER_REG = /new URL\(\s*['"]([\w.-/:~]+)['"],\s*import\.meta\.url\s*\)(,\s*{.*?["']module["'].*?})?/gm;
88+
const WORKER_REG =
89+
/new URL\(\s*['"]([\w.-/:~]+\.worker[\w.-/:~]+)['"],\s*import\.meta\.url\s*\)(,\s*{.*?["']module["'].*?})?/gm;
8990

9091
if (WORKER_REG.test(code)) {
9192
const s = new MagicString(code, {

0 commit comments

Comments
 (0)