Skip to content
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

cache does not work in watch mode #133

Closed
akosyakov opened this issue Sep 25, 2019 · 8 comments · Fixed by #159
Closed

cache does not work in watch mode #133

akosyakov opened this issue Sep 25, 2019 · 8 comments · Fixed by #159

Comments

@akosyakov
Copy link

akosyakov commented Sep 25, 2019

We are using code splitting in dev (watch) mode in order to avoid redownloading everything on page refresh but only changed bundles. But compression plugin keeps generating new compressed artifacts even for not changed bundles. I've tried to enable caching and it did not have any effect.

@akosyakov
Copy link
Author

akosyakov commented Sep 25, 2019

I see that record is found in the cache, but a new file is still emitted. So Express.js treats it as a new resource.

@alexander-akait
Copy link
Member

alexander-akait commented Sep 25, 2019

Please create minimum reproducible test repo

@akosyakov
Copy link
Author

@evilebottnawi Here you go: https://github.com/akosyakov/compression-webpack-with-watch

In order to reproduce:

  • run yarn in order to install dependencies and start watching
  • look at timestamps in lib folder for both bundles and gzipped archives
  • wait sometime
  • change client.js
  • look at timestamps again, bundle.js is not changed, but gzipped is changed

Here is a Gitpod snapshot to reproduce:
Open in Gitpod

compression

@akosyakov
Copy link
Author

@evilebottnawi does it look like an issue? Are you opened to a PR? What would be the proper solution? Skip emitting a new file if an original asset timestamp did not change?

@alexander-akait
Copy link
Member

A lot of issues, you can debug it and send a PR, sorry

akosyakov added a commit to theia-ide/compression-webpack-plugin that referenced this issue Oct 4, 2019
akosyakov added a commit to theia-ide/compression-webpack-plugin that referenced this issue Oct 11, 2019
akosyakov added a commit to theia-ide/compression-webpack-plugin that referenced this issue Oct 14, 2019
akosyakov added a commit to theia-ide/compression-webpack-plugin that referenced this issue Oct 14, 2019
akosyakov added a commit to theia-ide/compression-webpack-plugin that referenced this issue Oct 15, 2019
@ernestostifano
Copy link

For anyone getting here. A temporary solution, if writing a plugin is a possibility, is to collect and update effectively emitted assets paths on 'compiler.hooks.assetEmitted' hook and passing them to "compression-webpack-plugin" exclude option on each watch run. I'm currently doing that until this issue is fixed.

For additional information, please see this comment on relative PR.

@alexander-akait
Copy link
Member

alexander-akait commented Apr 29, 2020

There are several solution:

  • Implement on webpack side new API isAssetEmitted and skip files which already exists (ideally)
  • Cache our compressed assets in memory between compilations, now the cache option only for filesystem cache (sounds like hacky)
  • migrate on the assetEmitted hook (it can break assets manifest plugins)
  • migrate on the optimizeAssets hook (ideally for webpack@6), the main problem - a lot of plugins uses emit hook for adding new assets, but it is wrong, on emit hook plugins should not adding new assets. I think we will throw a warning for webpack@5/webpack@6 if a plugin added assets into emit hook

@alexander-akait
Copy link
Member

I need a little discussion with @sokra about it, in the near future I will find a solution, sorry for delay

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

Successfully merging a pull request may close this issue.

3 participants