rollup-plugin-stats 1.5.2-beta.0 → 1.5.3-beta.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 (54) hide show
  1. package/README.md +9 -8
  2. package/dist/cjs/extract.d.ts +2 -0
  3. package/dist/cjs/extract.js +1 -0
  4. package/dist/cjs/extract2.d.ts +56 -0
  5. package/dist/cjs/extract2.js +2 -0
  6. package/dist/cjs/extract2.js.map +1 -0
  7. package/dist/cjs/index.d.ts +32 -0
  8. package/dist/cjs/index.js +2 -0
  9. package/dist/cjs/index.js.map +1 -0
  10. package/dist/esm/extract.d.mts +2 -0
  11. package/dist/esm/extract.mjs +1 -0
  12. package/dist/esm/extract2.d.mts +56 -0
  13. package/dist/esm/extract2.mjs +2 -0
  14. package/dist/esm/extract2.mjs.map +1 -0
  15. package/dist/esm/index.d.mts +32 -0
  16. package/dist/esm/index.mjs +2 -0
  17. package/dist/esm/index.mjs.map +1 -0
  18. package/package.json +24 -32
  19. package/lib/cjs/extract.js +0 -66
  20. package/lib/cjs/extract.js.map +0 -1
  21. package/lib/cjs/index.js +0 -41
  22. package/lib/cjs/index.js.map +0 -1
  23. package/lib/cjs/utils/check-exclude-filepath.js +0 -30
  24. package/lib/cjs/utils/check-exclude-filepath.js.map +0 -1
  25. package/lib/cjs/utils/format-file-size.js +0 -37
  26. package/lib/cjs/utils/format-file-size.js.map +0 -1
  27. package/lib/cjs/utils/omit.js +0 -15
  28. package/lib/cjs/utils/omit.js.map +0 -1
  29. package/lib/cjs/utils/round.js +0 -9
  30. package/lib/cjs/utils/round.js.map +0 -1
  31. package/lib/cjs/write.js +0 -23
  32. package/lib/cjs/write.js.map +0 -1
  33. package/lib/esm/extract.js +0 -64
  34. package/lib/esm/extract.js.map +0 -1
  35. package/lib/esm/index.js +0 -34
  36. package/lib/esm/index.js.map +0 -1
  37. package/lib/esm/package.json +0 -1
  38. package/lib/esm/utils/check-exclude-filepath.js +0 -28
  39. package/lib/esm/utils/check-exclude-filepath.js.map +0 -1
  40. package/lib/esm/utils/format-file-size.js +0 -35
  41. package/lib/esm/utils/format-file-size.js.map +0 -1
  42. package/lib/esm/utils/omit.js +0 -13
  43. package/lib/esm/utils/omit.js.map +0 -1
  44. package/lib/esm/utils/round.js +0 -7
  45. package/lib/esm/utils/round.js.map +0 -1
  46. package/lib/esm/write.js +0 -16
  47. package/lib/esm/write.js.map +0 -1
  48. package/lib/types/extract.d.ts +0 -48
  49. package/lib/types/index.d.ts +0 -22
  50. package/lib/types/utils/check-exclude-filepath.d.ts +0 -7
  51. package/lib/types/utils/format-file-size.d.ts +0 -1
  52. package/lib/types/utils/omit.d.ts +0 -1
  53. package/lib/types/utils/round.d.ts +0 -1
  54. package/lib/types/write.d.ts +0 -6
package/README.md CHANGED
@@ -96,23 +96,24 @@ export default defineConfig({
96
96
 
97
97
  ## Related projects
98
98
 
99
- ### [rollup-plugin-webpack-stats](https://github.com/relative-ci/rollup-plugin-webpack-stats)
99
+ ### [bundle-stats](https://github.com/relative-ci/bundle-stats)
100
100
 
101
- 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).
101
+ Analyze bundle stats(bundle size, assets, modules, packages) and compare the results between different builds. Support for webpack, rspack, vite, rolldown and rollup.
102
102
 
103
- ### [bundle-stats](https://github.com/relative-ci/bundle-stats)
103
+ ### [rollup-plugin-webpack-stats](https://github.com/relative-ci/rollup-plugin-webpack-stats)
104
104
 
105
- Analyze webpack stats(bundle size, assets, modules, packages) and compare the results between different builds. Support for webpack, rspack, vite, rollup.
105
+ Generate vite/rollup/rolldown 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).
106
106
 
107
107
  ### :cyclone: [relative-ci.com](https://relative-ci.com?utm_medium=rollup-plugin-stats)
108
108
 
109
- #### Optimize your web app's performance with automated bundle stats analysis and monitoring.
109
+ #### Automated bundle analysis, reviews and monitoring - Quickly identify and fix bundle regressions before shipping to production.
110
110
 
111
111
  - :crystal_ball: In-depth bundle stats analysis for every build
112
112
  - :chart_with_upwards_trend: Monitor bundle stats changes and identify opportunities for optimizations
113
- - :bell: [Rule based automated review flow](https://relative-ci.com/documentation/setup/configure/integrations/github-commit-status-review?utm_medium=rollup-plugin-stats), or get notified via [GitHub Pull Request comments](https://relative-ci.com/documentation/setup/configure/integrations/github-pull-request-comment?utm_medium=rollup-plugin-stats), [GitHub check reports](https://relative-ci.com/documentation/setup/configure/integrations/github-check-report?utm_medium=rollup-plugin-stats) and [Slack messages](https://relative-ci.com/documentation/setup/configure/integrations/slack-notification?utm_medium=rollup-plugin-stats)
114
- - :wrench: Support for **webpack** and beta support for **Vite**/**Rollup**
113
+ - :bell: Quick feedback with [rule based automated review flow](https://relative-ci.com/documentation/setup/configure/integrations/github-commit-status-review?utm_medium=rollup-plugin-stats), [GitHub Pull Request comments](https://relative-ci.com/documentation/setup/configure/integrations/github-pull-request-comment?utm_medium=rollup-plugin-stats), [GitHub check reports](https://relative-ci.com/documentation/setup/configure/integrations/github-check-report?utm_medium=rollup-plugin-stats), or [Slack messages](https://relative-ci.com/documentation/setup/configure/integrations/slack-notification?utm_medium=rollup-plugin-stats)
114
+ - :wrench: Support for **webpack**, **vite**, **rspack**, **rollup**, **rolldown**
115
115
  - :hammer: Support for all major CI services(CircleCI, GitHub Actions, Gitlab CI, Jenkins, Travis CI)
116
116
  - :nut_and_bolt: Support for **npm**, **yarn** and **pnpm**; support for monorepos
117
- - :two_hearts: **Always free** for **Open Source**
117
+ - :two_hearts: [**Always free** for **Open Source**](https://relative-ci.com/open-source?utm_medium=rollup-plugin-stats)
118
118
 
119
+ [:rocket: Get started](https://relative-ci.com?utm_medium=rollup-plugin-stats)
@@ -0,0 +1,2 @@
1
+ import { a as ModuleStats, c as StatsOptions, i as ChunkStatsOptionalProperties, l as extractRollupStats, n as AssetStatsOptionalProperties, o as ModuleStatsOptionalProperties, r as ChunkStats, s as Stats, t as AssetStats } from "./extract2.js";
2
+ export { AssetStats, AssetStatsOptionalProperties, ChunkStats, ChunkStatsOptionalProperties, ModuleStats, ModuleStatsOptionalProperties, Stats, StatsOptions, extractRollupStats as default };
@@ -0,0 +1 @@
1
+ const e=require(`./extract2.js`);module.exports=e.t;
@@ -0,0 +1,56 @@
1
+ import { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from "rollup";
2
+
3
+ //#region src/utils/check-exclude-filepath.d.ts
4
+ type ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);
5
+ type ExcludeFilepathPatterns = ExcludeFilepathParam | Array<ExcludeFilepathParam>;
6
+ //#endregion
7
+ //#region src/extract.d.ts
8
+ type AssetStatsOptionalProperties = {
9
+ source?: OutputAsset['source'];
10
+ };
11
+ type AssetStats = Omit<OutputAsset, keyof AssetStatsOptionalProperties> & AssetStatsOptionalProperties;
12
+ type ModuleStatsOptionalProperties = {
13
+ code?: RenderedModule['code'] | null;
14
+ };
15
+ type ModuleStats = Omit<RenderedModule, keyof ModuleStatsOptionalProperties> & ModuleStatsOptionalProperties;
16
+ type ChunkStatsOptionalProperties = {
17
+ code?: OutputChunk['code'];
18
+ map?: OutputChunk['map'];
19
+ };
20
+ type ChunkStats = Omit<OutputChunk, keyof ChunkStatsOptionalProperties | 'modules'> & {
21
+ modules: Record<string, ModuleStats>;
22
+ } & ChunkStatsOptionalProperties;
23
+ type Stats = Record<string, AssetStats | ChunkStats>;
24
+ type StatsOptions = {
25
+ /**
26
+ * Output asset/module sources
27
+ * @default false
28
+ */
29
+ source?: boolean;
30
+ /**
31
+ * Output chunk map
32
+ * @default false
33
+ */
34
+ map?: boolean;
35
+ /**
36
+ * Exclude matching assets
37
+ */
38
+ excludeAssets?: ExcludeFilepathPatterns;
39
+ /**
40
+ * Exclude matching modules
41
+ */
42
+ excludeModules?: ExcludeFilepathPatterns;
43
+ };
44
+ /**
45
+ * Extract bundler stats
46
+ *
47
+ * Shallow clone stats object before any processing using `omit` to
48
+ * 1. resolve getters
49
+ * 2. prevent changes to the stats object
50
+ *
51
+ * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128
52
+ */
53
+ declare function extractRollupStats(bundle: OutputBundle, options?: StatsOptions): Stats;
54
+ //#endregion
55
+ export { ModuleStats as a, StatsOptions as c, ChunkStatsOptionalProperties as i, extractRollupStats as l, AssetStatsOptionalProperties as n, ModuleStatsOptionalProperties as o, ChunkStats as r, Stats as s, AssetStats as t };
56
+ //# sourceMappingURL=extract2.d.ts.map
@@ -0,0 +1,2 @@
1
+ function e(e,t){let n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n}function t(e,n){if(!n)return!1;if(Array.isArray(n)){let r=!1;for(let i=0;i<=n.length-1&&r===!1;i++)r=t(e,n[i]);return r}return typeof n==`function`?n(e):typeof n==`string`?!!e.match(n):`test`in n?n.test(e):!1}function n(n,r={}){let{source:i=!1,map:a=!1,excludeAssets:o,excludeModules:s}=r,c={};return Object.entries(n).forEach(([n,r])=>{if(!t(n,o)){if(r.type===`asset`){let t=[];i||t.push(`source`),c[n]=e(r,t);return}if(r.type===`chunk`){let o=[];i||o.push(`code`),a||o.push(`map`);let l=e(r,o),u={};Object.entries(l.modules).forEach(([n,r])=>{if(t(n,s))return;let a=[];i||a.push(`code`),u[n]=e(r,a)}),l.modules=u,c[n]=l;return}}}),c}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
2
+ //# sourceMappingURL=extract2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract2.js","names":["output: Stats","assetStatsOmitKeys: Array<keyof AssetStatsOptionalProperties>","chunkStatsOmitKeys: Array<keyof ChunkStatsOptionalProperties>","chunkModulesStats: ChunkStats['modules']","moduleStatsOmitKeys: Array<keyof ModuleStatsOptionalProperties>"],"sources":["../../src/utils/omit.ts","../../src/utils/check-exclude-filepath.ts","../../src/extract.ts"],"sourcesContent":["export function omit<D extends object, K extends keyof D = keyof D>(\n data: D,\n keys: K[],\n): Omit<D, K> {\n const result = {} as D;\n const objectKeys = Object.keys(data) as Array<K>;\n\n objectKeys.forEach((key) => {\n if (!keys.includes(key)) {\n result[key] = data[key];\n }\n });\n\n return result;\n}\n","type ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathPatterns = ExcludeFilepathParam | Array<ExcludeFilepathParam>;\n\n/**\n * Check if filepath should be excluded based on patterns\n */\nexport function checkExcludeFilepath(\n filepath: string,\n patterns?: ExcludeFilepathPatterns,\n): boolean {\n if (!patterns) {\n return false;\n }\n\n if (Array.isArray(patterns)) {\n let res = false;\n\n for (let i = 0; i <= patterns.length - 1 && res === false; i++) {\n res = checkExcludeFilepath(filepath, patterns[i]);\n }\n\n return res;\n }\n\n if (typeof patterns === 'function') {\n return patterns(filepath);\n }\n\n if (typeof patterns === 'string') {\n return Boolean(filepath.match(patterns));\n }\n\n if ('test' in patterns) {\n return patterns.test(filepath);\n }\n\n return false;\n}\n","import type { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from 'rollup';\nimport { omit } from './utils/omit';\nimport { type ExcludeFilepathPatterns, checkExcludeFilepath } from './utils/check-exclude-filepath';\n\nexport type AssetStatsOptionalProperties = {\n source?: OutputAsset['source'];\n};\n\nexport type AssetStats = Omit<OutputAsset, keyof AssetStatsOptionalProperties> & AssetStatsOptionalProperties;\n\nexport type ModuleStatsOptionalProperties = {\n code?: RenderedModule['code'] | null;\n};\n\nexport type ModuleStats = Omit<RenderedModule, keyof ModuleStatsOptionalProperties> & ModuleStatsOptionalProperties;\n\nexport type ChunkStatsOptionalProperties = {\n code?: OutputChunk['code'];\n map?: OutputChunk['map']; \n};\n\nexport type ChunkStats = Omit<OutputChunk, keyof ChunkStatsOptionalProperties | 'modules'> & {\n modules: Record<string, ModuleStats>;\n} & ChunkStatsOptionalProperties;\n\nexport type Stats = Record<string, AssetStats | ChunkStats>;\n\nexport type StatsOptions = {\n /**\n * Output asset/module sources\n * @default false \n */\n source?: boolean;\n /**\n * Output chunk map\n * @default false \n */\n map?: boolean;\n /**\n * Exclude matching assets\n */\n excludeAssets?: ExcludeFilepathPatterns;\n /**\n * Exclude matching modules\n */\n excludeModules?: ExcludeFilepathPatterns;\n}\n\n/**\n * Extract bundler stats\n *\n * Shallow clone stats object before any processing using `omit` to\n * 1. resolve getters\n * 2. prevent changes to the stats object\n *\n * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128\n */\nexport default function extractRollupStats(bundle: OutputBundle, options: StatsOptions = {}): Stats {\n const { source = false, map = false, excludeAssets, excludeModules } = options;\n\n const output: Stats = {};\n\n Object.entries(bundle).forEach(([bundleEntryFilepath, bundleEntryStats]) => {\n // Skip extraction if the entry filepath matches the exclude assets pattern\n if (checkExcludeFilepath(bundleEntryFilepath, excludeAssets)) {\n return;\n }\n\n if (bundleEntryStats.type === \"asset\") {\n const assetStatsOmitKeys: Array<keyof AssetStatsOptionalProperties> = [];\n\n // Skip asset source if options.source is false\n if (!source) {\n assetStatsOmitKeys.push('source'); \n }\n\n output[bundleEntryFilepath] = omit(\n bundleEntryStats,\n assetStatsOmitKeys,\n ) as AssetStats;\n\n return;\n }\n\n if (bundleEntryStats.type === \"chunk\") {\n const chunkStatsOmitKeys: Array<keyof ChunkStatsOptionalProperties> = [];\n\n // Skip chunk source if options.source is false\n if (!source) {\n chunkStatsOmitKeys.push('code');\n }\n\n // Skip chunk map if options.map is false\n if (!map) {\n chunkStatsOmitKeys.push('map');\n }\n\n const chunkStats = omit(bundleEntryStats, chunkStatsOmitKeys) as ChunkStats;\n\n\n // Extract chunk modules stats\n const chunkModulesStats: ChunkStats['modules'] = {};\n\n Object.entries(chunkStats.modules).forEach(([bundleModuleFilepath, bundleModuleStats]) => {\n // Skip module extraction if the filepath matches the exclude modules pattern\n if (checkExcludeFilepath(bundleModuleFilepath, excludeModules)) {\n return;\n }\n\n const moduleStatsOmitKeys: Array<keyof ModuleStatsOptionalProperties> = [];\n\n // Skip module source if options.source is false\n if (!source) {\n moduleStatsOmitKeys.push('code');\n }\n\n chunkModulesStats[bundleModuleFilepath] = omit(\n bundleModuleStats,\n moduleStatsOmitKeys,\n ) as ModuleStats;\n });\n\n chunkStats.modules = chunkModulesStats;\n\n output[bundleEntryFilepath] = chunkStats;\n\n return;\n }\n });\n \n return output;\n}\n"],"mappings":"AAAA,SAAgB,EACd,EACA,EACY,CACZ,IAAM,EAAS,EAAE,CASjB,OARmB,OAAO,KAAK,EAAK,CAEzB,QAAS,GAAQ,CACrB,EAAK,SAAS,EAAI,GACrB,EAAO,GAAO,EAAK,KAErB,CAEK,ECNT,SAAgB,EACd,EACA,EACS,CACT,GAAI,CAAC,EACH,MAAO,GAGT,GAAI,MAAM,QAAQ,EAAS,CAAE,CAC3B,IAAI,EAAM,GAEV,IAAK,IAAI,EAAI,EAAG,GAAK,EAAS,OAAS,GAAK,IAAQ,GAAO,IACzD,EAAM,EAAqB,EAAU,EAAS,GAAG,CAGnD,OAAO,EAeT,OAZI,OAAO,GAAa,WACf,EAAS,EAAS,CAGvB,OAAO,GAAa,SACf,EAAQ,EAAS,MAAM,EAAS,CAGrC,SAAU,EACL,EAAS,KAAK,EAAS,CAGzB,GCoBT,SAAwB,EAAmB,EAAsB,EAAwB,EAAE,CAAS,CAClG,GAAM,CAAE,SAAS,GAAO,MAAM,GAAO,gBAAe,kBAAmB,EAEjEA,EAAgB,EAAE,CAsExB,OApEA,OAAO,QAAQ,EAAO,CAAC,SAAS,CAAC,EAAqB,KAAsB,CAEtE,MAAqB,EAAqB,EAAc,CAI5D,IAAI,EAAiB,OAAS,QAAS,CACrC,IAAMC,EAAgE,EAAE,CAGnE,GACH,EAAmB,KAAK,SAAS,CAGnC,EAAO,GAAuB,EAC5B,EACA,EACD,CAED,OAGF,GAAI,EAAiB,OAAS,QAAS,CACrC,IAAMC,EAAgE,EAAE,CAGnE,GACH,EAAmB,KAAK,OAAO,CAI5B,GACH,EAAmB,KAAK,MAAM,CAGhC,IAAM,EAAa,EAAK,EAAkB,EAAmB,CAIvDC,EAA2C,EAAE,CAEnD,OAAO,QAAQ,EAAW,QAAQ,CAAC,SAAS,CAAC,EAAsB,KAAuB,CAExF,GAAI,EAAqB,EAAsB,EAAe,CAC5D,OAGF,IAAMC,EAAkE,EAAE,CAGrE,GACH,EAAoB,KAAK,OAAO,CAGlC,EAAkB,GAAwB,EACxC,EACA,EACD,EACD,CAEF,EAAW,QAAU,EAErB,EAAO,GAAuB,EAE9B,UAEF,CAEK"}
@@ -0,0 +1,32 @@
1
+ import { c as StatsOptions } from "./extract2.js";
2
+ import { OutputOptions, Plugin } from "rollup";
3
+
4
+ //#region src/write.d.ts
5
+ type RollupStatsWriteResponse = {
6
+ filepath: string;
7
+ content: string;
8
+ };
9
+ type RollupStatsWrite = (filepath: string, stats: Record<string, unknown>) => RollupStatsWriteResponse;
10
+ //#endregion
11
+ //#region src/index.d.ts
12
+ type RollupStatsOptions = {
13
+ /**
14
+ * Output filename relative to Rollup output directory or absolute
15
+ * @default: stats.json
16
+ */
17
+ fileName?: string;
18
+ /**
19
+ * Rollup stats options
20
+ */
21
+ stats?: StatsOptions;
22
+ /**
23
+ * Custom file writer
24
+ * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
25
+ */
26
+ write?: RollupStatsWrite;
27
+ };
28
+ type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
29
+ declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
30
+ //#endregion
31
+ export { RollupStatsOptions, rollupStats as default };
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./extract2.js`);let l=require(`node:path`);l=s(l);let u=require(`node:process`);u=s(u);let d=require(`node:fs/promises`);d=s(d);async function f(e,t){let n=JSON.stringify(t,null,2);return await d.default.mkdir(l.default.dirname(e),{recursive:!0}),await d.default.writeFile(e,n),{filepath:e,content:n}}function p(e,t=2){let n=10^t;return Math.round(e*n)/n}const m={BYTE:{symbol:`B`,multiplier:1},KILO:{symbol:`KiB`,multiplier:1024},MEGA:{symbol:`MiB`,multiplier:1024*1024}};function h(e){let t=m.BYTE;return typeof e==`number`?(t=e<m.KILO.multiplier?m.BYTE:e<m.MEGA.multiplier?m.KILO:m.MEGA,`${p(e/t.multiplier,2)}${t.symbol}`):`0${t.symbol}`}const g=`rollupStats`,_=`stats.json`;function v(e={}){return{name:`rollupStats`,async generateBundle(t,n){let{fileName:r,stats:i,write:a=f}=(typeof e==`function`?e(t):e)||{},o=r||`stats.json`,s=l.default.isAbsolute(o)?o:l.default.join(t.dir||u.default.cwd(),o),d=c.t(n,i);try{let e=await a(s,d),t=Buffer.byteLength(e.content,`utf-8`);this.info(`Stats saved to ${e.filepath} (${h(t)})`)}catch(e){this.warn(e)}}}}var y=v;module.exports=y;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["fs","path","path","process","extractRollupStats","error: any"],"sources":["../../src/write.ts","../../src/utils/round.ts","../../src/utils/format-file-size.ts","../../src/index.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type RollupStatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type RollupStatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => RollupStatsWriteResponse;\n\nexport async function rollupStatsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<RollupStatsWriteResponse> {\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","export function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier; \n}\n","import { round } from './round';\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","import path from 'node:path';\nimport process from 'node:process';\nimport type { Plugin, OutputOptions } from 'rollup';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\n\nconst PLUGIN_NAME = 'rollupStats';\nconst DEFAULT_FILE_NAME = 'stats.json';\n\nexport type RollupStatsOptions = {\n /**\n * Output filename relative to Rollup output directory or absolute\n * @default: stats.json\n */\n fileName?: string;\n /**\n * Rollup stats options\n */\n stats?: StatsOptions;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: RollupStatsWrite;\n};\n\ntype RollupStatsOptionsOrOutputOptions =\n | RollupStatsOptions\n | ((outputOptions: OutputOptions) => RollupStatsOptions);\n\n\nfunction rollupStats(options: RollupStatsOptionsOrOutputOptions = {}): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions = typeof options === 'function' ? options(context) : options;\n const { fileName, stats: statsOptions, write = rollupStatsWrite } = resolvedOptions || {};\n\n const resolvedFileName = fileName || DEFAULT_FILE_NAME;\n const filepath = path.isAbsolute(resolvedFileName)\n ? resolvedFileName\n : path.join(context.dir || process.cwd(), resolvedFileName);\n\n const stats = extractRollupStats(bundle, statsOptions);\n\n try {\n const res = await write(filepath, stats);\n const outputSize = Buffer.byteLength(res.content, 'utf-8');\n\n this.info(`Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`);\n } catch (error: any) { // eslint-disable-line\n // Log error, but do not throw to allow the compilation to continue\n this.warn(error);\n }\n },\n } satisfies Plugin;\n}\n\nexport default rollupStats;\n\n"],"mappings":"+mBAaA,eAAsB,EAEpB,EAAkB,EAA6C,CAC/D,IAAM,EAAU,KAAK,UAAU,EAAO,KAAM,EAAE,CAO9C,OAJA,MAAMA,EAAAA,QAAG,MAAMC,EAAAA,QAAK,QAAQ,EAAS,CAAE,CAAE,UAAW,GAAM,CAAC,CAE3D,MAAMD,EAAAA,QAAG,UAAU,EAAU,EAAQ,CAE9B,CACL,WACA,UACD,CC1BH,SAAgB,EAAM,EAAe,EAAY,EAAG,CAClD,IAAM,EAAa,GAAK,EACxB,OAAO,KAAK,MAAM,EAAQ,EAAW,CAAG,ECA1C,MAAM,EAAY,CAChB,KAAM,CACJ,OAAQ,IACR,WAAY,EACb,CACD,KAAM,CACJ,OAAQ,MACR,WAAY,KACb,CACD,KAAM,CACJ,OAAQ,MACR,WAAY,KAAO,KACpB,CACF,CAED,SAAgB,EAAe,EAA+B,CAC5D,IAAI,EAAO,EAAU,KAcrB,OAZI,OAAO,GAAU,UAIrB,AAKE,EALE,EAAQ,EAAU,KAAK,WAClB,EAAU,KACR,EAAQ,EAAU,KAAK,WACzB,EAAU,KAEV,EAAU,KAGZ,GAAG,EAAM,EAAQ,EAAK,WAAY,EAAE,GAAG,EAAK,UAX1C,IAAI,EAAK,SCbpB,MAAM,EAAc,cACd,EAAoB,aAwB1B,SAAS,EAAY,EAA6C,EAAE,CAAU,CAC5E,MAAO,CACL,KAAM,cACN,MAAM,eAAe,EAAS,EAAQ,CAEpC,GAAM,CAAE,WAAU,MAAO,EAAc,QAAQ,IADvB,OAAO,GAAY,WAAa,EAAQ,EAAQ,CAAG,IACY,EAAE,CAEnF,EAAmB,GAAY,aAC/B,EAAWE,EAAAA,QAAK,WAAW,EAAiB,CAC9C,EACAA,EAAAA,QAAK,KAAK,EAAQ,KAAOC,EAAAA,QAAQ,KAAK,CAAE,EAAiB,CAEvD,EAAQC,EAAAA,EAAmB,EAAQ,EAAa,CAEtD,GAAI,CACF,IAAM,EAAM,MAAM,EAAM,EAAU,EAAM,CAClC,EAAa,OAAO,WAAW,EAAI,QAAS,QAAQ,CAE1D,KAAK,KAAK,kBAAkB,EAAI,SAAS,IAAI,EAAe,EAAW,CAAC,GAAG,OACpEC,EAAY,CAEnB,KAAK,KAAK,EAAM,GAGrB,CAGH,IAAA,EAAe"}
@@ -0,0 +1,2 @@
1
+ import { a as ModuleStats, c as StatsOptions, i as ChunkStatsOptionalProperties, l as extractRollupStats, n as AssetStatsOptionalProperties, o as ModuleStatsOptionalProperties, r as ChunkStats, s as Stats, t as AssetStats } from "./extract2.mjs";
2
+ export { AssetStats, AssetStatsOptionalProperties, ChunkStats, ChunkStatsOptionalProperties, ModuleStats, ModuleStatsOptionalProperties, Stats, StatsOptions, extractRollupStats as default };
@@ -0,0 +1 @@
1
+ import{t as e}from"./extract2.mjs";export{e as default};
@@ -0,0 +1,56 @@
1
+ import { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from "rollup";
2
+
3
+ //#region src/utils/check-exclude-filepath.d.ts
4
+ type ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);
5
+ type ExcludeFilepathPatterns = ExcludeFilepathParam | Array<ExcludeFilepathParam>;
6
+ //#endregion
7
+ //#region src/extract.d.ts
8
+ type AssetStatsOptionalProperties = {
9
+ source?: OutputAsset['source'];
10
+ };
11
+ type AssetStats = Omit<OutputAsset, keyof AssetStatsOptionalProperties> & AssetStatsOptionalProperties;
12
+ type ModuleStatsOptionalProperties = {
13
+ code?: RenderedModule['code'] | null;
14
+ };
15
+ type ModuleStats = Omit<RenderedModule, keyof ModuleStatsOptionalProperties> & ModuleStatsOptionalProperties;
16
+ type ChunkStatsOptionalProperties = {
17
+ code?: OutputChunk['code'];
18
+ map?: OutputChunk['map'];
19
+ };
20
+ type ChunkStats = Omit<OutputChunk, keyof ChunkStatsOptionalProperties | 'modules'> & {
21
+ modules: Record<string, ModuleStats>;
22
+ } & ChunkStatsOptionalProperties;
23
+ type Stats = Record<string, AssetStats | ChunkStats>;
24
+ type StatsOptions = {
25
+ /**
26
+ * Output asset/module sources
27
+ * @default false
28
+ */
29
+ source?: boolean;
30
+ /**
31
+ * Output chunk map
32
+ * @default false
33
+ */
34
+ map?: boolean;
35
+ /**
36
+ * Exclude matching assets
37
+ */
38
+ excludeAssets?: ExcludeFilepathPatterns;
39
+ /**
40
+ * Exclude matching modules
41
+ */
42
+ excludeModules?: ExcludeFilepathPatterns;
43
+ };
44
+ /**
45
+ * Extract bundler stats
46
+ *
47
+ * Shallow clone stats object before any processing using `omit` to
48
+ * 1. resolve getters
49
+ * 2. prevent changes to the stats object
50
+ *
51
+ * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128
52
+ */
53
+ declare function extractRollupStats(bundle: OutputBundle, options?: StatsOptions): Stats;
54
+ //#endregion
55
+ export { ModuleStats as a, StatsOptions as c, ChunkStatsOptionalProperties as i, extractRollupStats as l, AssetStatsOptionalProperties as n, ModuleStatsOptionalProperties as o, ChunkStats as r, Stats as s, AssetStats as t };
56
+ //# sourceMappingURL=extract2.d.mts.map
@@ -0,0 +1,2 @@
1
+ function e(e,t){let n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n}function t(e,n){if(!n)return!1;if(Array.isArray(n)){let r=!1;for(let i=0;i<=n.length-1&&r===!1;i++)r=t(e,n[i]);return r}return typeof n==`function`?n(e):typeof n==`string`?!!e.match(n):`test`in n?n.test(e):!1}function n(n,r={}){let{source:i=!1,map:a=!1,excludeAssets:o,excludeModules:s}=r,c={};return Object.entries(n).forEach(([n,r])=>{if(!t(n,o)){if(r.type===`asset`){let t=[];i||t.push(`source`),c[n]=e(r,t);return}if(r.type===`chunk`){let o=[];i||o.push(`code`),a||o.push(`map`);let l=e(r,o),u={};Object.entries(l.modules).forEach(([n,r])=>{if(t(n,s))return;let a=[];i||a.push(`code`),u[n]=e(r,a)}),l.modules=u,c[n]=l;return}}}),c}export{n as t};
2
+ //# sourceMappingURL=extract2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract2.mjs","names":["output: Stats","assetStatsOmitKeys: Array<keyof AssetStatsOptionalProperties>","chunkStatsOmitKeys: Array<keyof ChunkStatsOptionalProperties>","chunkModulesStats: ChunkStats['modules']","moduleStatsOmitKeys: Array<keyof ModuleStatsOptionalProperties>"],"sources":["../../src/utils/omit.ts","../../src/utils/check-exclude-filepath.ts","../../src/extract.ts"],"sourcesContent":["export function omit<D extends object, K extends keyof D = keyof D>(\n data: D,\n keys: K[],\n): Omit<D, K> {\n const result = {} as D;\n const objectKeys = Object.keys(data) as Array<K>;\n\n objectKeys.forEach((key) => {\n if (!keys.includes(key)) {\n result[key] = data[key];\n }\n });\n\n return result;\n}\n","type ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);\n\nexport type ExcludeFilepathPatterns = ExcludeFilepathParam | Array<ExcludeFilepathParam>;\n\n/**\n * Check if filepath should be excluded based on patterns\n */\nexport function checkExcludeFilepath(\n filepath: string,\n patterns?: ExcludeFilepathPatterns,\n): boolean {\n if (!patterns) {\n return false;\n }\n\n if (Array.isArray(patterns)) {\n let res = false;\n\n for (let i = 0; i <= patterns.length - 1 && res === false; i++) {\n res = checkExcludeFilepath(filepath, patterns[i]);\n }\n\n return res;\n }\n\n if (typeof patterns === 'function') {\n return patterns(filepath);\n }\n\n if (typeof patterns === 'string') {\n return Boolean(filepath.match(patterns));\n }\n\n if ('test' in patterns) {\n return patterns.test(filepath);\n }\n\n return false;\n}\n","import type { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from 'rollup';\nimport { omit } from './utils/omit';\nimport { type ExcludeFilepathPatterns, checkExcludeFilepath } from './utils/check-exclude-filepath';\n\nexport type AssetStatsOptionalProperties = {\n source?: OutputAsset['source'];\n};\n\nexport type AssetStats = Omit<OutputAsset, keyof AssetStatsOptionalProperties> & AssetStatsOptionalProperties;\n\nexport type ModuleStatsOptionalProperties = {\n code?: RenderedModule['code'] | null;\n};\n\nexport type ModuleStats = Omit<RenderedModule, keyof ModuleStatsOptionalProperties> & ModuleStatsOptionalProperties;\n\nexport type ChunkStatsOptionalProperties = {\n code?: OutputChunk['code'];\n map?: OutputChunk['map']; \n};\n\nexport type ChunkStats = Omit<OutputChunk, keyof ChunkStatsOptionalProperties | 'modules'> & {\n modules: Record<string, ModuleStats>;\n} & ChunkStatsOptionalProperties;\n\nexport type Stats = Record<string, AssetStats | ChunkStats>;\n\nexport type StatsOptions = {\n /**\n * Output asset/module sources\n * @default false \n */\n source?: boolean;\n /**\n * Output chunk map\n * @default false \n */\n map?: boolean;\n /**\n * Exclude matching assets\n */\n excludeAssets?: ExcludeFilepathPatterns;\n /**\n * Exclude matching modules\n */\n excludeModules?: ExcludeFilepathPatterns;\n}\n\n/**\n * Extract bundler stats\n *\n * Shallow clone stats object before any processing using `omit` to\n * 1. resolve getters\n * 2. prevent changes to the stats object\n *\n * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128\n */\nexport default function extractRollupStats(bundle: OutputBundle, options: StatsOptions = {}): Stats {\n const { source = false, map = false, excludeAssets, excludeModules } = options;\n\n const output: Stats = {};\n\n Object.entries(bundle).forEach(([bundleEntryFilepath, bundleEntryStats]) => {\n // Skip extraction if the entry filepath matches the exclude assets pattern\n if (checkExcludeFilepath(bundleEntryFilepath, excludeAssets)) {\n return;\n }\n\n if (bundleEntryStats.type === \"asset\") {\n const assetStatsOmitKeys: Array<keyof AssetStatsOptionalProperties> = [];\n\n // Skip asset source if options.source is false\n if (!source) {\n assetStatsOmitKeys.push('source'); \n }\n\n output[bundleEntryFilepath] = omit(\n bundleEntryStats,\n assetStatsOmitKeys,\n ) as AssetStats;\n\n return;\n }\n\n if (bundleEntryStats.type === \"chunk\") {\n const chunkStatsOmitKeys: Array<keyof ChunkStatsOptionalProperties> = [];\n\n // Skip chunk source if options.source is false\n if (!source) {\n chunkStatsOmitKeys.push('code');\n }\n\n // Skip chunk map if options.map is false\n if (!map) {\n chunkStatsOmitKeys.push('map');\n }\n\n const chunkStats = omit(bundleEntryStats, chunkStatsOmitKeys) as ChunkStats;\n\n\n // Extract chunk modules stats\n const chunkModulesStats: ChunkStats['modules'] = {};\n\n Object.entries(chunkStats.modules).forEach(([bundleModuleFilepath, bundleModuleStats]) => {\n // Skip module extraction if the filepath matches the exclude modules pattern\n if (checkExcludeFilepath(bundleModuleFilepath, excludeModules)) {\n return;\n }\n\n const moduleStatsOmitKeys: Array<keyof ModuleStatsOptionalProperties> = [];\n\n // Skip module source if options.source is false\n if (!source) {\n moduleStatsOmitKeys.push('code');\n }\n\n chunkModulesStats[bundleModuleFilepath] = omit(\n bundleModuleStats,\n moduleStatsOmitKeys,\n ) as ModuleStats;\n });\n\n chunkStats.modules = chunkModulesStats;\n\n output[bundleEntryFilepath] = chunkStats;\n\n return;\n }\n });\n \n return output;\n}\n"],"mappings":"AAAA,SAAgB,EACd,EACA,EACY,CACZ,IAAM,EAAS,EAAE,CASjB,OARmB,OAAO,KAAK,EAAK,CAEzB,QAAS,GAAQ,CACrB,EAAK,SAAS,EAAI,GACrB,EAAO,GAAO,EAAK,KAErB,CAEK,ECNT,SAAgB,EACd,EACA,EACS,CACT,GAAI,CAAC,EACH,MAAO,GAGT,GAAI,MAAM,QAAQ,EAAS,CAAE,CAC3B,IAAI,EAAM,GAEV,IAAK,IAAI,EAAI,EAAG,GAAK,EAAS,OAAS,GAAK,IAAQ,GAAO,IACzD,EAAM,EAAqB,EAAU,EAAS,GAAG,CAGnD,OAAO,EAeT,OAZI,OAAO,GAAa,WACf,EAAS,EAAS,CAGvB,OAAO,GAAa,SACf,EAAQ,EAAS,MAAM,EAAS,CAGrC,SAAU,EACL,EAAS,KAAK,EAAS,CAGzB,GCoBT,SAAwB,EAAmB,EAAsB,EAAwB,EAAE,CAAS,CAClG,GAAM,CAAE,SAAS,GAAO,MAAM,GAAO,gBAAe,kBAAmB,EAEjEA,EAAgB,EAAE,CAsExB,OApEA,OAAO,QAAQ,EAAO,CAAC,SAAS,CAAC,EAAqB,KAAsB,CAEtE,MAAqB,EAAqB,EAAc,CAI5D,IAAI,EAAiB,OAAS,QAAS,CACrC,IAAMC,EAAgE,EAAE,CAGnE,GACH,EAAmB,KAAK,SAAS,CAGnC,EAAO,GAAuB,EAC5B,EACA,EACD,CAED,OAGF,GAAI,EAAiB,OAAS,QAAS,CACrC,IAAMC,EAAgE,EAAE,CAGnE,GACH,EAAmB,KAAK,OAAO,CAI5B,GACH,EAAmB,KAAK,MAAM,CAGhC,IAAM,EAAa,EAAK,EAAkB,EAAmB,CAIvDC,EAA2C,EAAE,CAEnD,OAAO,QAAQ,EAAW,QAAQ,CAAC,SAAS,CAAC,EAAsB,KAAuB,CAExF,GAAI,EAAqB,EAAsB,EAAe,CAC5D,OAGF,IAAMC,EAAkE,EAAE,CAGrE,GACH,EAAoB,KAAK,OAAO,CAGlC,EAAkB,GAAwB,EACxC,EACA,EACD,EACD,CAEF,EAAW,QAAU,EAErB,EAAO,GAAuB,EAE9B,UAEF,CAEK"}
@@ -0,0 +1,32 @@
1
+ import { c as StatsOptions } from "./extract2.mjs";
2
+ import { OutputOptions, Plugin } from "rollup";
3
+
4
+ //#region src/write.d.ts
5
+ type RollupStatsWriteResponse = {
6
+ filepath: string;
7
+ content: string;
8
+ };
9
+ type RollupStatsWrite = (filepath: string, stats: Record<string, unknown>) => RollupStatsWriteResponse;
10
+ //#endregion
11
+ //#region src/index.d.ts
12
+ type RollupStatsOptions = {
13
+ /**
14
+ * Output filename relative to Rollup output directory or absolute
15
+ * @default: stats.json
16
+ */
17
+ fileName?: string;
18
+ /**
19
+ * Rollup stats options
20
+ */
21
+ stats?: StatsOptions;
22
+ /**
23
+ * Custom file writer
24
+ * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
25
+ */
26
+ write?: RollupStatsWrite;
27
+ };
28
+ type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
29
+ declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
30
+ //#endregion
31
+ export { RollupStatsOptions, rollupStats as default };
32
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./extract2.mjs";import t from"node:path";import n from"node:process";import r from"node:fs/promises";async function i(e,n){let i=JSON.stringify(n,null,2);return await r.mkdir(t.dirname(e),{recursive:!0}),await r.writeFile(e,i),{filepath:e,content:i}}function a(e,t=2){let n=10^t;return Math.round(e*n)/n}const o={BYTE:{symbol:`B`,multiplier:1},KILO:{symbol:`KiB`,multiplier:1024},MEGA:{symbol:`MiB`,multiplier:1024*1024}};function s(e){let t=o.BYTE;return typeof e==`number`?(t=e<o.KILO.multiplier?o.BYTE:e<o.MEGA.multiplier?o.KILO:o.MEGA,`${a(e/t.multiplier,2)}${t.symbol}`):`0${t.symbol}`}function c(r={}){return{name:`rollupStats`,async generateBundle(a,o){let{fileName:c,stats:l,write:u=i}=(typeof r==`function`?r(a):r)||{},d=c||`stats.json`,f=t.isAbsolute(d)?d:t.join(a.dir||n.cwd(),d),p=e(o,l);try{let e=await u(f,p),t=Buffer.byteLength(e.content,`utf-8`);this.info(`Stats saved to ${e.filepath} (${s(t)})`)}catch(e){this.warn(e)}}}}var l=c;export{l as default};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["error: any"],"sources":["../../src/write.ts","../../src/utils/round.ts","../../src/utils/format-file-size.ts","../../src/index.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\n\nexport type RollupStatsWriteResponse = {\n filepath: string;\n content: string;\n};\n\nexport type RollupStatsWrite = (\n filepath: string,\n stats: Record<string, unknown>\n) => RollupStatsWriteResponse;\n\nexport async function rollupStatsWrite<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(filepath: string, stats: T): Promise<RollupStatsWriteResponse> {\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","export function round(value: number, precision = 2) {\n const multiplier = 10 ^ precision;\n return Math.round(value * multiplier) / multiplier; \n}\n","import { round } from './round';\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","import path from 'node:path';\nimport process from 'node:process';\nimport type { Plugin, OutputOptions } from 'rollup';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\n\nconst PLUGIN_NAME = 'rollupStats';\nconst DEFAULT_FILE_NAME = 'stats.json';\n\nexport type RollupStatsOptions = {\n /**\n * Output filename relative to Rollup output directory or absolute\n * @default: stats.json\n */\n fileName?: string;\n /**\n * Rollup stats options\n */\n stats?: StatsOptions;\n /**\n * Custom file writer\n * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));\n */\n write?: RollupStatsWrite;\n};\n\ntype RollupStatsOptionsOrOutputOptions =\n | RollupStatsOptions\n | ((outputOptions: OutputOptions) => RollupStatsOptions);\n\n\nfunction rollupStats(options: RollupStatsOptionsOrOutputOptions = {}): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions = typeof options === 'function' ? options(context) : options;\n const { fileName, stats: statsOptions, write = rollupStatsWrite } = resolvedOptions || {};\n\n const resolvedFileName = fileName || DEFAULT_FILE_NAME;\n const filepath = path.isAbsolute(resolvedFileName)\n ? resolvedFileName\n : path.join(context.dir || process.cwd(), resolvedFileName);\n\n const stats = extractRollupStats(bundle, statsOptions);\n\n try {\n const res = await write(filepath, stats);\n const outputSize = Buffer.byteLength(res.content, 'utf-8');\n\n this.info(`Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`);\n } catch (error: any) { // eslint-disable-line\n // Log error, but do not throw to allow the compilation to continue\n this.warn(error);\n }\n },\n } satisfies Plugin;\n}\n\nexport default rollupStats;\n\n"],"mappings":"wHAaA,eAAsB,EAEpB,EAAkB,EAA6C,CAC/D,IAAM,EAAU,KAAK,UAAU,EAAO,KAAM,EAAE,CAO9C,OAJA,MAAM,EAAG,MAAM,EAAK,QAAQ,EAAS,CAAE,CAAE,UAAW,GAAM,CAAC,CAE3D,MAAM,EAAG,UAAU,EAAU,EAAQ,CAE9B,CACL,WACA,UACD,CC1BH,SAAgB,EAAM,EAAe,EAAY,EAAG,CAClD,IAAM,EAAa,GAAK,EACxB,OAAO,KAAK,MAAM,EAAQ,EAAW,CAAG,ECA1C,MAAM,EAAY,CAChB,KAAM,CACJ,OAAQ,IACR,WAAY,EACb,CACD,KAAM,CACJ,OAAQ,MACR,WAAY,KACb,CACD,KAAM,CACJ,OAAQ,MACR,WAAY,KAAO,KACpB,CACF,CAED,SAAgB,EAAe,EAA+B,CAC5D,IAAI,EAAO,EAAU,KAcrB,OAZI,OAAO,GAAU,UAIrB,AAKE,EALE,EAAQ,EAAU,KAAK,WAClB,EAAU,KACR,EAAQ,EAAU,KAAK,WACzB,EAAU,KAEV,EAAU,KAGZ,GAAG,EAAM,EAAQ,EAAK,WAAY,EAAE,GAAG,EAAK,UAX1C,IAAI,EAAK,SCYpB,SAAS,EAAY,EAA6C,EAAE,CAAU,CAC5E,MAAO,CACL,KAAM,cACN,MAAM,eAAe,EAAS,EAAQ,CAEpC,GAAM,CAAE,WAAU,MAAO,EAAc,QAAQ,IADvB,OAAO,GAAY,WAAa,EAAQ,EAAQ,CAAG,IACY,EAAE,CAEnF,EAAmB,GAAY,aAC/B,EAAW,EAAK,WAAW,EAAiB,CAC9C,EACA,EAAK,KAAK,EAAQ,KAAO,EAAQ,KAAK,CAAE,EAAiB,CAEvD,EAAQ,EAAmB,EAAQ,EAAa,CAEtD,GAAI,CACF,IAAM,EAAM,MAAM,EAAM,EAAU,EAAM,CAClC,EAAa,OAAO,WAAW,EAAI,QAAS,QAAQ,CAE1D,KAAK,KAAK,kBAAkB,EAAI,SAAS,IAAI,EAAe,EAAW,CAAC,GAAG,OACpEA,EAAY,CAEnB,KAAK,KAAK,EAAM,GAGrB,CAGH,IAAA,EAAe"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rollup-plugin-stats",
3
3
  "description": "Output Rollup stats",
4
- "version": "1.5.2-beta.0",
4
+ "version": "1.5.3-beta.0",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "repository": {
@@ -24,39 +24,36 @@
24
24
  "stats",
25
25
  "bundle-stats"
26
26
  ],
27
- "main": "./lib/cjs/index.js",
28
- "module": "./lib/esm/index.js",
29
- "typings": "./lib/types/index.d.ts",
27
+ "main": "dist/cjs/index.js",
28
+ "module": "dist/esm/index.mjs",
29
+ "typings": "dist/esm/index.d.ts",
30
30
  "files": [
31
- "lib"
31
+ "dist"
32
32
  ],
33
33
  "exports": {
34
34
  ".": {
35
- "types": "./lib/types/index.d.ts",
36
- "import": "./lib/esm/index.js",
37
- "require": "./lib/cjs/index.js"
35
+ "types": "./dist/esm/index.d.ts",
36
+ "import": "./dist/esm/index.mjs",
37
+ "require": "./dist/cjs/index.js"
38
38
  },
39
39
  "./extract": {
40
- "types": "./lib/types/extract.d.ts",
41
- "import": "./lib/esm/extract.js",
42
- "require": "./lib/cjs/extract.js"
40
+ "types": "./dist/esm/extract.d.ts",
41
+ "import": "./dist/esm/extract.mjs",
42
+ "require": "./dist/cjs/extract.js"
43
43
  }
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18"
47
47
  },
48
48
  "scripts": {
49
- "build": "npm run clean && npm run type-check && rollup -c && npm run build-esm-packages",
50
- "build-esm-packages": "echo '{\"type\":\"module\"}' > lib/esm/package.json",
51
- "type-check": "tsc",
52
- "clean": "rimraf ./lib",
49
+ "build": "tsdown",
53
50
  "lint": "eslint .",
54
51
  "format": "prettier --write .",
55
52
  "test:unit": "vitest test/unit",
56
53
  "test:package": "npm run test:package:rolldown && npm run test:package:rollup && npm run test:package:vite",
57
- "test:package:rolldown": "cd test/package/rolldown && npm run test",
58
- "test:package:rollup": "cd test/package/rollup && npm run test",
59
- "test:package:vite": "cd test/package/vite && npm run test",
54
+ "test:package:rolldown": "vitest test/package/rolldown",
55
+ "test:package:rollup": "vitest test/package/rollup",
56
+ "test:package:vite": "vitest test/package/vite",
60
57
  "bump": "./scripts/bump.sh",
61
58
  "release": "./scripts/release.sh"
62
59
  },
@@ -66,26 +63,21 @@
66
63
  }
67
64
  },
68
65
  "devDependencies": {
69
- "@eslint/js": "9.36.0",
66
+ "@eslint/js": "9.39.0",
70
67
  "@release-it/conventional-changelog": "10.0.1",
71
- "@rollup/plugin-commonjs": "^28.0.6",
72
- "@rollup/plugin-node-resolve": "^16.0.1",
73
- "@rollup/plugin-typescript": "^12.1.4",
74
68
  "@tsconfig/node18": "18.2.4",
75
- "@types/deep-freeze-strict": "^1.1.2",
76
- "@types/node": "24.5.2",
69
+ "@types/node": "24.9.2",
77
70
  "deep-freeze-strict": "1.1.1",
78
- "eslint": "9.36.0",
79
- "globals": "16.4.0",
71
+ "eslint": "9.39.0",
72
+ "globals": "16.5.0",
80
73
  "husky": "8.0.3",
81
- "memfs": "4.46.1",
74
+ "memfs": "4.50.0",
82
75
  "prettier": "3.6.2",
83
76
  "release-it": "19.0.5",
84
- "rimraf": "6.0.1",
85
- "rollup": "4.52.2",
86
- "typescript": "5.9.2",
87
- "typescript-eslint": "8.44.1",
88
- "vitest": "3.2.4"
77
+ "tsdown": "^0.15.12",
78
+ "typescript": "5.9.3",
79
+ "typescript-eslint": "8.46.2",
80
+ "vitest": "4.0.6"
89
81
  },
90
82
  "peerDependencies": {
91
83
  "rolldown": "^1.0.0-beta.0",
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- var omit = require('./utils/omit.js');
4
- var checkExcludeFilepath = require('./utils/check-exclude-filepath.js');
5
-
6
- /**
7
- * Extract bundler stats
8
- *
9
- * Shallow clone stats object before any processing using `omit` to
10
- * 1. resolve getters
11
- * 2. prevent changes to the stats object
12
- *
13
- * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128
14
- */
15
- function extractRollupStats(bundle, options = {}) {
16
- const { source = false, map = false, excludeAssets, excludeModules } = options;
17
- const output = {};
18
- Object.entries(bundle).forEach(([bundleEntryFilepath, bundleEntryStats]) => {
19
- // Skip extraction if the entry filepath matches the exclude assets pattern
20
- if (checkExcludeFilepath.checkExcludeFilepath(bundleEntryFilepath, excludeAssets)) {
21
- return;
22
- }
23
- if (bundleEntryStats.type === "asset") {
24
- const assetStatsOmitKeys = [];
25
- // Skip asset source if options.source is false
26
- if (!source) {
27
- assetStatsOmitKeys.push('source');
28
- }
29
- output[bundleEntryFilepath] = omit.omit(bundleEntryStats, assetStatsOmitKeys);
30
- return;
31
- }
32
- if (bundleEntryStats.type === "chunk") {
33
- const chunkStatsOmitKeys = [];
34
- // Skip chunk source if options.source is false
35
- if (!source) {
36
- chunkStatsOmitKeys.push('code');
37
- }
38
- // Skip chunk map if options.map is false
39
- if (!map) {
40
- chunkStatsOmitKeys.push('map');
41
- }
42
- const chunkStats = omit.omit(bundleEntryStats, chunkStatsOmitKeys);
43
- // Extract chunk modules stats
44
- const chunkModulesStats = {};
45
- Object.entries(chunkStats.modules).forEach(([bundleModuleFilepath, bundleModuleStats]) => {
46
- // Skip module extraction if the filepath matches the exclude modules pattern
47
- if (checkExcludeFilepath.checkExcludeFilepath(bundleModuleFilepath, excludeModules)) {
48
- return;
49
- }
50
- const moduleStatsOmitKeys = [];
51
- // Skip module source if options.source is false
52
- if (!source) {
53
- moduleStatsOmitKeys.push('code');
54
- }
55
- chunkModulesStats[bundleModuleFilepath] = omit.omit(bundleModuleStats, moduleStatsOmitKeys);
56
- });
57
- chunkStats.modules = chunkModulesStats;
58
- output[bundleEntryFilepath] = chunkStats;
59
- return;
60
- }
61
- });
62
- return output;
63
- }
64
-
65
- module.exports = extractRollupStats;
66
- //# sourceMappingURL=extract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract.js","sources":["../../../src/extract.ts"],"sourcesContent":[null],"names":["checkExcludeFilepath","omit"],"mappings":";;;;;AAgDA;;;;;;;;AAQG;AACW,SAAU,kBAAkB,CAAC,MAAoB,EAAE,UAAwB,EAAE,EAAA;AACzF,IAAA,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,GAAG,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,OAAO;IAE9E,MAAM,MAAM,GAAU,EAAE;AAExB,IAAA,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,KAAI;;AAEzE,QAAA,IAAIA,yCAAoB,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAAE;YAC5D;QACF;AAEA,QAAA,IAAI,gBAAgB,CAAC,IAAI,KAAK,OAAO,EAAE;YACrC,MAAM,kBAAkB,GAA8C,EAAE;;YAGxE,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;YACnC;YAEA,MAAM,CAAC,mBAAmB,CAAC,GAAGC,SAAI,CAChC,gBAAgB,EAChB,kBAAkB,CACL;YAEf;QACF;AAEA,QAAA,IAAI,gBAAgB,CAAC,IAAI,KAAK,OAAO,EAAE;YACrC,MAAM,kBAAkB,GAA8C,EAAE;;YAGxE,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;YACjC;;YAGA,IAAI,CAAC,GAAG,EAAE;AACR,gBAAA,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;YAChC;YAEA,MAAM,UAAU,GAAGA,SAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAe;;YAI3E,MAAM,iBAAiB,GAA0B,EAAE;AAEnD,YAAA,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,KAAI;;AAEvF,gBAAA,IAAID,yCAAoB,CAAC,oBAAoB,EAAE,cAAc,CAAC,EAAE;oBAC9D;gBACF;gBAEA,MAAM,mBAAmB,GAA+C,EAAE;;gBAG1E,IAAI,CAAC,MAAM,EAAE;AACX,oBAAA,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;gBAClC;gBAEA,iBAAiB,CAAC,oBAAoB,CAAC,GAAGC,SAAI,CAC5C,iBAAiB,EACjB,mBAAmB,CACL;AAClB,YAAA,CAAC,CAAC;AAEF,YAAA,UAAU,CAAC,OAAO,GAAG,iBAAiB;AAEtC,YAAA,MAAM,CAAC,mBAAmB,CAAC,GAAG,UAAU;YAExC;QACF;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
package/lib/cjs/index.js DELETED
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var process = require('node:process');
5
- var extract = require('./extract.js');
6
- var write = require('./write.js');
7
- var formatFileSize = require('./utils/format-file-size.js');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
-
11
- var path__default = /*#__PURE__*/_interopDefault(path);
12
- var process__default = /*#__PURE__*/_interopDefault(process);
13
-
14
- const PLUGIN_NAME = 'rollupStats';
15
- const DEFAULT_FILE_NAME = 'stats.json';
16
- function rollupStats(options = {}) {
17
- return {
18
- name: PLUGIN_NAME,
19
- async generateBundle(context, bundle) {
20
- const resolvedOptions = typeof options === 'function' ? options(context) : options;
21
- const { fileName, stats: statsOptions, write: write$1 = write.rollupStatsWrite } = resolvedOptions || {};
22
- const resolvedFileName = fileName || DEFAULT_FILE_NAME;
23
- const filepath = path__default.default.isAbsolute(resolvedFileName)
24
- ? resolvedFileName
25
- : path__default.default.join(context.dir || process__default.default.cwd(), resolvedFileName);
26
- const stats = extract(bundle, statsOptions);
27
- try {
28
- const res = await write$1(filepath, stats);
29
- const outputSize = Buffer.byteLength(res.content, 'utf-8');
30
- this.info(`Stats saved to ${res.filepath} (${formatFileSize.formatFileSize(outputSize)})`);
31
- }
32
- catch (error) { // eslint-disable-line
33
- // Log error, but do not throw to allow the compilation to continue
34
- this.warn(error);
35
- }
36
- },
37
- };
38
- }
39
-
40
- module.exports = rollupStats;
41
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":["write","rollupStatsWrite","path","process","extractRollupStats","formatFileSize"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,WAAW,GAAG,aAAa;AACjC,MAAM,iBAAiB,GAAG,YAAY;AAwBtC,SAAS,WAAW,CAAC,OAAA,GAA6C,EAAE,EAAA;IAClE,OAAO;AACL,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,MAAM,cAAc,CAAC,OAAO,EAAE,MAAM,EAAA;AAClC,YAAA,MAAM,eAAe,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO;AAClF,YAAA,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,SAAEA,OAAK,GAAGC,sBAAgB,EAAE,GAAG,eAAe,IAAI,EAAE;AAEzF,YAAA,MAAM,gBAAgB,GAAG,QAAQ,IAAI,iBAAiB;AACtD,YAAA,MAAM,QAAQ,GAAGC,qBAAI,CAAC,UAAU,CAAC,gBAAgB;AAC/C,kBAAE;AACF,kBAAEA,qBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAIC,wBAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;YAE7D,MAAM,KAAK,GAAGC,OAAkB,CAAC,MAAM,EAAE,YAAY,CAAC;AAEtD,YAAA,IAAI;gBACF,MAAM,GAAG,GAAG,MAAMJ,OAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;AACxC,gBAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;AAE1D,gBAAA,IAAI,CAAC,IAAI,CAAC,CAAA,eAAA,EAAkB,GAAG,CAAC,QAAQ,CAAA,EAAA,EAAKK,6BAAc,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG,CAAC;YAC7E;AAAE,YAAA,OAAO,KAAU,EAAE;;AAEnB,gBAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClB;QACF,CAAC;KACe;AACpB;;;;"}
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Check if filepath should be excluded based on patterns
5
- */
6
- function checkExcludeFilepath(filepath, patterns) {
7
- if (!patterns) {
8
- return false;
9
- }
10
- if (Array.isArray(patterns)) {
11
- let res = false;
12
- for (let i = 0; i <= patterns.length - 1 && res === false; i++) {
13
- res = checkExcludeFilepath(filepath, patterns[i]);
14
- }
15
- return res;
16
- }
17
- if (typeof patterns === 'function') {
18
- return patterns(filepath);
19
- }
20
- if (typeof patterns === 'string') {
21
- return Boolean(filepath.match(patterns));
22
- }
23
- if ('test' in patterns) {
24
- return patterns.test(filepath);
25
- }
26
- return false;
27
- }
28
-
29
- exports.checkExcludeFilepath = checkExcludeFilepath;
30
- //# sourceMappingURL=check-exclude-filepath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-exclude-filepath.js","sources":["../../../../src/utils/check-exclude-filepath.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;AAEG;AACG,SAAU,oBAAoB,CAClC,QAAgB,EAChB,QAAkC,EAAA;IAElC,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,GAAG,GAAG,KAAK;QAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9D,GAAG,GAAG,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACnD;AAEA,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AAClC,QAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B;AAEA,IAAA,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAChC,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C;AAEA,IAAA,IAAI,MAAM,IAAI,QAAQ,EAAE;AACtB,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAChC;AAEA,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- var round = require('./round.js');
4
-
5
- const FILE_SIZE = {
6
- BYTE: {
7
- symbol: 'B',
8
- multiplier: 1,
9
- },
10
- KILO: {
11
- symbol: 'KiB',
12
- multiplier: 1024,
13
- },
14
- MEGA: {
15
- symbol: 'MiB',
16
- multiplier: 1024 * 1024,
17
- },
18
- };
19
- function formatFileSize(value) {
20
- let unit = FILE_SIZE.BYTE;
21
- if (typeof value !== 'number') {
22
- return `0${unit.symbol}`;
23
- }
24
- if (value < FILE_SIZE.KILO.multiplier) {
25
- unit = FILE_SIZE.BYTE;
26
- }
27
- else if (value < FILE_SIZE.MEGA.multiplier) {
28
- unit = FILE_SIZE.KILO;
29
- }
30
- else {
31
- unit = FILE_SIZE.MEGA;
32
- }
33
- return `${round.round(value / unit.multiplier, 2)}${unit.symbol}`;
34
- }
35
-
36
- exports.formatFileSize = formatFileSize;
37
- //# sourceMappingURL=format-file-size.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-file-size.js","sources":["../../../../src/utils/format-file-size.ts"],"sourcesContent":[null],"names":["round"],"mappings":";;;;AAEA,MAAM,SAAS,GAAG;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,UAAU,EAAE,CAAC;AACd,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,UAAU,EAAE,IAAI;AACjB,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,IAAI,GAAG,IAAI;AACxB,KAAA;CACF;AAEK,SAAU,cAAc,CAAC,KAAqB,EAAA;AAClD,IAAA,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI;AAEzB,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE;IAC1B;IAEA,IAAI,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;AACrC,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;SAAO,IAAI,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;AAC5C,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;SAAO;AACL,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;AAEA,IAAA,OAAO,GAAGA,WAAK,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA,EAAG,IAAI,CAAC,MAAM,EAAE;AAC7D;;;;"}
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- function omit(data, keys) {
4
- const result = {};
5
- const objectKeys = Object.keys(data);
6
- objectKeys.forEach((key) => {
7
- if (!keys.includes(key)) {
8
- result[key] = data[key];
9
- }
10
- });
11
- return result;
12
- }
13
-
14
- exports.omit = omit;
15
- //# sourceMappingURL=omit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"omit.js","sources":["../../../../src/utils/omit.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAM,SAAU,IAAI,CAClB,IAAO,EACP,IAAS,EAAA;IAET,MAAM,MAAM,GAAG,EAAO;IACtB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAa;AAEhD,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QACzB;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- function round(value, precision = 2) {
4
- const multiplier = 10 ^ precision;
5
- return Math.round(value * multiplier) / multiplier;
6
- }
7
-
8
- exports.round = round;
9
- //# sourceMappingURL=round.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"round.js","sources":["../../../../src/utils/round.ts"],"sourcesContent":[null],"names":[],"mappings":";;SAAgB,KAAK,CAAC,KAAa,EAAE,SAAS,GAAG,CAAC,EAAA;AAChD,IAAA,MAAM,UAAU,GAAG,EAAE,GAAG,SAAS;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU;AACpD;;;;"}
package/lib/cjs/write.js DELETED
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var fs = require('node:fs/promises');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var path__default = /*#__PURE__*/_interopDefault(path);
9
- var fs__default = /*#__PURE__*/_interopDefault(fs);
10
-
11
- async function rollupStatsWrite(filepath, stats) {
12
- const content = JSON.stringify(stats, null, 2);
13
- // Create base directory if it does not exist
14
- await fs__default.default.mkdir(path__default.default.dirname(filepath), { recursive: true });
15
- await fs__default.default.writeFile(filepath, content);
16
- return {
17
- filepath,
18
- content,
19
- };
20
- }
21
-
22
- exports.rollupStatsWrite = rollupStatsWrite;
23
- //# sourceMappingURL=write.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.js","sources":["../../../src/write.ts"],"sourcesContent":[null],"names":["fs","path"],"mappings":";;;;;;;;;;AAaO,eAAe,gBAAgB,CAEpC,QAAgB,EAAE,KAAQ,EAAA;AAC1B,IAAA,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;AAG9C,IAAA,MAAMA,mBAAE,CAAC,KAAK,CAACC,qBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAE3D,MAAMD,mBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAErC,OAAO;QACL,QAAQ;QACR,OAAO;KACR;AACH;;;;"}
@@ -1,64 +0,0 @@
1
- import { omit } from './utils/omit.js';
2
- import { checkExcludeFilepath } from './utils/check-exclude-filepath.js';
3
-
4
- /**
5
- * Extract bundler stats
6
- *
7
- * Shallow clone stats object before any processing using `omit` to
8
- * 1. resolve getters
9
- * 2. prevent changes to the stats object
10
- *
11
- * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128
12
- */
13
- function extractRollupStats(bundle, options = {}) {
14
- const { source = false, map = false, excludeAssets, excludeModules } = options;
15
- const output = {};
16
- Object.entries(bundle).forEach(([bundleEntryFilepath, bundleEntryStats]) => {
17
- // Skip extraction if the entry filepath matches the exclude assets pattern
18
- if (checkExcludeFilepath(bundleEntryFilepath, excludeAssets)) {
19
- return;
20
- }
21
- if (bundleEntryStats.type === "asset") {
22
- const assetStatsOmitKeys = [];
23
- // Skip asset source if options.source is false
24
- if (!source) {
25
- assetStatsOmitKeys.push('source');
26
- }
27
- output[bundleEntryFilepath] = omit(bundleEntryStats, assetStatsOmitKeys);
28
- return;
29
- }
30
- if (bundleEntryStats.type === "chunk") {
31
- const chunkStatsOmitKeys = [];
32
- // Skip chunk source if options.source is false
33
- if (!source) {
34
- chunkStatsOmitKeys.push('code');
35
- }
36
- // Skip chunk map if options.map is false
37
- if (!map) {
38
- chunkStatsOmitKeys.push('map');
39
- }
40
- const chunkStats = omit(bundleEntryStats, chunkStatsOmitKeys);
41
- // Extract chunk modules stats
42
- const chunkModulesStats = {};
43
- Object.entries(chunkStats.modules).forEach(([bundleModuleFilepath, bundleModuleStats]) => {
44
- // Skip module extraction if the filepath matches the exclude modules pattern
45
- if (checkExcludeFilepath(bundleModuleFilepath, excludeModules)) {
46
- return;
47
- }
48
- const moduleStatsOmitKeys = [];
49
- // Skip module source if options.source is false
50
- if (!source) {
51
- moduleStatsOmitKeys.push('code');
52
- }
53
- chunkModulesStats[bundleModuleFilepath] = omit(bundleModuleStats, moduleStatsOmitKeys);
54
- });
55
- chunkStats.modules = chunkModulesStats;
56
- output[bundleEntryFilepath] = chunkStats;
57
- return;
58
- }
59
- });
60
- return output;
61
- }
62
-
63
- export { extractRollupStats as default };
64
- //# sourceMappingURL=extract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract.js","sources":["../../../src/extract.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAgDA;;;;;;;;AAQG;AACW,SAAU,kBAAkB,CAAC,MAAoB,EAAE,UAAwB,EAAE,EAAA;AACzF,IAAA,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,GAAG,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,OAAO;IAE9E,MAAM,MAAM,GAAU,EAAE;AAExB,IAAA,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,KAAI;;AAEzE,QAAA,IAAI,oBAAoB,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAAE;YAC5D;QACF;AAEA,QAAA,IAAI,gBAAgB,CAAC,IAAI,KAAK,OAAO,EAAE;YACrC,MAAM,kBAAkB,GAA8C,EAAE;;YAGxE,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;YACnC;YAEA,MAAM,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAChC,gBAAgB,EAChB,kBAAkB,CACL;YAEf;QACF;AAEA,QAAA,IAAI,gBAAgB,CAAC,IAAI,KAAK,OAAO,EAAE;YACrC,MAAM,kBAAkB,GAA8C,EAAE;;YAGxE,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;YACjC;;YAGA,IAAI,CAAC,GAAG,EAAE;AACR,gBAAA,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;YAChC;YAEA,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAe;;YAI3E,MAAM,iBAAiB,GAA0B,EAAE;AAEnD,YAAA,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,KAAI;;AAEvF,gBAAA,IAAI,oBAAoB,CAAC,oBAAoB,EAAE,cAAc,CAAC,EAAE;oBAC9D;gBACF;gBAEA,MAAM,mBAAmB,GAA+C,EAAE;;gBAG1E,IAAI,CAAC,MAAM,EAAE;AACX,oBAAA,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;gBAClC;gBAEA,iBAAiB,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAC5C,iBAAiB,EACjB,mBAAmB,CACL;AAClB,YAAA,CAAC,CAAC;AAEF,YAAA,UAAU,CAAC,OAAO,GAAG,iBAAiB;AAEtC,YAAA,MAAM,CAAC,mBAAmB,CAAC,GAAG,UAAU;YAExC;QACF;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
package/lib/esm/index.js DELETED
@@ -1,34 +0,0 @@
1
- import path from 'node:path';
2
- import process from 'node:process';
3
- import extractRollupStats from './extract.js';
4
- import { rollupStatsWrite } from './write.js';
5
- import { formatFileSize } from './utils/format-file-size.js';
6
-
7
- const PLUGIN_NAME = 'rollupStats';
8
- const DEFAULT_FILE_NAME = 'stats.json';
9
- function rollupStats(options = {}) {
10
- return {
11
- name: PLUGIN_NAME,
12
- async generateBundle(context, bundle) {
13
- const resolvedOptions = typeof options === 'function' ? options(context) : options;
14
- const { fileName, stats: statsOptions, write = rollupStatsWrite } = resolvedOptions || {};
15
- const resolvedFileName = fileName || DEFAULT_FILE_NAME;
16
- const filepath = path.isAbsolute(resolvedFileName)
17
- ? resolvedFileName
18
- : path.join(context.dir || process.cwd(), resolvedFileName);
19
- const stats = extractRollupStats(bundle, statsOptions);
20
- try {
21
- const res = await write(filepath, stats);
22
- const outputSize = Buffer.byteLength(res.content, 'utf-8');
23
- this.info(`Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`);
24
- }
25
- catch (error) { // eslint-disable-line
26
- // Log error, but do not throw to allow the compilation to continue
27
- this.warn(error);
28
- }
29
- },
30
- };
31
- }
32
-
33
- export { rollupStats as default };
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAQA,MAAM,WAAW,GAAG,aAAa;AACjC,MAAM,iBAAiB,GAAG,YAAY;AAwBtC,SAAS,WAAW,CAAC,OAAA,GAA6C,EAAE,EAAA;IAClE,OAAO;AACL,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,MAAM,cAAc,CAAC,OAAO,EAAE,MAAM,EAAA;AAClC,YAAA,MAAM,eAAe,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO;AAClF,YAAA,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,GAAG,gBAAgB,EAAE,GAAG,eAAe,IAAI,EAAE;AAEzF,YAAA,MAAM,gBAAgB,GAAG,QAAQ,IAAI,iBAAiB;AACtD,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB;AAC/C,kBAAE;AACF,kBAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;YAE7D,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC;AAEtD,YAAA,IAAI;gBACF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;AACxC,gBAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;AAE1D,gBAAA,IAAI,CAAC,IAAI,CAAC,CAAA,eAAA,EAAkB,GAAG,CAAC,QAAQ,CAAA,EAAA,EAAK,cAAc,CAAC,UAAU,CAAC,CAAA,CAAA,CAAG,CAAC;YAC7E;AAAE,YAAA,OAAO,KAAU,EAAE;;AAEnB,gBAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAClB;QACF,CAAC;KACe;AACpB;;;;"}
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Check if filepath should be excluded based on patterns
3
- */
4
- function checkExcludeFilepath(filepath, patterns) {
5
- if (!patterns) {
6
- return false;
7
- }
8
- if (Array.isArray(patterns)) {
9
- let res = false;
10
- for (let i = 0; i <= patterns.length - 1 && res === false; i++) {
11
- res = checkExcludeFilepath(filepath, patterns[i]);
12
- }
13
- return res;
14
- }
15
- if (typeof patterns === 'function') {
16
- return patterns(filepath);
17
- }
18
- if (typeof patterns === 'string') {
19
- return Boolean(filepath.match(patterns));
20
- }
21
- if ('test' in patterns) {
22
- return patterns.test(filepath);
23
- }
24
- return false;
25
- }
26
-
27
- export { checkExcludeFilepath };
28
- //# sourceMappingURL=check-exclude-filepath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-exclude-filepath.js","sources":["../../../../src/utils/check-exclude-filepath.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIA;;AAEG;AACG,SAAU,oBAAoB,CAClC,QAAgB,EAChB,QAAkC,EAAA;IAElC,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,GAAG,GAAG,KAAK;QAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9D,GAAG,GAAG,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACnD;AAEA,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AAClC,QAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B;AAEA,IAAA,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAChC,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C;AAEA,IAAA,IAAI,MAAM,IAAI,QAAQ,EAAE;AACtB,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAChC;AAEA,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -1,35 +0,0 @@
1
- import { round } from './round.js';
2
-
3
- const FILE_SIZE = {
4
- BYTE: {
5
- symbol: 'B',
6
- multiplier: 1,
7
- },
8
- KILO: {
9
- symbol: 'KiB',
10
- multiplier: 1024,
11
- },
12
- MEGA: {
13
- symbol: 'MiB',
14
- multiplier: 1024 * 1024,
15
- },
16
- };
17
- function formatFileSize(value) {
18
- let unit = FILE_SIZE.BYTE;
19
- if (typeof value !== 'number') {
20
- return `0${unit.symbol}`;
21
- }
22
- if (value < FILE_SIZE.KILO.multiplier) {
23
- unit = FILE_SIZE.BYTE;
24
- }
25
- else if (value < FILE_SIZE.MEGA.multiplier) {
26
- unit = FILE_SIZE.KILO;
27
- }
28
- else {
29
- unit = FILE_SIZE.MEGA;
30
- }
31
- return `${round(value / unit.multiplier, 2)}${unit.symbol}`;
32
- }
33
-
34
- export { formatFileSize };
35
- //# sourceMappingURL=format-file-size.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-file-size.js","sources":["../../../../src/utils/format-file-size.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAAG;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,UAAU,EAAE,CAAC;AACd,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,UAAU,EAAE,IAAI;AACjB,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,IAAI,GAAG,IAAI;AACxB,KAAA;CACF;AAEK,SAAU,cAAc,CAAC,KAAqB,EAAA;AAClD,IAAA,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI;AAEzB,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE;IAC1B;IAEA,IAAI,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;AACrC,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;SAAO,IAAI,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;AAC5C,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;SAAO;AACL,QAAA,IAAI,GAAG,SAAS,CAAC,IAAI;IACvB;AAEA,IAAA,OAAO,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA,EAAG,IAAI,CAAC,MAAM,EAAE;AAC7D;;;;"}
@@ -1,13 +0,0 @@
1
- function omit(data, keys) {
2
- const result = {};
3
- const objectKeys = Object.keys(data);
4
- objectKeys.forEach((key) => {
5
- if (!keys.includes(key)) {
6
- result[key] = data[key];
7
- }
8
- });
9
- return result;
10
- }
11
-
12
- export { omit };
13
- //# sourceMappingURL=omit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"omit.js","sources":["../../../../src/utils/omit.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAM,SAAU,IAAI,CAClB,IAAO,EACP,IAAS,EAAA;IAET,MAAM,MAAM,GAAG,EAAO;IACtB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAa;AAEhD,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;QACzB;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
@@ -1,7 +0,0 @@
1
- function round(value, precision = 2) {
2
- const multiplier = 10 ^ precision;
3
- return Math.round(value * multiplier) / multiplier;
4
- }
5
-
6
- export { round };
7
- //# sourceMappingURL=round.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"round.js","sources":["../../../../src/utils/round.ts"],"sourcesContent":[null],"names":[],"mappings":"SAAgB,KAAK,CAAC,KAAa,EAAE,SAAS,GAAG,CAAC,EAAA;AAChD,IAAA,MAAM,UAAU,GAAG,EAAE,GAAG,SAAS;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU;AACpD;;;;"}
package/lib/esm/write.js DELETED
@@ -1,16 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs/promises';
3
-
4
- async function rollupStatsWrite(filepath, stats) {
5
- const content = JSON.stringify(stats, null, 2);
6
- // Create base directory if it does not exist
7
- await fs.mkdir(path.dirname(filepath), { recursive: true });
8
- await fs.writeFile(filepath, content);
9
- return {
10
- filepath,
11
- content,
12
- };
13
- }
14
-
15
- export { rollupStatsWrite };
16
- //# sourceMappingURL=write.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.js","sources":["../../../src/write.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAaO,eAAe,gBAAgB,CAEpC,QAAgB,EAAE,KAAQ,EAAA;AAC1B,IAAA,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;AAG9C,IAAA,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAE3D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAErC,OAAO;QACL,QAAQ;QACR,OAAO;KACR;AACH;;;;"}
@@ -1,48 +0,0 @@
1
- import type { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from 'rollup';
2
- import { type ExcludeFilepathPatterns } from './utils/check-exclude-filepath';
3
- export type AssetStatsOptionalProperties = {
4
- source?: OutputAsset['source'];
5
- };
6
- export type AssetStats = Omit<OutputAsset, keyof AssetStatsOptionalProperties> & AssetStatsOptionalProperties;
7
- export type ModuleStatsOptionalProperties = {
8
- code?: RenderedModule['code'] | null;
9
- };
10
- export type ModuleStats = Omit<RenderedModule, keyof ModuleStatsOptionalProperties> & ModuleStatsOptionalProperties;
11
- export type ChunkStatsOptionalProperties = {
12
- code?: OutputChunk['code'];
13
- map?: OutputChunk['map'];
14
- };
15
- export type ChunkStats = Omit<OutputChunk, keyof ChunkStatsOptionalProperties | 'modules'> & {
16
- modules: Record<string, ModuleStats>;
17
- } & ChunkStatsOptionalProperties;
18
- export type Stats = Record<string, AssetStats | ChunkStats>;
19
- export type StatsOptions = {
20
- /**
21
- * Output asset/module sources
22
- * @default false
23
- */
24
- source?: boolean;
25
- /**
26
- * Output chunk map
27
- * @default false
28
- */
29
- map?: boolean;
30
- /**
31
- * Exclude matching assets
32
- */
33
- excludeAssets?: ExcludeFilepathPatterns;
34
- /**
35
- * Exclude matching modules
36
- */
37
- excludeModules?: ExcludeFilepathPatterns;
38
- };
39
- /**
40
- * Extract bundler stats
41
- *
42
- * Shallow clone stats object before any processing using `omit` to
43
- * 1. resolve getters
44
- * 2. prevent changes to the stats object
45
- *
46
- * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128
47
- */
48
- export default function extractRollupStats(bundle: OutputBundle, options?: StatsOptions): Stats;
@@ -1,22 +0,0 @@
1
- import type { Plugin, OutputOptions } from 'rollup';
2
- import { type StatsOptions } from './extract';
3
- import { type RollupStatsWrite } from './write';
4
- export type RollupStatsOptions = {
5
- /**
6
- * Output filename relative to Rollup output directory or absolute
7
- * @default: stats.json
8
- */
9
- fileName?: string;
10
- /**
11
- * Rollup stats options
12
- */
13
- stats?: StatsOptions;
14
- /**
15
- * Custom file writer
16
- * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
17
- */
18
- write?: RollupStatsWrite;
19
- };
20
- type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
21
- declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
22
- export default rollupStats;
@@ -1,7 +0,0 @@
1
- type ExcludeFilepathParam = string | RegExp | ((filepath: string) => boolean);
2
- export type ExcludeFilepathPatterns = ExcludeFilepathParam | Array<ExcludeFilepathParam>;
3
- /**
4
- * Check if filepath should be excluded based on patterns
5
- */
6
- export declare function checkExcludeFilepath(filepath: string, patterns?: ExcludeFilepathPatterns): boolean;
7
- export {};
@@ -1 +0,0 @@
1
- export declare function formatFileSize(value?: number | null): string;
@@ -1 +0,0 @@
1
- export declare function omit<D extends object, K extends keyof D = keyof D>(data: D, keys: K[]): Omit<D, K>;
@@ -1 +0,0 @@
1
- export declare function round(value: number, precision?: number): number;
@@ -1,6 +0,0 @@
1
- export type RollupStatsWriteResponse = {
2
- filepath: string;
3
- content: string;
4
- };
5
- export type RollupStatsWrite = (filepath: string, stats: Record<string, unknown>) => RollupStatsWriteResponse;
6
- export declare function rollupStatsWrite<T extends Record<string, unknown> = Record<string, unknown>>(filepath: string, stats: T): Promise<RollupStatsWriteResponse>;