Skip to content

Commit

Permalink
fix: Worker detection (#948)
Browse files Browse the repository at this point in the history
* fix: Worker detection

* docs: Adding changset
  • Loading branch information
rschristian authored Jan 4, 2023
1 parent ab4b512 commit 3c5672e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-shirts-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wmr': patch
---

Corrects worker regex pattern to avoid false positives
3 changes: 2 additions & 1 deletion packages/wmr/src/plugins/worker-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export function workerPlugin(options) {
}
// Check if a worker is referenced anywhere in the file
else if (/\.(?:[tj]sx?|mjs|cjs)$/.test(id)) {
const WORKER_REG = /new URL\(\s*['"]([\w.-/:~]+)['"],\s*import\.meta\.url\s*\)(,\s*{.*?["']module["'].*?})?/gm;
const WORKER_REG =
/new URL\(\s*['"]([\w.-/:~]+\.worker[\w.-/:~]+)['"],\s*import\.meta\.url\s*\)(,\s*{.*?["']module["'].*?})?/gm;

if (WORKER_REG.test(code)) {
const s = new MagicString(code, {
Expand Down

0 comments on commit 3c5672e

Please sign in to comment.