Skip to content

Commit

Permalink
Use unique resource name with workerUrl
Browse files Browse the repository at this point in the history
Append `?workerUrl=true` resource query to a "virtual" module created using `workerUrl()`. This intends to resolve an issue , where there're duplicate entries being generated in the source maps that reference the same resource path of imported worker script, which can not be represented in devtools accordingly.

```
// client-main.js.map
...
"/foo/bar/src/worker.js" ... (Changes to => "/foo/bar/src/worker.js?workerUrl=true")
"module.exports = __webpack_public_path__ + \"worker.js\";

// worker.js.map
...
"/foo/bar/src/worker.js" ...
"console.log('test worker');"
```
  • Loading branch information
shYkiSto authored and fusionjs-sync-bot[bot] committed Jul 1, 2022
1 parent 141778c commit cc467da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function refsHandler(t, context, refs = []) {
}
args[0].replaceWith(
t.callExpression(t.identifier('require'), [
t.stringLiteral(`__SECRET_WORKER_LOADER__!${args[0].node.value}`),
t.stringLiteral(
`__SECRET_WORKER_LOADER__!${args[0].node.value}?workerUrl=true`
),
])
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { workerUrl } from 'fusion-core';
import { workerUrl as workerUrlOther } from 'workerUrl';
const path = './test';
workerUrl(require("__SECRET_WORKER_LOADER__!./path"));
workerUrl(require("__SECRET_WORKER_LOADER__!./path?workerUrl=true"));
workerUrlOther(path);
workerUrl(require("__SECRET_WORKER_LOADER__!./path"));
workerUrl(require("__SECRET_WORKER_LOADER__!./path?workerUrl=true"));
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { workerUrl as frameworkWorkerUrl } from 'fusion-core';
import workerUrl from 'workerURL';
workerUrl('./path');
frameworkWorkerUrl(require("__SECRET_WORKER_LOADER__!./path"));
frameworkWorkerUrl(require("__SECRET_WORKER_LOADER__!./path?workerUrl=true"));

0 comments on commit cc467da

Please sign in to comment.