rollup-plugin-webpack-stats
Advanced tools
Comparing version 0.2.1 to 0.2.2-beta.0
'use strict'; | ||
var crypto = require('crypto'); | ||
var path = require('path'); | ||
const HASH_LENGTH = 7; | ||
const getByteSize = (content) => { | ||
@@ -11,2 +13,15 @@ if (typeof content === 'string') { | ||
}; | ||
const getHash = (text) => { | ||
const digest = crypto.createHash('sha256'); | ||
return digest.update(Buffer.from(text)).digest('hex').substr(0, HASH_LENGTH); | ||
}; | ||
const getChunkId = (chunk) => { | ||
let value = chunk.name; | ||
// Use entry module relative path | ||
if (chunk.moduleIds?.length > 0) { | ||
const absoluteModulePath = chunk.moduleIds[chunk.moduleIds.length - 1]; | ||
value = path.relative(process.cwd(), absoluteModulePath); | ||
} | ||
return getHash([chunk, value].join('-')); | ||
}; | ||
const bundleToWebpackStats = (bundle, customOptions) => { | ||
@@ -27,3 +42,3 @@ const options = { | ||
}); | ||
const chunkId = item.name; | ||
const chunkId = getChunkId(item); | ||
chunks.push({ | ||
@@ -30,0 +45,0 @@ id: chunkId, |
{ | ||
"name": "rollup-plugin-webpack-stats", | ||
"version": "0.2.1", | ||
"version": "0.2.2-beta.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,2 +9,3 @@ # rollup-plugin-webpack-stats | ||
[![ci](https://github.com/vio/rollup-plugin-webpack-stats/actions/workflows/ci.yml/badge.svg)](https://github.com/vio/rollup-plugin-webpack-stats/actions/workflows/ci.yml) | ||
[![Socket Badge](https://socket.dev/api/badge/npm/package/rollup-plugin-webpack-stats)](https://socket.dev/npm/package/rollup-plugin-webpack-stats) | ||
@@ -11,0 +12,0 @@ Generate rollup stats JSON file with a [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli) webpack [supported structure](https://github.com/relative-ci/bundle-stats/blob/master/packages/plugin-webpack-filter/src/index.ts). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16452
149
43
40552