NativeScript / worker-loader

36 stars 20 forks source link

Kddimitrov/fix worker loader cachable #48

Closed KristianDD closed 4 years ago

KristianDD commented 4 years ago

The worker loader was marked as non cachable - here, which caused a new child compilation and new emit on every change - source here.

When the cache disable is removed initially(after first compilation) the worker files are added as a dependency and watched, because the file dependencies of the child compilation are added to the fileDependencies of the parent compilation - here.

After the first change webpack doesn't find any module dependent on the files and the loader result is cached, so no child compilation is started. This results in that the watcher no longer is even watching the files - source here.

To fix this, we should take all file dependencies of the child compilation and add them to the file dependencies of the module. Now this method will mark the module as one that needs rebuild which will in turn invoke the loader logic.

Fixes https://github.com/NativeScript/worker-loader/issues/41