# cache-loader-hash

> Caches the result of following loaders on disk.

Latest version **4.1.6** (published 2020-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install cache-loader-hash
pnpm add cache-loader-hash
yarn add cache-loader-hash
bun add cache-loader-hash
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.6 |
| Published | 2020-06-12 |
| First published | 2020-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8.9.0 |
| Dependencies | 6 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Tobias Koppers @sokra |
| Maintainers | fxxjdedd |
| Keywords | webpack |

## Links

- npm: https://www.npmjs.com/package/cache-loader-hash
- Repository: https://github.com/fxxjdedd/cache-loader
- Issues: https://github.com/fxxjdedd/cache-loader/issues
- npm.io page: https://npm.io/package/cache-loader-hash

## Dependencies (6)

- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [neo-async](https://npm.io/package/neo-async.md) ^2.6.1
- [buffer-json](https://npm.io/package/buffer-json.md) ^2.0.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3
- [schema-utils](https://npm.io/package/schema-utils.md) ^2.0.0
- [find-cache-dir](https://npm.io/package/find-cache-dir.md) ^3.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 4.1.6 (latest) — 2020-06-12
- 4.1.5 — 2020-06-12
- 4.1.4 — 2020-05-09
- 4.1.3 — 2020-05-09
- 4.1.2 — 2020-05-08
- 4.1.1 — 2020-05-08
- 4.1.0 — 2020-05-08

## README

<div align="center">
  <a href="https://webpack.js.org/">
    <img width="200" height="200" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
  </a>
</div>

# cache-loader-hash

Added the mode option to the `cache-loader` options, supporting `mtime` (default) and `hash`.

# Usage

```bash
npm install cache-loader-hash --save-dev
```

```js
const CacheLoaderHash = require.resolve('@datafe/cache-loader-hash');
webpackChain.module.rules
  .values()
  .filter((rule) => rule.uses.has('cache-loader'))
  .forEach((rule) => {
    rule
      .use('cache-loader')
      .loader(CacheLoaderHash)
      .tap((options) => {
        options.mode = 'hash';
        return options;
      });
  });
```

# No Breaking Change

No breaking change when using `mtime` mode.

# Why

We are doing a CI package acceleration work, which will store `node_modules/.cache` on `s3`, and then pull it from `s3` at a certain time. due to
The cache-loader uses `mtime` by default for cache verification, which causes the newly installed node_modules in the new CI process to not match the `mtime` of `node_modules/.cache` on `s3`. The solution to this problem is to use the hash of the file instead of mtime as the cache verification method of the cache-loader.

# License

MIT

---
_Source: https://npm.io/package/cache-loader-hash · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
