Socket
Socket
Sign inDemoInstall

cache-loader

Package Overview
Dependencies
292
Maintainers
9
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 3.0.0

20

CHANGELOG.md

@@ -5,2 +5,22 @@ # Change Log

<a name="3.0.0"></a>
# [3.0.0](https://github.com/webpack-contrib/cache-loader/compare/v2.0.1...v3.0.0) (2019-04-19)
### Bug Fixes
* usage with raw loaders ([#69](https://github.com/webpack-contrib/cache-loader/issues/69)) ([4924341](https://github.com/webpack-contrib/cache-loader/commit/4924341))
### Features
* change default cache directory ([#64](https://github.com/webpack-contrib/cache-loader/issues/64)) ([fd1c6d7](https://github.com/webpack-contrib/cache-loader/commit/fd1c6d7))
### BREAKING CHANGES
* default cache directory is `node_modules/.cache/cache-loader`
<a name="2.0.1"></a>

@@ -7,0 +27,0 @@ ## [2.0.1](https://github.com/webpack-contrib/cache-loader/compare/v2.0.0...v2.0.1) (2019-01-04)

40

dist/index.js

@@ -8,2 +8,3 @@ "use strict";

exports.pitch = pitch;
exports.raw = void 0;

@@ -15,2 +16,4 @@ /* eslint-disable

const os = require('os');
const path = require('path');

@@ -26,2 +29,6 @@

const findCacheDir = require('find-cache-dir');
const BJSON = require('buffer-json');
const {

@@ -41,6 +48,9 @@ getOptions

cacheContext: '',
cacheDirectory: path.resolve('.cache-loader'),
cacheDirectory: findCacheDir({
name: 'cache-loader'
}) || os.tmpdir(),
cacheIdentifier: `cache-loader:${pkg.version} ${env}`,
cacheKey,
read,
readOnly: false,
write

@@ -65,4 +75,12 @@ };

const {
readOnly,
write: writeFn
} = options;
} = options; // In case we are under a readOnly mode on cache-loader
// we don't want to write or update any cache file
if (readOnly) {
this.callback(null, ...args);
return;
}
const callback = this.async();

@@ -133,2 +151,3 @@ const {

read: readFn,
readOnly,
cacheContext,

@@ -159,2 +178,10 @@ cacheKey: cacheKeyFn

return;
} // When we are under a readOnly config on cache-loader
// we don't want to emit any other error than a
// file stat error
if (readOnly) {
eachCallback();
return;
}

@@ -191,3 +218,3 @@

const dirname = path.dirname(key);
const content = JSON.stringify(data);
const content = BJSON.stringify(data);

@@ -218,3 +245,3 @@ if (directories.has(dirname)) {

try {
const data = JSON.parse(content);
const data = BJSON.parse(content);
callback(null, data);

@@ -234,2 +261,5 @@ } catch (e) {

return path.join(cacheDirectory, `${hash}.json`);
}
}
const raw = true;
exports.raw = raw;

@@ -19,2 +19,5 @@ {

},
"readOnly": {
"type": "boolean"
},
"write": {

@@ -21,0 +24,0 @@ "instanceof": "Function"

11

package.json
{
"name": "cache-loader",
"version": "2.0.1",
"version": "3.0.0",
"description": "Caches the result of following loaders on disk.",

@@ -22,3 +22,3 @@ "license": "MIT",

"prebuild": "npm run clean",
"prepublish": "npm run build",
"prepare": "npm run build",
"release": "standard-version",

@@ -42,2 +42,4 @@ "security": "npm audit",

"dependencies": {
"buffer-json": "^2.0.0",
"find-cache-dir": "^2.1.0",
"loader-utils": "^1.1.0",

@@ -59,3 +61,3 @@ "mkdirp": "^0.5.1",

"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.4",

@@ -69,4 +71,5 @@ "cross-env": "^5.0.0",

"eslint-plugin-prettier": "^3.0.0",
"file-loader": "^3.0.1",
"husky": "^1.2.1",
"jest": "^23.6.0",
"jest": "^24.5.0",
"lint-staged": "^8.1.0",

@@ -73,0 +76,0 @@ "memory-fs": "^0.4.1",

@@ -10,3 +10,3 @@ <div align="center">

[![deps][deps]][deps-url]
[![test][test]][test-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]

@@ -50,10 +50,11 @@ [![chat][chat]][chat-url]

| Name | Type | Default | Description |
| :-------------------: | :----------------------------------------------: | :---------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`cacheContext`** | `{String}` | `undefined` | Allows you to override the default cache context in order to generate the cache relatively to a path. By default it will use absolute paths |
| **`cacheKey`** | `{Function(options, request) -> {String}}` | `undefined` | Allows you to override default cache key generator |
| **`cacheDirectory`** | `{String}` | `path.resolve('.cache-loader')` | Provide a cache directory where cache items should be stored (used for default read/write implementation) |
| **`cacheIdentifier`** | `{String}` | `cache-loader:{version} {process.env.NODE_ENV}` | Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation) |
| **`write`** | `{Function(cacheKey, data, callback) -> {void}}` | `undefined` | Allows you to override default write cache data to file (e.g. Redis, memcached) |
| **`read`** | `{Function(cacheKey, callback) -> {void}}` | `undefined` | Allows you to override default read cache data from file |
| Name | Type | n Default | Description |
| :-------------------: | :----------------------------------------------: | :---------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`cacheContext`** | `{String}` | `undefined` | Allows you to override the default cache context in order to generate the cache relatively to a path. By default it will use absolute paths |
| **`cacheKey`** | `{Function(options, request) -> {String}}` | `undefined` | Allows you to override default cache key generator |
| **`cacheDirectory`** | `{String}` | `findCacheDir({ name: 'cache-loader' }) or os.tmpdir()` | Provide a cache directory where cache items should be stored (used for default read/write implementation) |
| **`cacheIdentifier`** | `{String}` | `cache-loader:{version} {process.env.NODE_ENV}` | Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation) |
| **`write`** | `{Function(cacheKey, data, callback) -> {void}}` | `undefined` | Allows you to override default write cache data to file (e.g. Redis, memcached) |
| **`read`** | `{Function(cacheKey, callback) -> {void}}` | `undefined` | Allows you to override default read cache data from file |
| **`readOnly`** | `{Boolean}` | `false` | Allows you to override default value and make the cache read only (useful for some environments where you don't want the cache to be updated, only read from it) |

@@ -60,0 +61,0 @@ ## Examples

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc