rollup-plugin-webpack-stats 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.cts +1 -1
  3. package/dist/index.d.mts +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/{plugin.cjs → src/plugin.cjs} +2 -2
  6. package/dist/src/plugin.cjs.map +1 -0
  7. package/dist/{plugin.d.cts → src/plugin.d.cts} +1 -1
  8. package/dist/src/plugin.d.cts.map +1 -0
  9. package/dist/{plugin.d.mts → src/plugin.d.mts} +1 -1
  10. package/dist/src/plugin.d.mts.map +1 -0
  11. package/dist/{plugin.mjs → src/plugin.mjs} +1 -1
  12. package/dist/src/plugin.mjs.map +1 -0
  13. package/dist/src/types.d.cts.map +1 -0
  14. package/dist/src/types.d.mts.map +1 -0
  15. package/dist/{utils.cjs → src/utils.cjs} +1 -1
  16. package/dist/src/utils.cjs.map +1 -0
  17. package/dist/src/utils.mjs.map +1 -0
  18. package/dist/{write.cjs → src/write.cjs} +1 -1
  19. package/dist/src/write.cjs.map +1 -0
  20. package/dist/src/write.d.cts.map +1 -0
  21. package/dist/src/write.d.mts.map +1 -0
  22. package/dist/src/write.mjs.map +1 -0
  23. package/dist/transform.cjs +1 -1
  24. package/dist/transform.mjs +1 -1
  25. package/package.json +10 -10
  26. package/dist/plugin.cjs.map +0 -1
  27. package/dist/plugin.d.cts.map +0 -1
  28. package/dist/plugin.d.mts.map +0 -1
  29. package/dist/plugin.mjs.map +0 -1
  30. package/dist/types.d.cts.map +0 -1
  31. package/dist/types.d.mts.map +0 -1
  32. package/dist/utils.cjs.map +0 -1
  33. package/dist/utils.mjs.map +0 -1
  34. package/dist/write.cjs.map +0 -1
  35. package/dist/write.d.cts.map +0 -1
  36. package/dist/write.d.mts.map +0 -1
  37. package/dist/write.mjs.map +0 -1
  38. /package/dist/{types.d.cts → src/types.d.cts} +0 -0
  39. /package/dist/{types.d.mts → src/types.d.mts} +0 -0
  40. /package/dist/{utils.mjs → src/utils.mjs} +0 -0
  41. /package/dist/{write.d.cts → src/write.d.cts} +0 -0
  42. /package/dist/{write.d.mts → src/write.d.mts} +0 -0
  43. /package/dist/{write.mjs → src/write.mjs} +0 -0
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_plugin = require('./plugin.cjs');
1
+ const require_plugin = require('./src/plugin.cjs');
2
2
 
3
3
  //#region src/index.ts
4
4
  var src_default = require_plugin.webpackStats;
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { webpackStats } from "./plugin.cjs";
1
+ import { webpackStats } from "./src/plugin.cjs";
2
2
  export = webpackStats;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { webpackStats } from "./plugin.mjs";
1
+ import { webpackStats } from "./src/plugin.mjs";
2
2
  export { webpackStats as default };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { webpackStats } from "./plugin.mjs";
1
+ import { webpackStats } from "./src/plugin.mjs";
2
2
 
3
3
  //#region src/index.ts
4
4
  var src_default = webpackStats;
@@ -1,6 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_utils = require('./utils.cjs');
3
- const require_transform = require('./transform.cjs');
3
+ const require_transform = require('../transform.cjs');
4
4
  const require_write = require('./write.cjs');
5
5
  let rollup_plugin_stats_extract = require("rollup-plugin-stats/extract");
6
6
  rollup_plugin_stats_extract = require_runtime.__toESM(rollup_plugin_stats_extract);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","names":["statsWrite","bundleToWebpackStats","resolveFilepath","getByteSize","formatFileSize"],"sources":["../../src/plugin.ts"],"sourcesContent":["import extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n\nimport type { Plugin, OutputOptions } from './types';\nimport { type BundleTransformOptions, bundleToWebpackStats } from './transform';\nimport { type StatsWrite, statsWrite } from './write';\nimport { formatFileSize, getByteSize, resolveFilepath } from './utils';\n\nconst PLUGIN_NAME = 'webpackStats';\n\ntype WebpackStatsOptions = {\n /**\n * JSON file output fileName\n * default: webpack-stats.json\n */\n fileName?: string;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: StatsWrite;\n} & Omit<StatsOptions, 'source' | 'map'> &\n BundleTransformOptions;\n\ntype WebpackStatsOptionsOrBuilder =\n | WebpackStatsOptions\n | ((outputOptions: OutputOptions) => WebpackStatsOptions);\n\nexport const webpackStats = (\n options: WebpackStatsOptionsOrBuilder = {}\n): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(outputOptions, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(outputOptions) : options;\n const {\n fileName,\n excludeAssets,\n excludeModules,\n write = statsWrite,\n ...transformOptions\n } = resolvedOptions;\n\n const rollupStats = extractStats(bundle, {\n excludeAssets,\n excludeModules,\n // Extract stats source to compute size\n source: true,\n });\n const stats = bundleToWebpackStats(rollupStats, transformOptions);\n const filepath = resolveFilepath(fileName, outputOptions.dir);\n\n try {\n const res = await write(\n filepath,\n stats as unknown as Record<string, unknown>\n );\n const outputSize = getByteSize(res.content);\n\n this.info(\n `Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`\n );\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : JSON.stringify(error);\n\n // Log error, but do not throw to allow the compilation to continue\n this.warn(message);\n }\n },\n});\n"],"mappings":";;;;;;;;AAOA,MAAM,cAAc;AAoBpB,MAAa,gBACX,UAAwC,EAAE,MAC9B;CACZ,MAAM;CACN,MAAM,eAAe,eAAe,QAAQ;EAG1C,MAAM,EACJ,UACA,eACA,gBACA,QAAQA,0BACR,GAAG,qBANH,OAAO,YAAY,aAAa,QAAQ,cAAc,GAAG;EAe3D,MAAM,QAAQC,gFANmB,QAAQ;GACvC;GACA;GAEA,QAAQ;GACT,CAAC,EAC8C,iBAAiB;EACjE,MAAM,WAAWC,8BAAgB,UAAU,cAAc,IAAI;AAE7D,MAAI;GACF,MAAM,MAAM,MAAM,MAChB,UACA,MACD;GACD,MAAM,aAAaC,0BAAY,IAAI,QAAQ;AAE3C,QAAK,KACH,kBAAkB,IAAI,SAAS,IAAIC,6BAAe,WAAW,CAAC,GAC/D;WACM,OAAgB;GACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,QAAK,KAAK,QAAQ;;;CAGvB"}
@@ -1,5 +1,5 @@
1
1
  import { OutputOptions, Plugin } from "./types.cjs";
2
- import { BundleTransformOptions } from "./transform.cjs";
2
+ import { BundleTransformOptions } from "../transform.cjs";
3
3
  import { StatsWrite } from "./write.cjs";
4
4
  import { StatsOptions } from "rollup-plugin-stats/extract";
5
5
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;KASK,mBAAA;;AALiD;;;EAUpD,QAAA;EAMO;;;;EADP,KAAA,GAAQ,UAAA;AAAA,IACN,IAAA,CAAK,YAAA,sBACP,sBAAA;AAAA,KAEG,4BAAA,GACD,mBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,mBAAA;AAAA,cAE1B,YAAA,GACX,OAAA,GAAS,4BAAA,KACR,MAAA"}
@@ -1,5 +1,5 @@
1
1
  import { OutputOptions, Plugin } from "./types.mjs";
2
- import { BundleTransformOptions } from "./transform.mjs";
2
+ import { BundleTransformOptions } from "../transform.mjs";
3
3
  import { StatsWrite } from "./write.mjs";
4
4
  import { StatsOptions } from "rollup-plugin-stats/extract";
5
5
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;KASK,mBAAA;;AALiD;;;EAUpD,QAAA;EAMO;;;;EADP,KAAA,GAAQ,UAAA;AAAA,IACN,IAAA,CAAK,YAAA,sBACP,sBAAA;AAAA,KAEG,4BAAA,GACD,mBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,mBAAA;AAAA,cAE1B,YAAA,GACX,OAAA,GAAS,4BAAA,KACR,MAAA"}
@@ -1,5 +1,5 @@
1
1
  import { formatFileSize, getByteSize, resolveFilepath } from "./utils.mjs";
2
- import { bundleToWebpackStats } from "./transform.mjs";
2
+ import { bundleToWebpackStats } from "../transform.mjs";
3
3
  import { statsWrite } from "./write.mjs";
4
4
  import extractStats from "rollup-plugin-stats/extract";
5
5
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n\nimport type { Plugin, OutputOptions } from './types';\nimport { type BundleTransformOptions, bundleToWebpackStats } from './transform';\nimport { type StatsWrite, statsWrite } from './write';\nimport { formatFileSize, getByteSize, resolveFilepath } from './utils';\n\nconst PLUGIN_NAME = 'webpackStats';\n\ntype WebpackStatsOptions = {\n /**\n * JSON file output fileName\n * default: webpack-stats.json\n */\n fileName?: string;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: StatsWrite;\n} & Omit<StatsOptions, 'source' | 'map'> &\n BundleTransformOptions;\n\ntype WebpackStatsOptionsOrBuilder =\n | WebpackStatsOptions\n | ((outputOptions: OutputOptions) => WebpackStatsOptions);\n\nexport const webpackStats = (\n options: WebpackStatsOptionsOrBuilder = {}\n): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(outputOptions, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(outputOptions) : options;\n const {\n fileName,\n excludeAssets,\n excludeModules,\n write = statsWrite,\n ...transformOptions\n } = resolvedOptions;\n\n const rollupStats = extractStats(bundle, {\n excludeAssets,\n excludeModules,\n // Extract stats source to compute size\n source: true,\n });\n const stats = bundleToWebpackStats(rollupStats, transformOptions);\n const filepath = resolveFilepath(fileName, outputOptions.dir);\n\n try {\n const res = await write(\n filepath,\n stats as unknown as Record<string, unknown>\n );\n const outputSize = getByteSize(res.content);\n\n this.info(\n `Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`\n );\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : JSON.stringify(error);\n\n // Log error, but do not throw to allow the compilation to continue\n this.warn(message);\n }\n },\n});\n"],"mappings":";;;;;;AAOA,MAAM,cAAc;AAoBpB,MAAa,gBACX,UAAwC,EAAE,MAC9B;CACZ,MAAM;CACN,MAAM,eAAe,eAAe,QAAQ;EAG1C,MAAM,EACJ,UACA,eACA,gBACA,QAAQ,YACR,GAAG,qBANH,OAAO,YAAY,aAAa,QAAQ,cAAc,GAAG;EAe3D,MAAM,QAAQ,qBANM,aAAa,QAAQ;GACvC;GACA;GAEA,QAAQ;GACT,CAAC,EAC8C,iBAAiB;EACjE,MAAM,WAAW,gBAAgB,UAAU,cAAc,IAAI;AAE7D,MAAI;GACF,MAAM,MAAM,MAAM,MAChB,UACA,MACD;GACD,MAAM,aAAa,YAAY,IAAI,QAAQ;AAE3C,QAAK,KACH,kBAAkB,IAAI,SAAS,IAAI,eAAe,WAAW,CAAC,GAC/D;WACM,OAAgB;GACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,QAAK,KAAK,QAAQ;;;CAGvB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;KAMY,QAAA,GAAS,QAAA,GAAa,MAAA;AAAA,KACtB,eAAA,GAAgB,aAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;KAMY,QAAA,GAAS,QAAA,GAAa,MAAA;AAAA,KACtB,eAAA,GAAgB,aAAA"}
@@ -1,4 +1,4 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let node_path = require("node:path");
3
3
  node_path = require_runtime.__toESM(node_path);
4
4
  let node_crypto = require("node:crypto");
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","names":["crypto","path"],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport crypto from 'node:crypto';\nimport type { ChunkStats } from 'rollup-plugin-stats/extract';\n\nconst HASH_LENGTH = 7;\n\n/**\n * Get content byte size\n */\nexport function getByteSize(\n content?: string | Uint8Array<ArrayBufferLike>\n): number {\n if (!content) {\n return 0;\n }\n\n if (typeof content === 'string') {\n return Buffer.byteLength(content);\n }\n\n return content?.length || 0;\n}\n\n/**\n * Generate a 7 chars hash from a filepath\n */\nexport function getHash(filepath: string): string {\n const digest = crypto.createHash('sha256');\n return digest.update(filepath).digest('hex').substr(0, HASH_LENGTH);\n}\n\nexport function getChunkId(chunk: ChunkStats): string {\n let value = chunk.name;\n\n // Use entry module relative path\n if (chunk.moduleIds?.length > 0) {\n const absoluteModulePath = chunk.moduleIds[chunk.moduleIds.length - 1];\n value = path.relative(process.cwd(), absoluteModulePath);\n }\n\n return getHash([chunk, value].join('-'));\n}\n\ntype ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathOption =\n | ExcludeFilepathParam\n | Array<ExcludeFilepathParam>;\n\nexport function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier;\n}\n\nconst FILE_SIZE = {\n BYTE: {\n symbol: 'B',\n multiplier: 1,\n },\n KILO: {\n symbol: 'KiB',\n multiplier: 1024,\n },\n MEGA: {\n symbol: 'MiB',\n multiplier: 1024 * 1024,\n },\n};\n\nexport function formatFileSize(value?: number | null): string {\n let unit = FILE_SIZE.BYTE;\n\n if (typeof value !== 'number') {\n return `0${unit.symbol}`;\n }\n\n if (value < FILE_SIZE.KILO.multiplier) {\n unit = FILE_SIZE.BYTE;\n } else if (value < FILE_SIZE.MEGA.multiplier) {\n unit = FILE_SIZE.KILO;\n } else {\n unit = FILE_SIZE.MEGA;\n }\n\n return `${round(value / unit.multiplier, 2)}${unit.symbol}`;\n}\n\nconst DEFAULT_FILE_NAME = 'webpack-stats.json';\n\nexport function resolveFilepath(\n fileName = DEFAULT_FILE_NAME,\n outputDir?: string\n): string {\n // Check if the fileName is an absolute path\n if (path.isAbsolute(fileName)) {\n return fileName;\n }\n\n // If the fileName is not an absolute path, join it with the output directory or the current working directory\n return path.join(outputDir || process.cwd(), fileName);\n}\n"],"mappings":";;;;;;;AAIA,MAAM,cAAc;;;;AAKpB,SAAgB,YACd,SACQ;AACR,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO,OAAO,WAAW,QAAQ;AAGnC,QAAO,SAAS,UAAU;;;;;AAM5B,SAAgB,QAAQ,UAA0B;AAEhD,QADeA,oBAAO,WAAW,SAAS,CAC5B,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,GAAG,YAAY;;AAGrE,SAAgB,WAAW,OAA2B;CACpD,IAAI,QAAQ,MAAM;AAGlB,KAAI,MAAM,WAAW,SAAS,GAAG;EAC/B,MAAM,qBAAqB,MAAM,UAAU,MAAM,UAAU,SAAS;AACpE,UAAQC,kBAAK,SAAS,QAAQ,KAAK,EAAE,mBAAmB;;AAG1D,QAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,KAAK,IAAI,CAAC;;AAS1C,SAAgB,MAAM,OAAe,YAAY,GAAG;CAClD,MAAM,aAAa,KAAK;AACxB,QAAO,KAAK,MAAM,QAAQ,WAAW,GAAG;;AAG1C,MAAM,YAAY;CAChB,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY,OAAO;EACpB;CACF;AAED,SAAgB,eAAe,OAA+B;CAC5D,IAAI,OAAO,UAAU;AAErB,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,KAAK;AAGlB,KAAI,QAAQ,UAAU,KAAK,WACzB,QAAO,UAAU;UACR,QAAQ,UAAU,KAAK,WAChC,QAAO,UAAU;KAEjB,QAAO,UAAU;AAGnB,QAAO,GAAG,MAAM,QAAQ,KAAK,YAAY,EAAE,GAAG,KAAK;;AAGrD,MAAM,oBAAoB;AAE1B,SAAgB,gBACd,WAAW,mBACX,WACQ;AAER,KAAIA,kBAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,QAAOA,kBAAK,KAAK,aAAa,QAAQ,KAAK,EAAE,SAAS"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport crypto from 'node:crypto';\nimport type { ChunkStats } from 'rollup-plugin-stats/extract';\n\nconst HASH_LENGTH = 7;\n\n/**\n * Get content byte size\n */\nexport function getByteSize(\n content?: string | Uint8Array<ArrayBufferLike>\n): number {\n if (!content) {\n return 0;\n }\n\n if (typeof content === 'string') {\n return Buffer.byteLength(content);\n }\n\n return content?.length || 0;\n}\n\n/**\n * Generate a 7 chars hash from a filepath\n */\nexport function getHash(filepath: string): string {\n const digest = crypto.createHash('sha256');\n return digest.update(filepath).digest('hex').substr(0, HASH_LENGTH);\n}\n\nexport function getChunkId(chunk: ChunkStats): string {\n let value = chunk.name;\n\n // Use entry module relative path\n if (chunk.moduleIds?.length > 0) {\n const absoluteModulePath = chunk.moduleIds[chunk.moduleIds.length - 1];\n value = path.relative(process.cwd(), absoluteModulePath);\n }\n\n return getHash([chunk, value].join('-'));\n}\n\ntype ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathOption =\n | ExcludeFilepathParam\n | Array<ExcludeFilepathParam>;\n\nexport function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier;\n}\n\nconst FILE_SIZE = {\n BYTE: {\n symbol: 'B',\n multiplier: 1,\n },\n KILO: {\n symbol: 'KiB',\n multiplier: 1024,\n },\n MEGA: {\n symbol: 'MiB',\n multiplier: 1024 * 1024,\n },\n};\n\nexport function formatFileSize(value?: number | null): string {\n let unit = FILE_SIZE.BYTE;\n\n if (typeof value !== 'number') {\n return `0${unit.symbol}`;\n }\n\n if (value < FILE_SIZE.KILO.multiplier) {\n unit = FILE_SIZE.BYTE;\n } else if (value < FILE_SIZE.MEGA.multiplier) {\n unit = FILE_SIZE.KILO;\n } else {\n unit = FILE_SIZE.MEGA;\n }\n\n return `${round(value / unit.multiplier, 2)}${unit.symbol}`;\n}\n\nconst DEFAULT_FILE_NAME = 'webpack-stats.json';\n\nexport function resolveFilepath(\n fileName = DEFAULT_FILE_NAME,\n outputDir?: string\n): string {\n // Check if the fileName is an absolute path\n if (path.isAbsolute(fileName)) {\n return fileName;\n }\n\n // If the fileName is not an absolute path, join it with the output directory or the current working directory\n return path.join(outputDir || process.cwd(), fileName);\n}\n"],"mappings":";;;;AAIA,MAAM,cAAc;;;;AAKpB,SAAgB,YACd,SACQ;AACR,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO,OAAO,WAAW,QAAQ;AAGnC,QAAO,SAAS,UAAU;;;;;AAM5B,SAAgB,QAAQ,UAA0B;AAEhD,QADe,OAAO,WAAW,SAAS,CAC5B,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,GAAG,YAAY;;AAGrE,SAAgB,WAAW,OAA2B;CACpD,IAAI,QAAQ,MAAM;AAGlB,KAAI,MAAM,WAAW,SAAS,GAAG;EAC/B,MAAM,qBAAqB,MAAM,UAAU,MAAM,UAAU,SAAS;AACpE,UAAQ,KAAK,SAAS,QAAQ,KAAK,EAAE,mBAAmB;;AAG1D,QAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,KAAK,IAAI,CAAC;;AAS1C,SAAgB,MAAM,OAAe,YAAY,GAAG;CAClD,MAAM,aAAa,KAAK;AACxB,QAAO,KAAK,MAAM,QAAQ,WAAW,GAAG;;AAG1C,MAAM,YAAY;CAChB,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY,OAAO;EACpB;CACF;AAED,SAAgB,eAAe,OAA+B;CAC5D,IAAI,OAAO,UAAU;AAErB,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,KAAK;AAGlB,KAAI,QAAQ,UAAU,KAAK,WACzB,QAAO,UAAU;UACR,QAAQ,UAAU,KAAK,WAChC,QAAO,UAAU;KAEjB,QAAO,UAAU;AAGnB,QAAO,GAAG,MAAM,QAAQ,KAAK,YAAY,EAAE,GAAG,KAAK;;AAGrD,MAAM,oBAAoB;AAE1B,SAAgB,gBACd,WAAW,mBACX,WACQ;AAER,KAAI,KAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,QAAO,KAAK,KAAK,aAAa,QAAQ,KAAK,EAAE,SAAS"}
@@ -1,4 +1,4 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  let node_path = require("node:path");
3
3
  node_path = require_runtime.__toESM(node_path);
4
4
  let node_fs_promises = require("node:fs/promises");
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.cjs","names":["fs","path"],"sources":["../../src/write.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type StatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type StatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => StatsWriteResponse;\n\nexport async function statsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<StatsWriteResponse> {\n const content = JSON.stringify(stats, null, 2);\n\n // Create base directory if it does not exist\n await fs.mkdir(path.dirname(filepath), { recursive: true });\n\n await fs.writeFile(filepath, content);\n\n return {\n filepath,\n content,\n };\n}\n"],"mappings":";;;;;;;AAaA,eAAsB,WAEpB,UAAkB,OAAuC;CACzD,MAAM,UAAU,KAAK,UAAU,OAAO,MAAM,EAAE;AAG9C,OAAMA,yBAAG,MAAMC,kBAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AAE3D,OAAMD,yBAAG,UAAU,UAAU,QAAQ;AAErC,QAAO;EACL;EACA;EACD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.cts","names":[],"sources":["../../src/write.ts"],"mappings":";KAGY,kBAAA;EACV,QAAA;EACA,OAAA;AAAA;AAAA,KAGU,UAAA,IACV,QAAA,UACA,KAAA,EAAO,MAAA,sBACJ,kBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.mts","names":[],"sources":["../../src/write.ts"],"mappings":";KAGY,kBAAA;EACV,QAAA;EACA,OAAA;AAAA;AAAA,KAGU,UAAA,IACV,QAAA,UACA,KAAA,EAAO,MAAA,sBACJ,kBAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.mjs","names":[],"sources":["../../src/write.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type StatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type StatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => StatsWriteResponse;\n\nexport async function statsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<StatsWriteResponse> {\n const content = JSON.stringify(stats, null, 2);\n\n // Create base directory if it does not exist\n await fs.mkdir(path.dirname(filepath), { recursive: true });\n\n await fs.writeFile(filepath, content);\n\n return {\n filepath,\n content,\n };\n}\n"],"mappings":";;;;AAaA,eAAsB,WAEpB,UAAkB,OAAuC;CACzD,MAAM,UAAU,KAAK,UAAU,OAAO,MAAM,EAAE;AAG9C,OAAM,GAAG,MAAM,KAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AAE3D,OAAM,GAAG,UAAU,UAAU,QAAQ;AAErC,QAAO;EACL;EACA;EACD"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_utils = require('./utils.cjs');
3
+ const require_utils = require('./src/utils.cjs');
4
4
  let path = require("path");
5
5
  path = require_runtime.__toESM(path);
6
6
 
@@ -1,4 +1,4 @@
1
- import { getByteSize, getChunkId } from "./utils.mjs";
1
+ import { getByteSize, getChunkId } from "./src/utils.mjs";
2
2
  import path from "path";
3
3
 
4
4
  //#region src/transform.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rollup-plugin-webpack-stats",
3
3
  "description": "Rollup/Vite/Rolldown plugin to generate a stats JSON file with a bundle-stats webpack-compatible structure",
4
- "version": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -74,31 +74,31 @@
74
74
  "prepare": "husky"
75
75
  },
76
76
  "devDependencies": {
77
- "@release-it/conventional-changelog": "10.0.5",
78
- "@types/node": "25.3.3",
77
+ "@release-it/conventional-changelog": "10.0.6",
78
+ "@types/node": "25.5.0",
79
79
  "eslint": "9.39.2",
80
80
  "eslint-config-prettier": "10.1.8",
81
81
  "husky": "9.1.7",
82
- "lint-staged": "16.3.1",
83
- "memfs": "4.56.10",
82
+ "lint-staged": "16.3.3",
83
+ "memfs": "4.56.11",
84
84
  "prettier": "3.8.1",
85
85
  "release-it": "19.2.4",
86
86
  "rimraf": "6.1.3",
87
87
  "rollup": "4.59.0",
88
- "tsdown": "0.20.3",
88
+ "tsdown": "0.21.2",
89
89
  "tslib": "2.8.1",
90
90
  "typescript": "5.9.3",
91
- "typescript-eslint": "8.56.1",
91
+ "typescript-eslint": "8.57.0",
92
92
  "vite": "7.3.1",
93
- "vitest": "4.0.18"
93
+ "vitest": "4.1.0"
94
94
  },
95
95
  "dependencies": {
96
- "rollup-plugin-stats": "2.0.0"
96
+ "rollup-plugin-stats": "2.1.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "rolldown": "^1.0.0-beta.0",
100
100
  "rollup": "^3.0.0 || ^4.0.0",
101
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
101
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
102
102
  },
103
103
  "peerDependenciesMeta": {
104
104
  "rolldown": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.cjs","names":["statsWrite","bundleToWebpackStats","resolveFilepath","getByteSize","formatFileSize"],"sources":["../src/plugin.ts"],"sourcesContent":["import extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n\nimport type { Plugin, OutputOptions } from './types';\nimport { type BundleTransformOptions, bundleToWebpackStats } from './transform';\nimport { type StatsWrite, statsWrite } from './write';\nimport { formatFileSize, getByteSize, resolveFilepath } from './utils';\n\nconst PLUGIN_NAME = 'webpackStats';\n\ntype WebpackStatsOptions = {\n /**\n * JSON file output fileName\n * default: webpack-stats.json\n */\n fileName?: string;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: StatsWrite;\n} & Omit<StatsOptions, 'source' | 'map'> &\n BundleTransformOptions;\n\ntype WebpackStatsOptionsOrBuilder =\n | WebpackStatsOptions\n | ((outputOptions: OutputOptions) => WebpackStatsOptions);\n\nexport const webpackStats = (\n options: WebpackStatsOptionsOrBuilder = {}\n): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(outputOptions, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(outputOptions) : options;\n const {\n fileName,\n excludeAssets,\n excludeModules,\n write = statsWrite,\n ...transformOptions\n } = resolvedOptions;\n\n const rollupStats = extractStats(bundle, {\n excludeAssets,\n excludeModules,\n // Extract stats source to compute size\n source: true,\n });\n const stats = bundleToWebpackStats(rollupStats, transformOptions);\n const filepath = resolveFilepath(fileName, outputOptions.dir);\n\n try {\n const res = await write(\n filepath,\n stats as unknown as Record<string, unknown>\n );\n const outputSize = getByteSize(res.content);\n\n this.info(\n `Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`\n );\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : JSON.stringify(error);\n\n // Log error, but do not throw to allow the compilation to continue\n this.warn(message);\n }\n },\n});\n"],"mappings":";;;;;;;;AAOA,MAAM,cAAc;AAoBpB,MAAa,gBACX,UAAwC,EAAE,MAC9B;CACZ,MAAM;CACN,MAAM,eAAe,eAAe,QAAQ;EAG1C,MAAM,EACJ,UACA,eACA,gBACA,QAAQA,0BACR,GAAG,qBANH,OAAO,YAAY,aAAa,QAAQ,cAAc,GAAG;EAe3D,MAAM,QAAQC,gFANmB,QAAQ;GACvC;GACA;GAEA,QAAQ;GACT,CAAC,EAC8C,iBAAiB;EACjE,MAAM,WAAWC,8BAAgB,UAAU,cAAc,IAAI;AAE7D,MAAI;GACF,MAAM,MAAM,MAAM,MAChB,UACA,MACD;GACD,MAAM,aAAaC,0BAAY,IAAI,QAAQ;AAE3C,QAAK,KACH,kBAAkB,IAAI,SAAS,IAAIC,6BAAe,WAAW,CAAC,GAC/D;WACM,OAAgB;GACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,QAAK,KAAK,QAAQ;;;CAGvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;KASK,mBAAA;;AALiD;;;EAUpD,QAAA;EAMO;;;;EADP,KAAA,GAAQ,UAAA;AAAA,IACN,IAAA,CAAK,YAAA,sBACP,sBAAA;AAAA,KAEG,4BAAA,GACD,mBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,mBAAA;AAAA,cAE1B,YAAA,GACX,OAAA,GAAS,4BAAA,KACR,MAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;KASK,mBAAA;;AALiD;;;EAUpD,QAAA;EAMO;;;;EADP,KAAA,GAAQ,UAAA;AAAA,IACN,IAAA,CAAK,YAAA,sBACP,sBAAA;AAAA,KAEG,4BAAA,GACD,mBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,mBAAA;AAAA,cAE1B,YAAA,GACX,OAAA,GAAS,4BAAA,KACR,MAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n\nimport type { Plugin, OutputOptions } from './types';\nimport { type BundleTransformOptions, bundleToWebpackStats } from './transform';\nimport { type StatsWrite, statsWrite } from './write';\nimport { formatFileSize, getByteSize, resolveFilepath } from './utils';\n\nconst PLUGIN_NAME = 'webpackStats';\n\ntype WebpackStatsOptions = {\n /**\n * JSON file output fileName\n * default: webpack-stats.json\n */\n fileName?: string;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: StatsWrite;\n} & Omit<StatsOptions, 'source' | 'map'> &\n BundleTransformOptions;\n\ntype WebpackStatsOptionsOrBuilder =\n | WebpackStatsOptions\n | ((outputOptions: OutputOptions) => WebpackStatsOptions);\n\nexport const webpackStats = (\n options: WebpackStatsOptionsOrBuilder = {}\n): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(outputOptions, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(outputOptions) : options;\n const {\n fileName,\n excludeAssets,\n excludeModules,\n write = statsWrite,\n ...transformOptions\n } = resolvedOptions;\n\n const rollupStats = extractStats(bundle, {\n excludeAssets,\n excludeModules,\n // Extract stats source to compute size\n source: true,\n });\n const stats = bundleToWebpackStats(rollupStats, transformOptions);\n const filepath = resolveFilepath(fileName, outputOptions.dir);\n\n try {\n const res = await write(\n filepath,\n stats as unknown as Record<string, unknown>\n );\n const outputSize = getByteSize(res.content);\n\n this.info(\n `Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`\n );\n } catch (error: unknown) {\n const message =\n error instanceof Error ? error.message : JSON.stringify(error);\n\n // Log error, but do not throw to allow the compilation to continue\n this.warn(message);\n }\n },\n});\n"],"mappings":";;;;;;AAOA,MAAM,cAAc;AAoBpB,MAAa,gBACX,UAAwC,EAAE,MAC9B;CACZ,MAAM;CACN,MAAM,eAAe,eAAe,QAAQ;EAG1C,MAAM,EACJ,UACA,eACA,gBACA,QAAQ,YACR,GAAG,qBANH,OAAO,YAAY,aAAa,QAAQ,cAAc,GAAG;EAe3D,MAAM,QAAQ,qBANM,aAAa,QAAQ;GACvC;GACA;GAEA,QAAQ;GACT,CAAC,EAC8C,iBAAiB;EACjE,MAAM,WAAW,gBAAgB,UAAU,cAAc,IAAI;AAE7D,MAAI;GACF,MAAM,MAAM,MAAM,MAChB,UACA,MACD;GACD,MAAM,aAAa,YAAY,IAAI,QAAQ;AAE3C,QAAK,KACH,kBAAkB,IAAI,SAAS,IAAI,eAAe,WAAW,CAAC,GAC/D;WACM,OAAgB;GACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,QAAK,KAAK,QAAQ;;;CAGvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAMY,QAAA,GAAS,QAAA,GAAa,MAAA;AAAA,KACtB,eAAA,GAAgB,aAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAMY,QAAA,GAAS,QAAA,GAAa,MAAA;AAAA,KACtB,eAAA,GAAgB,aAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.cjs","names":["crypto","path"],"sources":["../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport crypto from 'node:crypto';\nimport type { ChunkStats } from 'rollup-plugin-stats/extract';\n\nconst HASH_LENGTH = 7;\n\n/**\n * Get content byte size\n */\nexport function getByteSize(\n content?: string | Uint8Array<ArrayBufferLike>\n): number {\n if (!content) {\n return 0;\n }\n\n if (typeof content === 'string') {\n return Buffer.byteLength(content);\n }\n\n return content?.length || 0;\n}\n\n/**\n * Generate a 7 chars hash from a filepath\n */\nexport function getHash(filepath: string): string {\n const digest = crypto.createHash('sha256');\n return digest.update(filepath).digest('hex').substr(0, HASH_LENGTH);\n}\n\nexport function getChunkId(chunk: ChunkStats): string {\n let value = chunk.name;\n\n // Use entry module relative path\n if (chunk.moduleIds?.length > 0) {\n const absoluteModulePath = chunk.moduleIds[chunk.moduleIds.length - 1];\n value = path.relative(process.cwd(), absoluteModulePath);\n }\n\n return getHash([chunk, value].join('-'));\n}\n\ntype ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathOption =\n | ExcludeFilepathParam\n | Array<ExcludeFilepathParam>;\n\nexport function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier;\n}\n\nconst FILE_SIZE = {\n BYTE: {\n symbol: 'B',\n multiplier: 1,\n },\n KILO: {\n symbol: 'KiB',\n multiplier: 1024,\n },\n MEGA: {\n symbol: 'MiB',\n multiplier: 1024 * 1024,\n },\n};\n\nexport function formatFileSize(value?: number | null): string {\n let unit = FILE_SIZE.BYTE;\n\n if (typeof value !== 'number') {\n return `0${unit.symbol}`;\n }\n\n if (value < FILE_SIZE.KILO.multiplier) {\n unit = FILE_SIZE.BYTE;\n } else if (value < FILE_SIZE.MEGA.multiplier) {\n unit = FILE_SIZE.KILO;\n } else {\n unit = FILE_SIZE.MEGA;\n }\n\n return `${round(value / unit.multiplier, 2)}${unit.symbol}`;\n}\n\nconst DEFAULT_FILE_NAME = 'webpack-stats.json';\n\nexport function resolveFilepath(\n fileName = DEFAULT_FILE_NAME,\n outputDir?: string\n): string {\n // Check if the fileName is an absolute path\n if (path.isAbsolute(fileName)) {\n return fileName;\n }\n\n // If the fileName is not an absolute path, join it with the output directory or the current working directory\n return path.join(outputDir || process.cwd(), fileName);\n}\n"],"mappings":";;;;;;;AAIA,MAAM,cAAc;;;;AAKpB,SAAgB,YACd,SACQ;AACR,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO,OAAO,WAAW,QAAQ;AAGnC,QAAO,SAAS,UAAU;;;;;AAM5B,SAAgB,QAAQ,UAA0B;AAEhD,QADeA,oBAAO,WAAW,SAAS,CAC5B,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,GAAG,YAAY;;AAGrE,SAAgB,WAAW,OAA2B;CACpD,IAAI,QAAQ,MAAM;AAGlB,KAAI,MAAM,WAAW,SAAS,GAAG;EAC/B,MAAM,qBAAqB,MAAM,UAAU,MAAM,UAAU,SAAS;AACpE,UAAQC,kBAAK,SAAS,QAAQ,KAAK,EAAE,mBAAmB;;AAG1D,QAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,KAAK,IAAI,CAAC;;AAS1C,SAAgB,MAAM,OAAe,YAAY,GAAG;CAClD,MAAM,aAAa,KAAK;AACxB,QAAO,KAAK,MAAM,QAAQ,WAAW,GAAG;;AAG1C,MAAM,YAAY;CAChB,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY,OAAO;EACpB;CACF;AAED,SAAgB,eAAe,OAA+B;CAC5D,IAAI,OAAO,UAAU;AAErB,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,KAAK;AAGlB,KAAI,QAAQ,UAAU,KAAK,WACzB,QAAO,UAAU;UACR,QAAQ,UAAU,KAAK,WAChC,QAAO,UAAU;KAEjB,QAAO,UAAU;AAGnB,QAAO,GAAG,MAAM,QAAQ,KAAK,YAAY,EAAE,GAAG,KAAK;;AAGrD,MAAM,oBAAoB;AAE1B,SAAgB,gBACd,WAAW,mBACX,WACQ;AAER,KAAIA,kBAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,QAAOA,kBAAK,KAAK,aAAa,QAAQ,KAAK,EAAE,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport crypto from 'node:crypto';\nimport type { ChunkStats } from 'rollup-plugin-stats/extract';\n\nconst HASH_LENGTH = 7;\n\n/**\n * Get content byte size\n */\nexport function getByteSize(\n content?: string | Uint8Array<ArrayBufferLike>\n): number {\n if (!content) {\n return 0;\n }\n\n if (typeof content === 'string') {\n return Buffer.byteLength(content);\n }\n\n return content?.length || 0;\n}\n\n/**\n * Generate a 7 chars hash from a filepath\n */\nexport function getHash(filepath: string): string {\n const digest = crypto.createHash('sha256');\n return digest.update(filepath).digest('hex').substr(0, HASH_LENGTH);\n}\n\nexport function getChunkId(chunk: ChunkStats): string {\n let value = chunk.name;\n\n // Use entry module relative path\n if (chunk.moduleIds?.length > 0) {\n const absoluteModulePath = chunk.moduleIds[chunk.moduleIds.length - 1];\n value = path.relative(process.cwd(), absoluteModulePath);\n }\n\n return getHash([chunk, value].join('-'));\n}\n\ntype ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathOption =\n | ExcludeFilepathParam\n | Array<ExcludeFilepathParam>;\n\nexport function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier;\n}\n\nconst FILE_SIZE = {\n BYTE: {\n symbol: 'B',\n multiplier: 1,\n },\n KILO: {\n symbol: 'KiB',\n multiplier: 1024,\n },\n MEGA: {\n symbol: 'MiB',\n multiplier: 1024 * 1024,\n },\n};\n\nexport function formatFileSize(value?: number | null): string {\n let unit = FILE_SIZE.BYTE;\n\n if (typeof value !== 'number') {\n return `0${unit.symbol}`;\n }\n\n if (value < FILE_SIZE.KILO.multiplier) {\n unit = FILE_SIZE.BYTE;\n } else if (value < FILE_SIZE.MEGA.multiplier) {\n unit = FILE_SIZE.KILO;\n } else {\n unit = FILE_SIZE.MEGA;\n }\n\n return `${round(value / unit.multiplier, 2)}${unit.symbol}`;\n}\n\nconst DEFAULT_FILE_NAME = 'webpack-stats.json';\n\nexport function resolveFilepath(\n fileName = DEFAULT_FILE_NAME,\n outputDir?: string\n): string {\n // Check if the fileName is an absolute path\n if (path.isAbsolute(fileName)) {\n return fileName;\n }\n\n // If the fileName is not an absolute path, join it with the output directory or the current working directory\n return path.join(outputDir || process.cwd(), fileName);\n}\n"],"mappings":";;;;AAIA,MAAM,cAAc;;;;AAKpB,SAAgB,YACd,SACQ;AACR,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,OAAO,YAAY,SACrB,QAAO,OAAO,WAAW,QAAQ;AAGnC,QAAO,SAAS,UAAU;;;;;AAM5B,SAAgB,QAAQ,UAA0B;AAEhD,QADe,OAAO,WAAW,SAAS,CAC5B,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,GAAG,YAAY;;AAGrE,SAAgB,WAAW,OAA2B;CACpD,IAAI,QAAQ,MAAM;AAGlB,KAAI,MAAM,WAAW,SAAS,GAAG;EAC/B,MAAM,qBAAqB,MAAM,UAAU,MAAM,UAAU,SAAS;AACpE,UAAQ,KAAK,SAAS,QAAQ,KAAK,EAAE,mBAAmB;;AAG1D,QAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,KAAK,IAAI,CAAC;;AAS1C,SAAgB,MAAM,OAAe,YAAY,GAAG;CAClD,MAAM,aAAa,KAAK;AACxB,QAAO,KAAK,MAAM,QAAQ,WAAW,GAAG;;AAG1C,MAAM,YAAY;CAChB,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY;EACb;CACD,MAAM;EACJ,QAAQ;EACR,YAAY,OAAO;EACpB;CACF;AAED,SAAgB,eAAe,OAA+B;CAC5D,IAAI,OAAO,UAAU;AAErB,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,KAAK;AAGlB,KAAI,QAAQ,UAAU,KAAK,WACzB,QAAO,UAAU;UACR,QAAQ,UAAU,KAAK,WAChC,QAAO,UAAU;KAEjB,QAAO,UAAU;AAGnB,QAAO,GAAG,MAAM,QAAQ,KAAK,YAAY,EAAE,GAAG,KAAK;;AAGrD,MAAM,oBAAoB;AAE1B,SAAgB,gBACd,WAAW,mBACX,WACQ;AAER,KAAI,KAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,QAAO,KAAK,KAAK,aAAa,QAAQ,KAAK,EAAE,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.cjs","names":["fs","path"],"sources":["../src/write.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type StatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type StatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => StatsWriteResponse;\n\nexport async function statsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<StatsWriteResponse> {\n const content = JSON.stringify(stats, null, 2);\n\n // Create base directory if it does not exist\n await fs.mkdir(path.dirname(filepath), { recursive: true });\n\n await fs.writeFile(filepath, content);\n\n return {\n filepath,\n content,\n };\n}\n"],"mappings":";;;;;;;AAaA,eAAsB,WAEpB,UAAkB,OAAuC;CACzD,MAAM,UAAU,KAAK,UAAU,OAAO,MAAM,EAAE;AAG9C,OAAMA,yBAAG,MAAMC,kBAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AAE3D,OAAMD,yBAAG,UAAU,UAAU,QAAQ;AAErC,QAAO;EACL;EACA;EACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.cts","names":[],"sources":["../src/write.ts"],"mappings":";KAGY,kBAAA;EACV,QAAA;EACA,OAAA;AAAA;AAAA,KAGU,UAAA,IACV,QAAA,UACA,KAAA,EAAO,MAAA,sBACJ,kBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.mts","names":[],"sources":["../src/write.ts"],"mappings":";KAGY,kBAAA;EACV,QAAA;EACA,OAAA;AAAA;AAAA,KAGU,UAAA,IACV,QAAA,UACA,KAAA,EAAO,MAAA,sBACJ,kBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.mjs","names":[],"sources":["../src/write.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type StatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type StatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => StatsWriteResponse;\n\nexport async function statsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<StatsWriteResponse> {\n const content = JSON.stringify(stats, null, 2);\n\n // Create base directory if it does not exist\n await fs.mkdir(path.dirname(filepath), { recursive: true });\n\n await fs.writeFile(filepath, content);\n\n return {\n filepath,\n content,\n };\n}\n"],"mappings":";;;;AAaA,eAAsB,WAEpB,UAAkB,OAAuC;CACzD,MAAM,UAAU,KAAK,UAAU,OAAO,MAAM,EAAE;AAG9C,OAAM,GAAG,MAAM,KAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AAE3D,OAAM,GAAG,UAAU,UAAU,QAAQ;AAErC,QAAO;EACL;EACA;EACD"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes