Skip to content

HMR doesn't work in projects that use Plugins that use workers #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shiv19 opened this issue Jul 12, 2019 · 5 comments · Fixed by #48
Closed

HMR doesn't work in projects that use Plugins that use workers #41

shiv19 opened this issue Jul 12, 2019 · 5 comments · Fixed by #48
Assignees
Labels

Comments

@shiv19
Copy link
Member

shiv19 commented Jul 12, 2019

EddyVerbruggen/nativescript-particle#7
NativeScript6 Particle Plugin HMR issue.zip

HMR doesn't work when using nativescript-particle plugin.

This problem did not exist in older versions of dev-webpack

@DimitarTachev
Copy link
Contributor

Hi @shiv19,

Thanks for reporting that!

In [email protected] we had an issue with the updates of static resources during HMR LiveSync. The CLI was always refrehing the application on HMR change and files like images, fonts and databases were not properly updated with HMR sync. In this way, the users were forced to stop the command and re-run it when they need to update such file.

In order to fix that, starting from [email protected] we are restarting the application when the Webpack process emits a file different than a hot update. In this way, the updates of static resources that are included in the app through the CopyWebpackPlugin are causing an app restart and the app is properly updated.

The issue with apps using the Worker plugin is caused by the following behavior:

  1. The Worker plugin is always emitting an additional file (__worker-chunks.json) in the Webpack compilation. This is not a hot update file and the CLI is restarting the app in order to apply it.
  2. The Worker loader is creating a child Webpack process for each worker file and these Webpack processes are emitting [hash].worker.js files. These files are also triggering an app restart as they are not hot updates.

In other words, the Worker plugin and loader should stop emitting these files on each change and we will move this issue in the Worker loader repository. Unfortunately, the above-mentioned point (2) does not have an easy fix and most probably it will be a known limitation for [email protected] till we release a better version of the Worker plugin.

@rosen-vladimirov rosen-vladimirov transferred this issue from NativeScript/nativescript-dev-webpack Jul 16, 2019
@AtoianAvetik
Copy link

AtoianAvetik commented Sep 16, 2019

Hi @DimitarTachev,
What you can say about this small plugin https://github.com/TrigenSoftware/hmr-filter-webpack-plugin, can it help as a workaround?
I tried to use it but nothing happens.

@DimitarTachev
Copy link
Contributor

Hi @AtoianAvetik,

Thanks for your help!

Unfortunately, this plugin won't change the problematic behavior as the Worker chunks are already excluded from the HMR updates (they are generated by another Webpack process). We need the opposite logic, the Worker chunks should be included in the hot updates in order to avoid the app restart. As I've already mentioned, this issue should be handled in the nativescript-worker-plugin itself, as it's spawning a child Webpack process with a custom config.

@AtoianAvetik
Copy link

@DimitarTachev, thanks for such a quick reply. Then we will wait for other news from you. Thanks!

@KristianDD
Copy link
Contributor

KristianDD commented Nov 19, 2019

**Acceptance criteria **
Initial setup:

  1. Download repository
  2. In demo-angular - npm i --save-exact nativescript-worker-loader@next
  • Changes in application files should trigger just refresh
  • Changes in worker(this and this) should trigger a restart of the application
  • Changes in shared modules, like this one, should trigger a restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants