Modifying URL in web worker chunk
See original GitHub issueI’m running to issues with an inline web worker with a dynamic import not being intercepted by this library. Since inline web workers are blobs and therefore need an absolute URL to successfully import scripts, I’m attempting to use this library to fix-up the URL.
e.g.
const md = await import(/* webpackChunkName: "markdown-it" */ 'markdown-it');
inside a web worker becomes something like
const md = await __webpack_require__.e(/* import() | markdown-it */ 2).then(__webpack_require__.t.bind(null, 264, 7));
which calls into
r.e = function(e) {
var n = [];
return n.push(Promise.resolve().then(function() {
t[e] || importScripts(e + ".ee0bc93119ec2d63cc28.worker.js")
})),
Promise.all(n)
}
Unfortunately, this isn’t prepending the path
it should be per the config below since it never actually results in the code below being called.
Object.defineProperty(r, "p", {
get: function() {
return "http://localhost:8080/"
}
}),
new WebpackRequireFrom({
path: 'http://localhost:8080/',
suppressErrors: true,
}),
(For now, I’ve used a hardcoded path
to see if I could get it minimally working. In practice, it would be a variable that is set similar to the advice in https://stackoverflow.com/a/22582695/1266600.)
Am I misunderstanding how something works or perhaps the intent of this library?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
how to change the output format of web worker files in ...
const workerUrl = new URL( /* webpackChunkName: 'pdf.worker' ... which I was able to control the output directory of the web worker bundle....
Read more >Web Workers | webpack - JS.ORG
As of webpack 5, you can use Web Workers without worker-loader . Syntax. new Worker(new URL('./worker.js', import.meta.url)); // or customize the chunk name ......
Read more >Inline worker in webpack 5 · Discussion #14066 - GitHub
I need to host all assets in CDN, but Web Worker requires the same domain policy. ... relative/path/to/my/worker.js?inline'), import.meta.url).
Read more >Develop Faster JS Apps: the Ultimate Guide to Web Workers
In this tutorial, we'll introduce web workers and demonstrate how you can use them to address execution speed issues. Contents:.
Read more >Using Web Workers - Web APIs - MDN Web Docs
Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Resolved by https://github.com/agoldis/webpack-require-from/releases/tag/v1.8.0
Great, I will roll out a new npm release later this week