Socket
Socket
Sign inDemoInstall

cache-loader

Package Overview
Dependencies
Maintainers
9
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-loader - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

14

CHANGELOG.md

@@ -5,2 +5,16 @@ # Changelog

## [4.0.0](https://github.com/webpack-contrib/cache-loader/compare/v3.0.1...v4.0.0) (2019-06-05)
### chore
* **deps:** update ([#81](https://github.com/webpack-contrib/cache-loader/issues/81)) ([71e9e68](https://github.com/webpack-contrib/cache-loader/commit/71e9e68))
### BREAKING CHANGES
* **deps:** minimum required nodejs version is `8.9.0`
### [3.0.1](https://github.com/webpack-contrib/cache-loader/compare/v3.0.0...v3.0.1) (2019-05-13)

@@ -7,0 +21,0 @@

33

dist/index.js

@@ -48,2 +48,4 @@ "use strict";

cacheKey,
compare,
precision: 0,
read,

@@ -66,2 +68,6 @@ readOnly: false,

function roundMs(mtime, precision) {
return Math.floor(mtime / precision) * precision;
}
function loader(...args) {

@@ -145,6 +151,8 @@ const options = Object.assign({}, defaults, getOptions(this));

const {
cacheContext,
cacheKey: cacheKeyFn,
compare: compareFn,
read: readFn,
readOnly,
cacheContext,
cacheKey: cacheKeyFn
precision
} = options;

@@ -183,3 +191,18 @@ const callback = this.async();

if (stats.mtime.getTime() !== dep.mtime) {
const compStats = stats;
const compDep = dep;
if (precision > 1) {
['atime', 'mtime', 'ctime', 'birthtime'].forEach(key => {
const msKey = `${key}Ms`;
const ms = roundMs(stats[msKey], precision);
compStats[msKey] = ms;
compStats[key] = new Date(ms);
});
compDep.mtime = roundMs(dep.mtime, precision);
} // If the compare function returns false
// we not read from cache
if (compareFn(compStats, compDep) !== true) {
eachCallback(true);

@@ -256,3 +279,7 @@ return;

function compare(stats, dep) {
return stats.mtime.getTime() === dep.mtime;
}
const raw = true;
exports.raw = raw;

@@ -16,2 +16,8 @@ {

},
"compare": {
"instanceof": "Function"
},
"precision": {
"type": "number"
},
"read": {

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

51

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

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

"engines": {
"node": ">= 6.9.0"
"node": ">= 8.9.0"
},

@@ -18,14 +18,16 @@ "scripts": {

"prebuild": "npm run clean",
"build": "cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files",
"build": "cross-env NODE_ENV=production babel src -d dist --ignore \"src/**/*.test.js\" --copy-files",
"clean": "del-cli dist",
"commitlint": "commitlint --from=master",
"lint": "eslint --cache src test",
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different",
"lint:js": "eslint --cache src test",
"lint": "npm-run-all -l -p \"lint:**\"",
"prepare": "npm run build",
"release": "standard-version",
"security": "npm audit",
"test:only": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
"test:only": "cross-env NODE_ENV=test jest",
"test:watch": "cross-env NODE_ENV=test jest --watch",
"test:coverage": "cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage",
"pretest": "npm run lint",
"test": "npm run test:coverage",
"test": "cross-env NODE_ENV=test npm run test:coverage",
"defaults": "webpack-defaults"

@@ -41,3 +43,3 @@ },

"buffer-json": "^2.0.0",
"find-cache-dir": "^2.1.0",
"find-cache-dir": "^3.0.0",
"loader-utils": "^1.2.3",

@@ -50,28 +52,29 @@ "mkdirp": "^0.5.1",

"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@commitlint/cli": "^7.6.1",
"@commitlint/config-conventional": "^7.6.0",
"@webpack-contrib/defaults": "^4.0.1",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@webpack-contrib/defaults": "^5.0.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
"commitlint-azure-pipelines-cli": "^1.0.1",
"cross-env": "^5.0.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^5.2.0",
"del": "^4.1.1",
"del-cli": "^1.0.0",
"del-cli": "^2.0.0",
"eslint": "^5.16.0",
"eslint-plugin-import": "^2.17.2",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-prettier": "^3.1.0",
"file-loader": "^3.0.1",
"husky": "^2.2.0",
"file-loader": "^4.0.0",
"husky": "^2.4.0",
"jest": "^24.8.0",
"jest-junit": "^6.4.0",
"lint-staged": "^8.1.6",
"lint-staged": "^8.1.7",
"memory-fs": "^0.4.1",
"normalize-path": "^3.0.0",
"pre-commit": "^1.0.0",
"prettier": "^1.17.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.17.1",
"standard-version": "^6.0.1",
"webpack": "^4.31.0",
"webpack": "^4.33.0",
"webpack-cli": "^3.3.2"

@@ -78,0 +81,0 @@ },

@@ -55,5 +55,7 @@ <div align="center">

| **`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) |
| **`compare`** | `{Function(stats, dep) -> {Boolean}}` | `undefined` | Allows you to override default comparison function between the cached dependency and the one is being read. Return `true` to use the cached resource |
| **`precision`** | `{Number}` | `0` | Round `mtime` by this number of milliseconds both for `stats` and `dep` before passing those params to the comparing function |
| **`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) |
| **`write`** | `{Function(cacheKey, data, callback) -> {void}}` | `undefined` | Allows you to override default write cache data to file (e.g. Redis, memcached) |

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc