Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Do not rely on file mtime #34

Open
jdeniau opened this issue May 23, 2018 · 8 comments
Open

Do not rely on file mtime #34

jdeniau opened this issue May 23, 2018 · 8 comments

Comments

@jdeniau
Copy link

jdeniau commented May 23, 2018

npm 5.8+ set file mtime to October 1985 (See npm/npm#20439 ), it's a feature for them, so the cache-loader does not work anymore.

Furthermore, f24f723 tells to not trust file mtime.

Should we relly on file content hash instead ?

@alexander-akait
Copy link
Member

@jdeniau need tests mtime vs md4 from hash content. PR welcome 👍

@LukeSheard
Copy link

Maybe this could be slightly more generic, can supply a custom compare function for the comparison callback?

@luislobo
Copy link

👍 for the PR made by @LukeSheard

@bencoveney
Copy link

My diagnosis might not be correct, but I think this problem is impacting us as well. We have some custom loaders in our project written in TypeScript. When we run a build, we compile the TypeScript to JavaScript before running webpack - giving the custom loaders a new mtime. The loaders are added as dependencies by cache-loader, thus we can never get cached content.

Any chance the PR from @LukeSheard could be revived?

@sibelius
Copy link

is this fixed?

@alexander-akait
Copy link
Member

@sibelius no, cache-loader is low priority due webpack@5 will have built-in cache, anyway if you want to fix something PR welcome

@jdeniau
Copy link
Author

jdeniau commented Mar 11, 2020

For the record, I do not use cache-loader anymore, as webpack does a fine job now like @evilebottnawi said.

@scottrippey
Copy link

I attempted to workaround this by comparing based on ctime, but unfortunately only mtime is stored in the cache.

So ultimately, I went with the approach recommended in webpack's docs: use a postinstall hook to remove the node_modules/.cache/cache-loader folder.

https://webpack.js.org/guides/build-performance/#persistent-cache

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

No branches or pull requests

7 participants