Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-webpack-stats

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-webpack-stats - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1-beta.1

dist/index.js.map

0

dist/index.d.ts

@@ -0,0 +0,0 @@ import { Plugin } from 'rollup';

@@ -0,8 +1,88 @@

'use strict';
'use strict'
var path = require('path');
if (process.env.NODE_ENV === 'production') {
module.exports = require('./rollup-plugin-webpack-stats.cjs.production.min.js')
} else {
module.exports = require('./rollup-plugin-webpack-stats.cjs.development.js')
}
const getByteSize = (content) => {
if (typeof content === 'string') {
return Buffer.from(content).length;
}
return content?.length || 0;
};
const bundleToWebpackStats = (bundle, customOptions) => {
const options = {
moduleOriginalSize: false,
...customOptions,
};
const items = Object.values(bundle);
const assets = [];
const chunks = [];
const moduleByFileName = {};
items.forEach(item => {
if (item.type === 'chunk') {
assets.push({
name: item.fileName,
size: getByteSize(item.code),
});
const chunkId = item.name;
chunks.push({
id: chunkId,
entry: item.isEntry,
initial: !item.isDynamicEntry,
files: [item.fileName],
names: [item.name],
});
Object.entries(item.modules).forEach(([modulePath, moduleInfo]) => {
// Remove unexpected rollup null prefix
const normalizedModulePath = modulePath.replace('\u0000', '');
const relativeModulePath = path.relative(process.cwd(), normalizedModulePath);
// Match webpack output - add current directory prefix for child modules
const relativeModulePathWithPrefix = relativeModulePath.match(/^\.\./)
? relativeModulePath
: `.${path.sep}${relativeModulePath}`;
const moduleEntry = moduleByFileName[relativeModulePathWithPrefix];
if (moduleEntry) {
moduleEntry.chunks.push(chunkId);
}
else {
moduleByFileName[relativeModulePathWithPrefix] = {
name: relativeModulePathWithPrefix,
size: options.moduleOriginalSize
? moduleInfo.originalLength
: moduleInfo.renderedLength,
chunks: [chunkId],
};
}
});
}
else if (item.type === 'asset') {
assets.push({
name: item.fileName,
size: getByteSize(item.source.toString()),
});
}
else ;
});
return {
builtAt: Date.now(),
assets,
chunks,
modules: Object.values(moduleByFileName),
};
};
const NAME = 'webpackStats';
const webpackStats = (options = {}) => ({
name: NAME,
generateBundle(_, bundle) {
const output = bundleToWebpackStats(bundle, options);
this.emitFile({
type: 'asset',
fileName: options?.fileName || 'webpack-stats.json',
source: JSON.stringify(output),
});
},
});
exports.bundleToWebpackStats = bundleToWebpackStats;
exports.webpackStats = webpackStats;
//# sourceMappingURL=index.js.map

6

dist/transform.d.ts
import { OutputBundle } from 'rollup';
export declare type WebpackStatsFilteredAsset = {
export type WebpackStatsFilteredAsset = {
name: string;

@@ -32,3 +32,3 @@ size?: number;

}
export declare type BundleTransformOptions = {
export type BundleTransformOptions = {
/**

@@ -40,2 +40,2 @@ * Extract module original size or rendered size

};
export declare const bundleToWebpackStats: (bundle: OutputBundle, customOptions?: BundleTransformOptions | undefined) => WebpackStatsFiltered;
export declare const bundleToWebpackStats: (bundle: OutputBundle, customOptions?: BundleTransformOptions) => WebpackStatsFiltered;
{
"name": "rollup-plugin-webpack-stats",
"version": "0.2.0",
"version": "0.2.1-beta.1",
"private": false,

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

"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build",
"analyze": "size-limit --why"
"build": "rollup -c rollup.config.mjs",
"lint": "exit 0",
"test:unit": "vitest test/unit",
"test:package": "vitest test/package",
"bump": "./scripts/bump.sh",
"release": "./scripts/release.sh"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
"pre-commit": "npm run lint"
}

@@ -48,10 +48,14 @@ },

},
"module": "dist/rollup-plugin-webpack-stats.esm.js",
"devDependencies": {
"husky": "^8.0.3",
"rollup": "^3.10.0",
"size-limit": "^8.1.1",
"tsdx": "^0.14.1",
"tslib": "^2.4.1",
"typescript": "^4.9.4"
"@release-it/conventional-changelog": "7.0.0",
"@rollup/plugin-typescript": "11.1.3",
"@tsconfig/node14": "14.1.0",
"@types/node": "20.5.6",
"dotenv": "16.3.1",
"husky": "8.0.3",
"release-it": "16.1.5",
"rollup": "3.28.1",
"tslib": "2.6.2",
"typescript": "5.2.2",
"vitest": "0.34.3"
},

@@ -58,0 +62,0 @@ "peerDependencies": {

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