question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR is not working for web workers

See original GitHub issue

Bug report

What is the current behavior?

When updating the code loaded by web worker nothing happens.

If the current behavior is a bug, please provide the steps to reproduce.

This is a very simple configuration where HMR doesn’t work: https://github.com/wclr/webpack-worker-hot-reload

What is the expected behavior?

I believe it should work the following way:

  1. If the worker’s entry script accepts hot reload, hot reload should be executed in the context of running web worker(s).
  2. Otherwise it should be upstreamed to the parent context (probably parent script where new URL of the worker script was created).

Other relevant information: webpack version: 5 Node.js version: 14 Operating System: Additional tools:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
donalffonscommented, May 23, 2022

if you want to help feel free to send a PR

Will do!

1reaction
alexander-akaitcommented, May 23, 2022

Here is a simple example that reproduces the error I had: ocjsx-hello-world-webpack-issue.zip @alexander-akait

Yep, bug, we should fix it, if you want to help feel free to send a PR

I’m not sure what would be the best way of doing that - maybe by writing some sort of Webpack Plugin?

Yep, a good question, ideally you need to pass path to worker as argument (you will faced with the same problem not only for webpack, for any other bundlers), multi compiler mode can be useful here too

Read more comments on GitHub >

github_iconTop Results From Across the Web

HMR with Angular running as a web worker with platform ...
I am attempting to implement a web worker based app using platformWorkerAppDynamic etc., but I am having some difficulties implementing HMR. If I...
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 >
Hot Module Replacement - SurviveJS
Hot Module Replacement (HMR) builds on top of the WDS. It enables an interface that makes it possible to swap modules live. For...
Read more >
Loading web workers using Webpack 5 · mmazzarolo.com
Web workers are restricted by a same-origin policy, so if your webpack assets are not being served from the same origin as your...
Read more >
Troubleshooting - Vite
The path to your project folder may include & , which doesn't work with npm on ... If HMR is not handled by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found