New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mokahr/cache-manage-plugin

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mokahr/cache-manage-plugin - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

CacheManagePlugin.js

@@ -9,4 +9,5 @@ "use strict";

this.options.cacheRecordPath = this.options.cacheRecordPath || 'node_modules/.cache';
this.options.maxAge = this.options.maxAge || 10000;
this.options.maxAge = this.options.maxAge || (1 * 24 * 60 * 60 * 1000);
this.options.cacheHash = this.options.cacheHash;
this.options.dependanceCachePaths = this.options.dependanceCachePaths || [];
this.recordPath = this.options.cacheRecordPath + 'cacheRecord.json';

@@ -35,3 +36,3 @@ this.apply = this.apply.bind(this);

var fullPath = _path + "/" + hash;
console.log('removepath', fullPath);
console.log('remove overdue cache', fullPath);
delete record[hash];

@@ -55,3 +56,2 @@ if (fs.existsSync(path.resolve(fullPath))) {

compiler.plugin('entryOption', function () {
console.log('begin');
var record = _this.getCacheRecord();

@@ -58,0 +58,0 @@ record = _this.removeOutTimeCache(record);

{
"name": "@mokahr/cache-manage-plugin",
"version": "1.0.0",
"description": "A webpack plugin used to mange dependencies loader/plugin cache",
"version": "1.0.1",
"description": "A webpack plugin used to mange muilti dependencies loader/plugin cache",
"main": "CacheManagePlugin.js",

@@ -11,3 +11,3 @@ "scripts": {

"type": "git",
"url": "git+https://github.com/southerncross/unused-webpack-plugin.git"
"url": "git+https://github.com/wYuanHpp/cache-manage-plugin.git"
},

@@ -17,5 +17,5 @@ "author": "wYuanHpp",

"bugs": {
"url": "https://github.com/southerncross/unused-webpack-plugin/issues"
"url": "https://github.com/wYuanHpp/cache-manage-plugin/issues"
},
"homepage": "https://github.com/southerncross/unused-webpack-plugin#readme",
"homepage": "https://github.com/wYuanHpp/cache-manage-plugin#readme",
"devDependencies": {

@@ -22,0 +22,0 @@ "@types/node": "^13.1.0",

@@ -1,6 +0,8 @@

# unused-webpack-plugin
# cache-manage-plugin
A Webpack plugin used to find unused source files
A Webpack plugin used to manage multiply cache Directory.
Manage different code caches based on the hash.
## Usage

@@ -10,3 +12,3 @@

`npm install --save-dev @mokahr/unused-webpack-plugin`
`npm install --save-dev @mokahr/cache-manage-plugin`

@@ -16,10 +18,24 @@ 2. Update webpack config file.

```js
const UnusedWebpackPlugin = require('@mokahr/unused-webpack-plugin');
const CacheManage = require('@mokahr/cache-manage-plugin');
const someHash = createHash();
// your webpack config
module.exports = {
module: {
rules: [
{
loader: 'babel-loader',
options: {
cacheDirectory: `node_modules/.cache/babel-loader/${someHash}`,
},
},
]
}
...
plugins: [
...
new UnusedWebpackPlugin(), // use the 'unused' plugin ;-)
new CacheManage({ // use
cacheHash: someHash,
dependanceCachePaths: [`node_modules/.cache/babel-loader/${someHash}`],
}),
]

@@ -29,31 +45,23 @@ }

3. Restart your webpack server and a new file named `unused-files` will be created under the project working directory.
## Configuration
```js
new UnusedWebpackPlugin(options)
new CacheManage(options)
```
### [optional] options.cwd: string
### [optional] options.cacheRecordPath: string
Current working directory, default value is `./`
cache directory, default value is `node_modules/.cache`
### [optional] options.patterns: string[]
### [optional] options.cacheHash: string
Included glob pattern list, default value is `['**/*.js', '**/*.styl']`, which means only .js or .styl files will be checked.
cacheHash mast provide;
Note: Usually not all the static assets are referenced in js files directly, such as some images or font files, therefore we do not recommend to use the pattern `*` directly, otherwise you may got some misleading results.
### [optional] options.maxAge: number
### [optional] options.ignores: string[]
cache max age, default value is `1 * 24 * 60 * 60 * 1000` one day
Excluded glob pattern list, default value is `['node_modules/**']`
### [optional] options.dependanceCachePaths:
### [optional] options.output: string
need to manage cache's cacheDirectory list, default value is `[]`
The result file path, default value is `./unused-files`
## Tips
- Please do not use this plugin on production environment.
- After generating unused files, you can remove them by shell command `cat unused-files | while read LINE; do rm $LINE; done`.
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