Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Make worker cacheable #19

Closed
sgrj opened this issue Feb 19, 2016 · 6 comments
Closed

Make worker cacheable #19

sgrj opened this issue Feb 19, 2016 · 6 comments

Comments

@sgrj
Copy link

sgrj commented Feb 19, 2016

Can the worker be made cacheable? I'm happy to create a pull request if it's possible.

@tobek
Copy link
Contributor

tobek commented Mar 13, 2017

Maybe this was fixed since this issue was opened, but the worker should be cacheable by browsers, if that's what you mean. By default the worker script produced is named with a content-dependent hash in it (e.g. 2e9912589ce947ab1cf5.worker.js).

If you override the output file name (e.g. require('worker-loader?name=output-name.js!./source-file.js')) then the hash is not included. However, you can use the text [hash] in the name, and it will be interpolated correctly. I've added this to the documentation with #53.

@renchap
Copy link
Contributor

renchap commented Mar 30, 2017

I think the issue comes from the output of webpack-dev-server for the worker file:

 [./app/workers/process_new_files.js] ./app/workers/process_new_files.js 61 kB {1} [not cacheable] [built]

The worker file is processed each time a source file is changed, even if it does not touch the worker source or a module it depends on via import.

@TrySound
Copy link
Contributor

@renchap If you will find a solution I will be glad to accept it :)

@renchap
Copy link
Contributor

renchap commented Mar 31, 2017

Unfortunately I have no idea what causes this, and I a quick glance has not helped, I am not very familiar with Webpack plugins internals. I was just trying to clarify the issue :)

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Jul 4, 2017

https://github.com/webpack-contrib/worker-loader/blob/master/index.js#L22 explicitly seems to disable caching for some reason, so the question is if this is required for the loader to work correctly :) ?

@renchap
Copy link
Contributor

renchap commented Jul 4, 2017

Looks like it has been added for Webpack 2 compat here: #24 by @dtinth, and confirmed it is needed by @sokra.

From what I understand, it creates 2 visible effects:

  • some additional output at each compilation
  • as a new name is generated for each compilation, this creates a lot of extra files in the output directory

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

No branches or pull requests

5 participants