rollup-plugin-webpack-stats
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -7,3 +7,3 @@ 'use strict'; | ||
var path = _interopDefault(require('node:path')); | ||
var path = _interopDefault(require('path')); | ||
@@ -10,0 +10,0 @@ function _extends() { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("node:path"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var i=function(e){return"string"==typeof e?Buffer.from(e).length:(null==e?void 0:e.length)||0};exports.webpackStats=function(e){return void 0===e&&(e={}),{name:"webpackStats",generateBundle:function(r,a){var s,u=function(e,r){var a=n({moduleOriginalSize:!1},r),s=Object.values(e),u=[],o=[],l={};return s.forEach((function(e){if("chunk"===e.type){u.push({name:e.fileName,size:i(e.code)});var n=e.name;o.push({id:n,entry:e.isEntry,initial:!e.isDynamicEntry,files:[e.fileName],names:[e.name]}),Object.entries(e.modules).forEach((function(e){var i=e[0],r=e[1],s=t.relative(process.cwd(),i.replace("\0","")),u=l[s];u?u.chunks.push(n):l[s]={name:s,size:a.moduleOriginalSize?r.originalLength:r.renderedLength,chunks:[n]}}))}else"asset"===e.type&&u.push({name:e.fileName,size:i(e.source)})})),{assets:u,chunks:o,modules:Object.values(l)}}(a,e);this.emitFile({type:"asset",fileName:(null==(s=e)?void 0:s.fileName)||"webpack-stats.json",source:JSON.stringify(u)})}}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("path"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var i=function(e){return"string"==typeof e?Buffer.from(e).length:(null==e?void 0:e.length)||0};exports.webpackStats=function(e){return void 0===e&&(e={}),{name:"webpackStats",generateBundle:function(r,a){var s,u=function(e,r){var a=n({moduleOriginalSize:!1},r),s=Object.values(e),u=[],o=[],l={};return s.forEach((function(e){if("chunk"===e.type){u.push({name:e.fileName,size:i(e.code)});var n=e.name;o.push({id:n,entry:e.isEntry,initial:!e.isDynamicEntry,files:[e.fileName],names:[e.name]}),Object.entries(e.modules).forEach((function(e){var i=e[0],r=e[1],s=t.relative(process.cwd(),i.replace("\0","")),u=l[s];u?u.chunks.push(n):l[s]={name:s,size:a.moduleOriginalSize?r.originalLength:r.renderedLength,chunks:[n]}}))}else"asset"===e.type&&u.push({name:e.fileName,size:i(e.source)})})),{assets:u,chunks:o,modules:Object.values(l)}}(a,e);this.emitFile({type:"asset",fileName:(null==(s=e)?void 0:s.fileName)||"webpack-stats.json",source:JSON.stringify(u)})}}}; | ||
//# sourceMappingURL=rollup-plugin-webpack-stats.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
import path from 'node:path'; | ||
import path from 'path'; | ||
@@ -3,0 +3,0 @@ function _extends() { |
{ | ||
"name": "rollup-plugin-webpack-stats", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# rollup-plugin-webpack-stats | ||
> **Warning** | ||
Under active development | ||
> Under active development | ||
[![](https://img.shields.io/npm/v/rollup-plugin-webpack-stats.svg)](https://www.npmjs.com/package/rollup-plugin-webpack-stats) | ||
![](https://img.shields.io/node/v/rollup-plugin-webpack-stats.svg) | ||
[![CI](https://github.com/vio/rollup-plugin-webpack-stats/actions/workflows/main.yml/badge.svg)](https://github.com/vio/rollup-plugin-webpack-stats/actions/workflows/main.yml) | ||
Generate rollup stats JSON file with a [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli) webpack [supported sructure](https://github.com/relative-ci/bundle-stats/blob/master/packages/plugin-webpack-filter/src/index.ts). | ||
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). | ||
## Install | ||
## Install | ||
@@ -25,3 +26,2 @@ ```shell | ||
```js | ||
@@ -28,0 +28,0 @@ // rollup.config.js |
@@ -1,2 +0,2 @@ | ||
import path from 'node:path'; | ||
import path from 'path'; | ||
import { OutputBundle } from 'rollup'; | ||
@@ -8,3 +8,3 @@ | ||
size?: number; | ||
} | ||
}; | ||
@@ -30,3 +30,4 @@ export interface WebpackStatsFilteredChunk { | ||
export interface WebpackStatsFilteredRootModule extends WebpackStatsFilteredModule { | ||
export interface WebpackStatsFilteredRootModule | ||
extends WebpackStatsFilteredModule { | ||
modules?: Array<WebpackStatsFilteredConcatenatedModule>; | ||
@@ -59,3 +60,6 @@ } | ||
export const bundleToWebpackStats = (bundle: OutputBundle, customOptions?: BundleTransformOptions): WebpackStatsFiltered => { | ||
export const bundleToWebpackStats = ( | ||
bundle: OutputBundle, | ||
customOptions?: BundleTransformOptions | ||
): WebpackStatsFiltered => { | ||
const options = { | ||
@@ -73,3 +77,3 @@ moduleOriginalSize: false, | ||
items.forEach((item) => { | ||
items.forEach(item => { | ||
if (item.type === 'chunk') { | ||
@@ -92,3 +96,6 @@ assets.push({ | ||
Object.entries(item.modules).forEach(([modulePath, moduleInfo]) => { | ||
const relativeModulePath = path.relative(process.cwd(), modulePath.replace('\u0000', '')); | ||
const relativeModulePath = path.relative( | ||
process.cwd(), | ||
modulePath.replace('\u0000', '') | ||
); | ||
@@ -102,3 +109,5 @@ const moduleEntry = moduleByFileName[relativeModulePath]; | ||
name: relativeModulePath, | ||
size: options.moduleOriginalSize ? moduleInfo.originalLength : moduleInfo.renderedLength, | ||
size: options.moduleOriginalSize | ||
? moduleInfo.originalLength | ||
: moduleInfo.renderedLength, | ||
chunks: [chunkId], | ||
@@ -105,0 +114,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
35035
378