rollup-plugin-stats 2.1.1-beta.0 → 2.1.1-beta.3

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.
package/dist/index.cjs CHANGED
@@ -1,35 +1,8 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_extract = require('./extract.cjs');
3
- const require_write = require('./src/write.cjs');
4
- const require_format_file_size = require('./src/utils/format-file-size.cjs');
5
- let node_path = require("node:path");
6
- node_path = require_runtime.__toESM(node_path);
7
- let node_process = require("node:process");
8
- node_process = require_runtime.__toESM(node_process);
1
+ const require_plugin = require('./src/plugin.cjs');
9
2
 
10
3
  //#region src/index.ts
11
- const PLUGIN_NAME = "rollupStats";
12
- const DEFAULT_FILE_NAME = "stats.json";
13
- function rollupStats(options = {}) {
14
- return {
15
- name: PLUGIN_NAME,
16
- async generateBundle(context, bundle) {
17
- const { fileName, stats: statsOptions, write = require_write.rollupStatsWrite } = (typeof options === "function" ? options(context) : options) || {};
18
- const resolvedFileName = fileName || DEFAULT_FILE_NAME;
19
- const filepath = node_path.default.isAbsolute(resolvedFileName) ? resolvedFileName : node_path.default.join(context.dir || node_process.default.cwd(), resolvedFileName);
20
- const stats = require_extract(bundle, statsOptions);
21
- try {
22
- const res = await write(filepath, stats);
23
- const outputSize = Buffer.byteLength(res.content, "utf-8");
24
- this.info(`Stats saved to ${res.filepath} (${require_format_file_size.formatFileSize(outputSize)})`);
25
- } catch (error) {
26
- const message = error instanceof Error ? error.message : JSON.stringify(error);
27
- this.warn(message);
28
- }
29
- }
30
- };
31
- }
4
+ var src_default = require_plugin.default;
32
5
 
33
6
  //#endregion
34
- module.exports = rollupStats;
7
+ module.exports = src_default;
35
8
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["rollupStatsWrite","path","process","extractRollupStats","formatFileSize"],"sources":["../src/index.ts"],"sourcesContent":["import path from 'node:path';\nimport process from 'node:process';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\nimport type { Plugin, OutputOptions } from './types';\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\nfunction rollupStats(options: RollupStatsOptionsOrOutputOptions = {}): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(context) : options;\n const {\n fileName,\n stats: statsOptions,\n write = rollupStatsWrite,\n } = 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(\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 } satisfies Plugin;\n}\n\nexport default rollupStats;\n"],"mappings":";;;;;;;;;;AAQA,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAuB1B,SAAS,YAAY,UAA6C,EAAE,EAAU;AAC5E,QAAO;EACL,MAAM;EACN,MAAM,eAAe,SAAS,QAAQ;GAGpC,MAAM,EACJ,UACA,OAAO,cACP,QAAQA,oCAJR,OAAO,YAAY,aAAa,QAAQ,QAAQ,GAAG,YAK9B,EAAE;GAEzB,MAAM,mBAAmB,YAAY;GACrC,MAAM,WAAWC,kBAAK,WAAW,iBAAiB,GAC9C,mBACAA,kBAAK,KAAK,QAAQ,OAAOC,qBAAQ,KAAK,EAAE,iBAAiB;GAE7D,MAAM,QAAQC,gBAAmB,QAAQ,aAAa;AAEtD,OAAI;IACF,MAAM,MAAM,MAAM,MAAM,UAAU,MAAM;IACxC,MAAM,aAAa,OAAO,WAAW,IAAI,SAAS,QAAQ;AAE1D,SAAK,KACH,kBAAkB,IAAI,SAAS,IAAIC,wCAAe,WAAW,CAAC,GAC/D;YACM,OAAgB;IACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,SAAK,KAAK,QAAQ;;;EAGvB"}
1
+ {"version":3,"file":"index.cjs","names":["rollupStats"],"sources":["../src/index.ts"],"sourcesContent":["import { rollupStats } from './plugin';\n\nexport type {\n RollupStatsOptions,\n RollupStatsOptionsOrOutputOptions,\n} from './plugin';\nexport type {\n OutputAsset,\n OutputBundle,\n OutputChunk,\n RenderedModule,\n} from './types';\n\nexport default rollupStats;\n"],"mappings":";;;AAaA,kBAAeA"}
package/dist/index.d.cts CHANGED
@@ -1,26 +1,3 @@
1
- import { OutputOptions, Plugin } from "./src/types.cjs";
2
- import { StatsOptions } from "./extract.cjs";
3
- import { RollupStatsWrite } from "./src/write.cjs";
4
-
5
- //#region src/index.d.ts
6
- type RollupStatsOptions = {
7
- /**
8
- * Output filename relative to Rollup output directory or absolute
9
- * @default: stats.json
10
- */
11
- fileName?: string;
12
- /**
13
- * Rollup stats options
14
- */
15
- stats?: StatsOptions;
16
- /**
17
- * Custom file writer
18
- * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
19
- */
20
- write?: RollupStatsWrite;
21
- };
22
- type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
23
- declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
24
- //#endregion
25
- export { RollupStatsOptions, rollupStats as default };
26
- //# sourceMappingURL=index.d.cts.map
1
+ import { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from "./src/types.cjs";
2
+ import { RollupStatsOptions, RollupStatsOptionsOrOutputOptions, rollupStats } from "./src/plugin.cjs";
3
+ export { type OutputAsset, type OutputBundle, type OutputChunk, type RenderedModule, type RollupStatsOptions, type RollupStatsOptionsOrOutputOptions, rollupStats as default };
package/dist/index.d.mts CHANGED
@@ -1,26 +1,3 @@
1
- import { OutputOptions, Plugin } from "./src/types.mjs";
2
- import { StatsOptions } from "./extract.mjs";
3
- import { RollupStatsWrite } from "./src/write.mjs";
4
-
5
- //#region src/index.d.ts
6
- type RollupStatsOptions = {
7
- /**
8
- * Output filename relative to Rollup output directory or absolute
9
- * @default: stats.json
10
- */
11
- fileName?: string;
12
- /**
13
- * Rollup stats options
14
- */
15
- stats?: StatsOptions;
16
- /**
17
- * Custom file writer
18
- * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
19
- */
20
- write?: RollupStatsWrite;
21
- };
22
- type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
23
- declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
24
- //#endregion
25
- export { RollupStatsOptions, rollupStats as default };
26
- //# sourceMappingURL=index.d.mts.map
1
+ import { OutputAsset, OutputBundle, OutputChunk, RenderedModule } from "./src/types.mjs";
2
+ import { RollupStatsOptions, RollupStatsOptionsOrOutputOptions, rollupStats } from "./src/plugin.mjs";
3
+ export { type OutputAsset, type OutputBundle, type OutputChunk, type RenderedModule, type RollupStatsOptions, type RollupStatsOptionsOrOutputOptions, rollupStats as default };
package/dist/index.mjs CHANGED
@@ -1,32 +1,8 @@
1
- import extractRollupStats from "./extract.mjs";
2
- import { rollupStatsWrite } from "./src/write.mjs";
3
- import { formatFileSize } from "./src/utils/format-file-size.mjs";
4
- import path from "node:path";
5
- import process from "node:process";
1
+ import rollupStats from "./src/plugin.mjs";
6
2
 
7
3
  //#region src/index.ts
8
- const PLUGIN_NAME = "rollupStats";
9
- const DEFAULT_FILE_NAME = "stats.json";
10
- function rollupStats(options = {}) {
11
- return {
12
- name: PLUGIN_NAME,
13
- async generateBundle(context, bundle) {
14
- const { fileName, stats: statsOptions, write = rollupStatsWrite } = (typeof options === "function" ? options(context) : options) || {};
15
- const resolvedFileName = fileName || DEFAULT_FILE_NAME;
16
- const filepath = path.isAbsolute(resolvedFileName) ? resolvedFileName : path.join(context.dir || process.cwd(), resolvedFileName);
17
- const stats = extractRollupStats(bundle, statsOptions);
18
- try {
19
- const res = await write(filepath, stats);
20
- const outputSize = Buffer.byteLength(res.content, "utf-8");
21
- this.info(`Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`);
22
- } catch (error) {
23
- const message = error instanceof Error ? error.message : JSON.stringify(error);
24
- this.warn(message);
25
- }
26
- }
27
- };
28
- }
4
+ var src_default = rollupStats;
29
5
 
30
6
  //#endregion
31
- export { rollupStats as default };
7
+ export { src_default as default };
32
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import path from 'node:path';\nimport process from 'node:process';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\nimport type { Plugin, OutputOptions } from './types';\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\nfunction rollupStats(options: RollupStatsOptionsOrOutputOptions = {}): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(context) : options;\n const {\n fileName,\n stats: statsOptions,\n write = rollupStatsWrite,\n } = 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(\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 } satisfies Plugin;\n}\n\nexport default rollupStats;\n"],"mappings":";;;;;;;AAQA,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAuB1B,SAAS,YAAY,UAA6C,EAAE,EAAU;AAC5E,QAAO;EACL,MAAM;EACN,MAAM,eAAe,SAAS,QAAQ;GAGpC,MAAM,EACJ,UACA,OAAO,cACP,QAAQ,sBAJR,OAAO,YAAY,aAAa,QAAQ,QAAQ,GAAG,YAK9B,EAAE;GAEzB,MAAM,mBAAmB,YAAY;GACrC,MAAM,WAAW,KAAK,WAAW,iBAAiB,GAC9C,mBACA,KAAK,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,iBAAiB;GAE7D,MAAM,QAAQ,mBAAmB,QAAQ,aAAa;AAEtD,OAAI;IACF,MAAM,MAAM,MAAM,MAAM,UAAU,MAAM;IACxC,MAAM,aAAa,OAAO,WAAW,IAAI,SAAS,QAAQ;AAE1D,SAAK,KACH,kBAAkB,IAAI,SAAS,IAAI,eAAe,WAAW,CAAC,GAC/D;YACM,OAAgB;IACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,SAAK,KAAK,QAAQ;;;EAGvB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { rollupStats } from './plugin';\n\nexport type {\n RollupStatsOptions,\n RollupStatsOptionsOrOutputOptions,\n} from './plugin';\nexport type {\n OutputAsset,\n OutputBundle,\n OutputChunk,\n RenderedModule,\n} from './types';\n\nexport default rollupStats;\n"],"mappings":";;;AAaA,kBAAe"}
@@ -0,0 +1,35 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_extract = require('../extract.cjs');
3
+ const require_write = require('./write.cjs');
4
+ const require_format_file_size = require('./utils/format-file-size.cjs');
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path);
7
+ let node_process = require("node:process");
8
+ node_process = require_runtime.__toESM(node_process);
9
+
10
+ //#region src/plugin.ts
11
+ const PLUGIN_NAME = "rollupStats";
12
+ const DEFAULT_FILE_NAME = "stats.json";
13
+ function rollupStats(options = {}) {
14
+ return {
15
+ name: PLUGIN_NAME,
16
+ async generateBundle(context, bundle) {
17
+ const { fileName, stats: statsOptions, write = require_write.rollupStatsWrite } = (typeof options === "function" ? options(context) : options) || {};
18
+ const resolvedFileName = fileName || DEFAULT_FILE_NAME;
19
+ const filepath = node_path.default.isAbsolute(resolvedFileName) ? resolvedFileName : node_path.default.join(context.dir || node_process.default.cwd(), resolvedFileName);
20
+ const stats = require_extract(bundle, statsOptions);
21
+ try {
22
+ const res = await write(filepath, stats);
23
+ const outputSize = Buffer.byteLength(res.content, "utf-8");
24
+ this.info(`Stats saved to ${res.filepath} (${require_format_file_size.formatFileSize(outputSize)})`);
25
+ } catch (error) {
26
+ const message = error instanceof Error ? error.message : JSON.stringify(error);
27
+ this.warn(message);
28
+ }
29
+ }
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ exports.default = rollupStats;
35
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","names":["rollupStatsWrite","path","process","extractRollupStats","formatFileSize"],"sources":["../../src/plugin.ts"],"sourcesContent":["import path from 'node:path';\nimport process from 'node:process';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\nimport type { OutputBundle } from './types';\n\nconst PLUGIN_NAME = 'rollupStats';\nconst DEFAULT_FILE_NAME = 'stats.json';\n\n/**\n * A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,\n * containing only the fields this plugin uses to generate a stats file for a specific output.\n */\nexport type OutputOptions = {\n /** Output directory for the generated files. */\n dir?: string | undefined;\n\n /** Output format */\n format?:\n | 'es'\n | 'esm'\n | 'module'\n | 'cjs'\n | 'commonjs'\n | 'iife'\n | 'umd'\n | 'amd'\n | 'system'\n | 'systemjs'\n | undefined;\n};\n\n/**\n * Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.\n */\ntype PluginContext = {\n /** Log an informational message through Vite/Rolldown/Rollup's logging pipeline. */\n info: (message: string) => void;\n\n /** Log a warning through Vite/Rolldown/Rollup's logging pipeline without stopping the build. */\n warn: (message: string) => void;\n};\n\n/**\n * Minimum plugin interface compatible with Vite/Rolldown/Rollup.\n *\n * @example\n * {\n * name: 'rollupStats',\n * async generateBundle(outputOptions, bundle) { ... },\n * }\n */\nexport type Plugin = {\n /** Unique identifier for the plugin, used in error messages and logs. */\n name: string;\n\n /**\n * Hook called after the bundle has been fully generated but before it is\n * written to disk. Receives the resolved output options and the complete\n * output bundle map.\n */\n generateBundle?: (\n this: PluginContext,\n outputOptions: OutputOptions,\n bundle: OutputBundle,\n isWrite: boolean\n ) => void | Promise<void>;\n};\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\nexport type RollupStatsOptionsOrOutputOptions =\n | RollupStatsOptions\n | ((outputOptions: OutputOptions) => RollupStatsOptions);\n\nexport function rollupStats(\n options: RollupStatsOptionsOrOutputOptions = {}\n): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(context) : options;\n const {\n fileName,\n stats: statsOptions,\n write = rollupStatsWrite,\n } = 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(\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 } satisfies Plugin;\n}\n\nexport default rollupStats;\n"],"mappings":";;;;;;;;;;AAQA,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAmF1B,SAAgB,YACd,UAA6C,EAAE,EACvC;AACR,QAAO;EACL,MAAM;EACN,MAAM,eAAe,SAAS,QAAQ;GAGpC,MAAM,EACJ,UACA,OAAO,cACP,QAAQA,oCAJR,OAAO,YAAY,aAAa,QAAQ,QAAQ,GAAG,YAK9B,EAAE;GAEzB,MAAM,mBAAmB,YAAY;GACrC,MAAM,WAAWC,kBAAK,WAAW,iBAAiB,GAC9C,mBACAA,kBAAK,KAAK,QAAQ,OAAOC,qBAAQ,KAAK,EAAE,iBAAiB;GAE7D,MAAM,QAAQC,gBAAmB,QAAQ,aAAa;AAEtD,OAAI;IACF,MAAM,MAAM,MAAM,MAAM,UAAU,MAAM;IACxC,MAAM,aAAa,OAAO,WAAW,IAAI,SAAS,QAAQ;AAE1D,SAAK,KACH,kBAAkB,IAAI,SAAS,IAAIC,wCAAe,WAAW,CAAC,GAC/D;YACM,OAAgB;IACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,SAAK,KAAK,QAAQ;;;EAGvB"}
@@ -0,0 +1,59 @@
1
+ import { OutputBundle } from "./types.cjs";
2
+ import { StatsOptions } from "../extract.cjs";
3
+ import { RollupStatsWrite } from "./write.cjs";
4
+
5
+ //#region src/plugin.d.ts
6
+ /**
7
+ * A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,
8
+ * containing only the fields this plugin uses to generate a stats file for a specific output.
9
+ */
10
+ type OutputOptions = {
11
+ /** Output directory for the generated files. */dir?: string | undefined; /** Output format */
12
+ format?: 'es' | 'esm' | 'module' | 'cjs' | 'commonjs' | 'iife' | 'umd' | 'amd' | 'system' | 'systemjs' | undefined;
13
+ };
14
+ /**
15
+ * Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.
16
+ */
17
+ type PluginContext = {
18
+ /** Log an informational message through Vite/Rolldown/Rollup's logging pipeline. */info: (message: string) => void; /** Log a warning through Vite/Rolldown/Rollup's logging pipeline without stopping the build. */
19
+ warn: (message: string) => void;
20
+ };
21
+ /**
22
+ * Minimum plugin interface compatible with Vite/Rolldown/Rollup.
23
+ *
24
+ * @example
25
+ * {
26
+ * name: 'rollupStats',
27
+ * async generateBundle(outputOptions, bundle) { ... },
28
+ * }
29
+ */
30
+ type Plugin = {
31
+ /** Unique identifier for the plugin, used in error messages and logs. */name: string;
32
+ /**
33
+ * Hook called after the bundle has been fully generated but before it is
34
+ * written to disk. Receives the resolved output options and the complete
35
+ * output bundle map.
36
+ */
37
+ generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
38
+ };
39
+ type RollupStatsOptions = {
40
+ /**
41
+ * Output filename relative to Rollup output directory or absolute
42
+ * @default: stats.json
43
+ */
44
+ fileName?: string;
45
+ /**
46
+ * Rollup stats options
47
+ */
48
+ stats?: StatsOptions;
49
+ /**
50
+ * Custom file writer
51
+ * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
52
+ */
53
+ write?: RollupStatsWrite;
54
+ };
55
+ type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
56
+ declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
57
+ //#endregion
58
+ export { RollupStatsOptions, RollupStatsOptionsOrOutputOptions, rollupStats };
59
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;;AAeA;;KAAY,aAAA;EAEV,gDAAA,GAAA,uBAoBG;EAjBH,MAAA;AAAA;;;;KAiBG,aAAA;EAKI,oFAHP,IAAA,GAAO,OAAA,mBAGe;EAAtB,IAAA,GAAO,OAAA;AAAA;;;;;;;;;;KAYG,MAAA;EAUR,yEARF,IAAA;EASE;;;;;EAFF,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,EAAe,aAAA,EACf,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA;AAAA,KAGF,kBAAA;EAAkB;;;;EAK5B,QAAA;EAIQ;;;EAAR,KAAA,GAAQ,YAAA;EAKgB;AAG1B;;;EAHE,KAAA,GAAQ,gBAAA;AAAA;AAAA,KAGE,iCAAA,GACR,kBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,kBAAA;AAAA,iBAEvB,WAAA,CACd,OAAA,GAAS,iCAAA,GACR,MAAA"}
@@ -0,0 +1,59 @@
1
+ import { OutputBundle } from "./types.mjs";
2
+ import { StatsOptions } from "../extract.mjs";
3
+ import { RollupStatsWrite } from "./write.mjs";
4
+
5
+ //#region src/plugin.d.ts
6
+ /**
7
+ * A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,
8
+ * containing only the fields this plugin uses to generate a stats file for a specific output.
9
+ */
10
+ type OutputOptions = {
11
+ /** Output directory for the generated files. */dir?: string | undefined; /** Output format */
12
+ format?: 'es' | 'esm' | 'module' | 'cjs' | 'commonjs' | 'iife' | 'umd' | 'amd' | 'system' | 'systemjs' | undefined;
13
+ };
14
+ /**
15
+ * Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.
16
+ */
17
+ type PluginContext = {
18
+ /** Log an informational message through Vite/Rolldown/Rollup's logging pipeline. */info: (message: string) => void; /** Log a warning through Vite/Rolldown/Rollup's logging pipeline without stopping the build. */
19
+ warn: (message: string) => void;
20
+ };
21
+ /**
22
+ * Minimum plugin interface compatible with Vite/Rolldown/Rollup.
23
+ *
24
+ * @example
25
+ * {
26
+ * name: 'rollupStats',
27
+ * async generateBundle(outputOptions, bundle) { ... },
28
+ * }
29
+ */
30
+ type Plugin = {
31
+ /** Unique identifier for the plugin, used in error messages and logs. */name: string;
32
+ /**
33
+ * Hook called after the bundle has been fully generated but before it is
34
+ * written to disk. Receives the resolved output options and the complete
35
+ * output bundle map.
36
+ */
37
+ generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
38
+ };
39
+ type RollupStatsOptions = {
40
+ /**
41
+ * Output filename relative to Rollup output directory or absolute
42
+ * @default: stats.json
43
+ */
44
+ fileName?: string;
45
+ /**
46
+ * Rollup stats options
47
+ */
48
+ stats?: StatsOptions;
49
+ /**
50
+ * Custom file writer
51
+ * @default - fs.write(FILENAME, JSON.stringify(STATS, null, 2));
52
+ */
53
+ write?: RollupStatsWrite;
54
+ };
55
+ type RollupStatsOptionsOrOutputOptions = RollupStatsOptions | ((outputOptions: OutputOptions) => RollupStatsOptions);
56
+ declare function rollupStats(options?: RollupStatsOptionsOrOutputOptions): Plugin;
57
+ //#endregion
58
+ export { RollupStatsOptions, RollupStatsOptionsOrOutputOptions, rollupStats };
59
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;;AAeA;;KAAY,aAAA;EAEV,gDAAA,GAAA,uBAoBG;EAjBH,MAAA;AAAA;;;;KAiBG,aAAA;EAKI,oFAHP,IAAA,GAAO,OAAA,mBAGe;EAAtB,IAAA,GAAO,OAAA;AAAA;;;;;;;;;;KAYG,MAAA;EAUR,yEARF,IAAA;EASE;;;;;EAFF,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,EAAe,aAAA,EACf,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA;AAAA,KAGF,kBAAA;EAAkB;;;;EAK5B,QAAA;EAIQ;;;EAAR,KAAA,GAAQ,YAAA;EAKgB;AAG1B;;;EAHE,KAAA,GAAQ,gBAAA;AAAA;AAAA,KAGE,iCAAA,GACR,kBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,kBAAA;AAAA,iBAEvB,WAAA,CACd,OAAA,GAAS,iCAAA,GACR,MAAA"}
@@ -0,0 +1,32 @@
1
+ import extractRollupStats from "../extract.mjs";
2
+ import { rollupStatsWrite } from "./write.mjs";
3
+ import { formatFileSize } from "./utils/format-file-size.mjs";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+
7
+ //#region src/plugin.ts
8
+ const PLUGIN_NAME = "rollupStats";
9
+ const DEFAULT_FILE_NAME = "stats.json";
10
+ function rollupStats(options = {}) {
11
+ return {
12
+ name: PLUGIN_NAME,
13
+ async generateBundle(context, bundle) {
14
+ const { fileName, stats: statsOptions, write = rollupStatsWrite } = (typeof options === "function" ? options(context) : options) || {};
15
+ const resolvedFileName = fileName || DEFAULT_FILE_NAME;
16
+ const filepath = path.isAbsolute(resolvedFileName) ? resolvedFileName : path.join(context.dir || process.cwd(), resolvedFileName);
17
+ const stats = extractRollupStats(bundle, statsOptions);
18
+ try {
19
+ const res = await write(filepath, stats);
20
+ const outputSize = Buffer.byteLength(res.content, "utf-8");
21
+ this.info(`Stats saved to ${res.filepath} (${formatFileSize(outputSize)})`);
22
+ } catch (error) {
23
+ const message = error instanceof Error ? error.message : JSON.stringify(error);
24
+ this.warn(message);
25
+ }
26
+ }
27
+ };
28
+ }
29
+
30
+ //#endregion
31
+ export { rollupStats as default };
32
+ //# sourceMappingURL=plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import path from 'node:path';\nimport process from 'node:process';\n\nimport extractRollupStats, { type StatsOptions } from './extract';\nimport { type RollupStatsWrite, rollupStatsWrite } from './write';\nimport { formatFileSize } from './utils/format-file-size';\nimport type { OutputBundle } from './types';\n\nconst PLUGIN_NAME = 'rollupStats';\nconst DEFAULT_FILE_NAME = 'stats.json';\n\n/**\n * A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,\n * containing only the fields this plugin uses to generate a stats file for a specific output.\n */\nexport type OutputOptions = {\n /** Output directory for the generated files. */\n dir?: string | undefined;\n\n /** Output format */\n format?:\n | 'es'\n | 'esm'\n | 'module'\n | 'cjs'\n | 'commonjs'\n | 'iife'\n | 'umd'\n | 'amd'\n | 'system'\n | 'systemjs'\n | undefined;\n};\n\n/**\n * Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.\n */\ntype PluginContext = {\n /** Log an informational message through Vite/Rolldown/Rollup's logging pipeline. */\n info: (message: string) => void;\n\n /** Log a warning through Vite/Rolldown/Rollup's logging pipeline without stopping the build. */\n warn: (message: string) => void;\n};\n\n/**\n * Minimum plugin interface compatible with Vite/Rolldown/Rollup.\n *\n * @example\n * {\n * name: 'rollupStats',\n * async generateBundle(outputOptions, bundle) { ... },\n * }\n */\nexport type Plugin = {\n /** Unique identifier for the plugin, used in error messages and logs. */\n name: string;\n\n /**\n * Hook called after the bundle has been fully generated but before it is\n * written to disk. Receives the resolved output options and the complete\n * output bundle map.\n */\n generateBundle?: (\n this: PluginContext,\n outputOptions: OutputOptions,\n bundle: OutputBundle,\n isWrite: boolean\n ) => void | Promise<void>;\n};\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\nexport type RollupStatsOptionsOrOutputOptions =\n | RollupStatsOptions\n | ((outputOptions: OutputOptions) => RollupStatsOptions);\n\nexport function rollupStats(\n options: RollupStatsOptionsOrOutputOptions = {}\n): Plugin {\n return {\n name: PLUGIN_NAME,\n async generateBundle(context, bundle) {\n const resolvedOptions =\n typeof options === 'function' ? options(context) : options;\n const {\n fileName,\n stats: statsOptions,\n write = rollupStatsWrite,\n } = 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(\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 } satisfies Plugin;\n}\n\nexport default rollupStats;\n"],"mappings":";;;;;;;AAQA,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAmF1B,SAAgB,YACd,UAA6C,EAAE,EACvC;AACR,QAAO;EACL,MAAM;EACN,MAAM,eAAe,SAAS,QAAQ;GAGpC,MAAM,EACJ,UACA,OAAO,cACP,QAAQ,sBAJR,OAAO,YAAY,aAAa,QAAQ,QAAQ,GAAG,YAK9B,EAAE;GAEzB,MAAM,mBAAmB,YAAY;GACrC,MAAM,WAAW,KAAK,WAAW,iBAAiB,GAC9C,mBACA,KAAK,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,iBAAiB;GAE7D,MAAM,QAAQ,mBAAmB,QAAQ,aAAa;AAEtD,OAAI;IACF,MAAM,MAAM,MAAM,MAAM,UAAU,MAAM;IACxC,MAAM,aAAa,OAAO,WAAW,IAAI,SAAS,QAAQ;AAE1D,SAAK,KACH,kBAAkB,IAAI,SAAS,IAAI,eAAe,WAAW,CAAC,GAC/D;YACM,OAAgB;IACvB,MAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,MAAM;AAGhE,SAAK,KAAK,QAAQ;;;EAGvB"}
@@ -1,86 +1,90 @@
1
1
  //#region src/types.d.ts
2
2
  /**
3
3
  * A generated asset entry in the output bundle (e.g. CSS, images, JSON).
4
- *
5
- * @example
6
- * {
7
- * type: 'asset',
8
- * fileName: 'assets/logo-CvPeBknE.svg',
9
- * names: ['logo'],
10
- * originalFileNames: ['src/assets/logo.svg'],
11
- * source: '<svg xmlns="http://www.w3.org/2000/svg">...</svg>',
12
- * }
13
4
  */
14
5
  type OutputAsset = {
15
- /** Discriminant literal identifying this entry as an asset. */type: 'asset'; /** All entry names that reference this asset. */
16
- names: string[]; /** Original source file names this asset was generated from. */
17
- originalFileNames: string[]; /** The asset content as a string (text assets) or a `Uint8Array` (binary assets). */
18
- source: string | Uint8Array; /** The emitted file name of the asset relative to the output directory. */
6
+ type: 'asset'; /** All entry names that reference this asset. */
7
+ names: string[];
8
+ /**
9
+ * The asset content as a string (text assets) or a `Uint8Array` (binary assets).
10
+ * Available when options.stats.source = true (default false)
11
+ */
12
+ source?: string | Uint8Array; /** The emitted file name of the asset relative to the output directory. */
19
13
  fileName: string;
14
+ /**
15
+ * Whether this asset requires a code reference (`import.meta.ROLLUP_FILE_URL_<id>`)
16
+ * to be included in the bundle.
17
+ */
18
+ needsCodeReference: boolean;
19
+ /**
20
+ * The original file name of the source asset before any transformations, or `null` when not applicable.
21
+ * @deprecated Use `originalFileNames` instead.
22
+ */
23
+ originalFileName: string | null; /** The original file names of the source assets before any transformations. */
24
+ originalFileNames: string[]; /** Optional Vite-specific metadata. Only present when using Vite. */
25
+ viteMetadata?: {
26
+ /** Set of asset file names imported by this asset (e.g. images referenced in CSS). */importedAssets: Set<string>; /** Set of CSS file names imported by this asset. */
27
+ importedCss: Set<string>;
28
+ };
20
29
  };
21
30
  /**
22
31
  * A generated JavaScript chunk entry in the output bundle.
23
- *
24
- * @example
25
- * {
26
- * type: 'chunk',
27
- * fileName: 'assets/index-DpgTxXR6.js',
28
- * name: 'index',
29
- * facadeModuleId: '/project/src/index.ts',
30
- * isEntry: true,
31
- * isDynamicEntry: false,
32
- * exports: ['default'],
33
- * imports: ['assets/vendor-CvaBJZ2l.js'],
34
- * dynamicImports: ['assets/lazy-Dj3OKb2X.js'],
35
- * modules: { '/project/src/index.ts': { renderedLength: 120, ... } },
36
- * code: '"use strict";...',
37
- * map: null,
38
- * }
39
32
  */
40
33
  type OutputChunk = {
41
- /** Discriminant literal identifying this entry as a JavaScript chunk. */type: 'chunk'; /** Names exported by this chunk. */
34
+ type: 'chunk';
35
+ /**
36
+ * The chunk name as used in `chunkFileNames` and `entryFileNames` patterns,
37
+ * without any content hash.
38
+ */
39
+ name: string; /** The emitted file name of the chunk relative to the output directory. */
40
+ fileName: string; /** The file name of this chunk before content hashes are applied. */
41
+ preliminaryFileName: string; /** File names of assets referenced via `import.meta.ROLLUP_FILE_URL_<id>` in this chunk. */
42
+ referencedFiles: string[]; /** The file name of the source map for this chunk, or `null` when source maps are not generated. */
43
+ sourcemapFileName: string | null; /** Names exported by this chunk. */
42
44
  exports: string[];
43
45
  /**
44
46
  * The module ID of the entry point that this chunk acts as a facade for,
45
47
  * or `null` when this chunk is not an entry facade.
46
48
  */
47
- facadeModuleId: string | null; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
48
- isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite, Rolldown, Rollup input options. */
49
- isEntry: boolean;
50
- /**
51
- * The chunk name as used in `chunkFileNames` and `entryFileNames` patterns,
52
- * without any content hash.
53
- */
54
- name: string; /** File names of chunks that are dynamically imported by this chunk. */
55
- dynamicImports: string[]; /** The emitted file name of the chunk relative to the output directory. */
56
- fileName: string; /** File names of chunks that are statically imported by this chunk. */
49
+ facadeModuleId: string | null; /** File names of chunks that should be loaded before this implicit entry point. */
50
+ implicitlyLoadedBefore: string[]; /** Per-import binding names imported from each dependency chunk, keyed by the imported chunk's file name. */
51
+ importedBindings: Record<string, string[]>; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
52
+ isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite/Rolldown/Rollup input options. */
53
+ isEntry: boolean; /** Whether this chunk is an implicit entry point, loaded after another entry via `implicitlyLoadedAfterOneOf`. */
54
+ isImplicitEntry: boolean; /** File names of chunks that are dynamically imported by this chunk. */
55
+ dynamicImports: string[]; /** File names of chunks that are statically imported by this chunk. */
57
56
  imports: string[];
58
57
  /**
59
58
  * Per-module render stats for every module included in this chunk,
60
59
  * keyed by the module's original file path.
61
60
  */
62
- modules: Record<string, RenderedModule>; /** The rendered JavaScript source code of this chunk. */
63
- code: string; /** Source map for this chunk, or `null` when source maps are not enabled. */
64
- map: SourceMap | null;
61
+ modules: Record<string, RenderedModule>; /** IDs of all modules included in this chunk, in the order they appear in the bundle. */
62
+ moduleIds: string[];
63
+ /**
64
+ * The rendered JavaScript source code of this chunk.,
65
+ * Available when options.stats.source = true (default false)
66
+ */
67
+ code?: string;
68
+ /**
69
+ * Source map for this chunk, or `null` when source maps are not enabled.
70
+ * Available when options.stats.source = true (default: false)
71
+ */
72
+ map?: SourceMap | null; /** Optional Vite-specific metadata. Only present when using Vite. */
73
+ viteMetadata?: {
74
+ /** Set of asset file names imported by this chunk (e.g. images, fonts). */importedAssets: Set<string>; /** Set of CSS file names imported by this chunk. */
75
+ importedCss: Set<string>;
76
+ };
65
77
  };
66
78
  /**
67
79
  * Stats for an individual module included in an output chunk.
68
- *
69
- * @example
70
- * {
71
- * code: 'export { add } from "./math.js";',
72
- * originalLength: 512,
73
- * removedExports: ['subtract'],
74
- * renderedExports: ['add'],
75
- * renderedLength: 34,
76
- * }
77
80
  */
78
81
  type RenderedModule = {
79
82
  /**
80
- * The module code that Vite, Rolldown or Rollup included in the bundle, or `null` when the
83
+ * The module code that Vite/Rolldown/Rollup included in the bundle, or `null` when the
81
84
  * module was fully tree-shaken.
85
+ * Available only when options.stats.source = true (default false)
82
86
  */
83
- readonly code: string | null; /** Size of the original module source in bytes, before any transformations. */
87
+ readonly code?: string | null; /** Size of the original module source in bytes, before any transformations. */
84
88
  originalLength: number; /** Exports removed from this module by tree-shaking. */
85
89
  removedExports: string[]; /** Exports from this module that are retained in the final bundle. */
86
90
  renderedExports: string[]; /** Size of the rendered module code in bytes. */
@@ -96,48 +100,14 @@ type SourceMap = {
96
100
  mappings: string; /** Original symbol names referenced by the mappings. */
97
101
  names: string[]; /** Paths to the original source files. */
98
102
  sources: string[]; /** Optional inline content of each original source file, parallel to `sources`. */
99
- sourcesContent?: string[]; /** Source map specification version — always `3`. */
103
+ sourcesContent?: string[] | undefined; /** Source map specification version — always `3`. */
100
104
  version: number;
101
105
  };
102
106
  /**
103
- * The complete output bundle produced by Vite, Rolldown or Rollup — a map from emitted file name
107
+ * The complete output bundle produced by Vite/Rolldown/Rollup — a map from emitted file name
104
108
  * to its corresponding asset or chunk descriptor.
105
109
  */
106
110
  type OutputBundle = Record<string, OutputAsset | OutputChunk>;
107
- /**
108
- * Relevant subset of Vite, Rolldown, Rollup's output options passed to the `generateBundle` hook.
109
- *
110
- * @example
111
- * { dir: 'dist' }
112
- */
113
- type OutputOptions = {
114
- /** Output directory for the generated files. */dir?: string;
115
- };
116
- /**
117
- * Subset of the Vite, Rolldown, Rollup plugin hook context (`this`) used by this plugin.
118
- */
119
- type PluginContext = {
120
- /** Log an informational message through Vite, Rolldown, Rollup's logging pipeline. */info: (message: string) => void; /** Log a warning through bundler's logging pipeline without stopping the build. */
121
- warn: (message: string) => void;
122
- };
123
- /**
124
- * Minimum plugin interface compatible with Vite, Rolldown and Rollup.
125
- *
126
- * @example
127
- * {
128
- * name: 'rollupStats',
129
- * async generateBundle(outputOptions, bundle) { ... },
130
- * }
131
- */
132
- type Plugin = {
133
- /** Unique identifier for the plugin, used in error messages and logs. */name: string;
134
- /**
135
- * Hook called after the bundle has been fully generated but before it is
136
- * written to disk. Receives the resolved output options and the complete
137
- * output bundle map.
138
- */
139
- generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
140
- };
141
111
  //#endregion
142
- export { OutputAsset, OutputBundle, OutputChunk, OutputOptions, Plugin, RenderedModule };
112
+ export { OutputAsset, OutputBundle, OutputChunk, RenderedModule };
143
113
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAYA;;;;;;;;;;;KAAY,WAAA;EAgCA,+DA9BV,IAAA;EAEA,KAAA,YAyDS;EAvDT,iBAAA,YA2Dc;EAzDd,MAAA,WAAiB,UAAA,EA0BjB;EAxBA,QAAA;AAAA;;;;;;;;;;;;;;;AAsEF;;;;;KAhDY,WAAA;EAyDV,yEAvDA,IAAA,WA2DA;EAzDA,OAAA;EAyDc;AACd;;;EArDA,cAAA,iBA8DA;EA5DA,cAAA,WAgEA;EA9DA,OAAA;EAkEA;;;;EA7DA,IAAA,UAsEsB;EApEtB,cAAA,YAoEwC;EAlExC,QAAA,UAkEyB;EAhEzB,OAAA;EAgE+B;;;;EA3D/B,OAAA,EAAS,MAAA,SAAe,cAAA,GA2DyC;EAzDjE,IAAA,UAiEuB;EA/DvB,GAAA,EAAK,SAAA;AAAA;;AAkEL;;;;;;;;;;AAqBF;KAxEY,cAAA;;;;;WAKD,IAAA,iBAgFU;EA9EnB,cAAA,UAmEA;EAjEA,cAAA,YAwEQ;EAtER,eAAA,YAuEiB;EArEjB,cAAA;AAAA;;;;;;KAQG,SAAA;mEAEH,IAAA;EAEA,QAAA;EAEA,KAAA;EAEA,OAAA;EAEA,cAAA;EAEA,OAAA;AAAA;;;;;KAOU,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA;;;;;;;KAQ5C,aAAA;kDAEV,GAAA;AAAA;;;;KAMG,aAAA;wFAEH,IAAA,GAAO,OAAA;EAEP,IAAA,GAAO,OAAA;AAAA;;;;;;;;;;KAYG,MAAA;2EAEV,IAAA;;;;;;EAMA,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,EAAe,aAAA,EACf,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAGA;;KAAY,WAAA;EACV,IAAA,WAgCkB;EA7BlB,KAAA;EA+BkB;;;;EAzBlB,MAAA,YAAkB,UAAA,EAAA;EAGlB,QAAA;EAMA;;;;EAAA,kBAAA;EAckB;;;;EARlB,gBAAA,iBAiBU;EAdV,iBAAA;EAGA,YAAA;IAkEwB,sFAhEtB,cAAA,EAAgB,GAAA,UA+EZ;IA7EJ,WAAA,EAAa,GAAA;EAAA;AAAA;;;;KAOL,WAAA;EACV,IAAA;EAeA;;;;EATA,IAAA,UA2BA;EAxBA,QAAA,UA2BA;EAxBA,mBAAA,UA8BA;EA3BA,eAAA,YAiCA;EA9BA,iBAAA,iBAoCS;EAjCT,OAAA;EAoCA;;;;EA9BA,cAAA,iBA+CE;EA5CF,sBAAA,YA8CE;EA3CF,gBAAA,EAAkB,MAAA,oBA2CA;EAxClB,cAAA,WA+CU;EA5CV,OAAA;EAGA,eAAA,WA+CS;EA5CT,cAAA,YAkDA;EA/CA,OAAA;EAqDA;;;AACA;EAhDA,OAAA,EAAS,MAAA,SAAe,cAAA;EAGxB,SAAA;EAsDA;;;;EAhDA,IAAA;EA0DA;;;AAOF;EA3DE,GAAA,GAAM,SAAA;EAGN,YAAA;IAwDsD,2EAtDpD,cAAA,EAAgB,GAAA,UAsDa;IApD7B,WAAA,EAAa,GAAA;EAAA;AAAA;;;;KAOL,cAAA;;;;;;WAMD,IAAA;EAGT,cAAA;EAGA,cAAA;EAGA,eAAA;EAGA,cAAA;AAAA;;;;;;KAQG,SAAA;mEAEH,IAAA;EAEA,QAAA;EAEA,KAAA;EAEA,OAAA;EAEA,cAAA;EAEA,OAAA;AAAA;;;;;KAOU,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA"}
@@ -1,86 +1,90 @@
1
1
  //#region src/types.d.ts
2
2
  /**
3
3
  * A generated asset entry in the output bundle (e.g. CSS, images, JSON).
4
- *
5
- * @example
6
- * {
7
- * type: 'asset',
8
- * fileName: 'assets/logo-CvPeBknE.svg',
9
- * names: ['logo'],
10
- * originalFileNames: ['src/assets/logo.svg'],
11
- * source: '<svg xmlns="http://www.w3.org/2000/svg">...</svg>',
12
- * }
13
4
  */
14
5
  type OutputAsset = {
15
- /** Discriminant literal identifying this entry as an asset. */type: 'asset'; /** All entry names that reference this asset. */
16
- names: string[]; /** Original source file names this asset was generated from. */
17
- originalFileNames: string[]; /** The asset content as a string (text assets) or a `Uint8Array` (binary assets). */
18
- source: string | Uint8Array; /** The emitted file name of the asset relative to the output directory. */
6
+ type: 'asset'; /** All entry names that reference this asset. */
7
+ names: string[];
8
+ /**
9
+ * The asset content as a string (text assets) or a `Uint8Array` (binary assets).
10
+ * Available when options.stats.source = true (default false)
11
+ */
12
+ source?: string | Uint8Array; /** The emitted file name of the asset relative to the output directory. */
19
13
  fileName: string;
14
+ /**
15
+ * Whether this asset requires a code reference (`import.meta.ROLLUP_FILE_URL_<id>`)
16
+ * to be included in the bundle.
17
+ */
18
+ needsCodeReference: boolean;
19
+ /**
20
+ * The original file name of the source asset before any transformations, or `null` when not applicable.
21
+ * @deprecated Use `originalFileNames` instead.
22
+ */
23
+ originalFileName: string | null; /** The original file names of the source assets before any transformations. */
24
+ originalFileNames: string[]; /** Optional Vite-specific metadata. Only present when using Vite. */
25
+ viteMetadata?: {
26
+ /** Set of asset file names imported by this asset (e.g. images referenced in CSS). */importedAssets: Set<string>; /** Set of CSS file names imported by this asset. */
27
+ importedCss: Set<string>;
28
+ };
20
29
  };
21
30
  /**
22
31
  * A generated JavaScript chunk entry in the output bundle.
23
- *
24
- * @example
25
- * {
26
- * type: 'chunk',
27
- * fileName: 'assets/index-DpgTxXR6.js',
28
- * name: 'index',
29
- * facadeModuleId: '/project/src/index.ts',
30
- * isEntry: true,
31
- * isDynamicEntry: false,
32
- * exports: ['default'],
33
- * imports: ['assets/vendor-CvaBJZ2l.js'],
34
- * dynamicImports: ['assets/lazy-Dj3OKb2X.js'],
35
- * modules: { '/project/src/index.ts': { renderedLength: 120, ... } },
36
- * code: '"use strict";...',
37
- * map: null,
38
- * }
39
32
  */
40
33
  type OutputChunk = {
41
- /** Discriminant literal identifying this entry as a JavaScript chunk. */type: 'chunk'; /** Names exported by this chunk. */
34
+ type: 'chunk';
35
+ /**
36
+ * The chunk name as used in `chunkFileNames` and `entryFileNames` patterns,
37
+ * without any content hash.
38
+ */
39
+ name: string; /** The emitted file name of the chunk relative to the output directory. */
40
+ fileName: string; /** The file name of this chunk before content hashes are applied. */
41
+ preliminaryFileName: string; /** File names of assets referenced via `import.meta.ROLLUP_FILE_URL_<id>` in this chunk. */
42
+ referencedFiles: string[]; /** The file name of the source map for this chunk, or `null` when source maps are not generated. */
43
+ sourcemapFileName: string | null; /** Names exported by this chunk. */
42
44
  exports: string[];
43
45
  /**
44
46
  * The module ID of the entry point that this chunk acts as a facade for,
45
47
  * or `null` when this chunk is not an entry facade.
46
48
  */
47
- facadeModuleId: string | null; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
48
- isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite, Rolldown, Rollup input options. */
49
- isEntry: boolean;
50
- /**
51
- * The chunk name as used in `chunkFileNames` and `entryFileNames` patterns,
52
- * without any content hash.
53
- */
54
- name: string; /** File names of chunks that are dynamically imported by this chunk. */
55
- dynamicImports: string[]; /** The emitted file name of the chunk relative to the output directory. */
56
- fileName: string; /** File names of chunks that are statically imported by this chunk. */
49
+ facadeModuleId: string | null; /** File names of chunks that should be loaded before this implicit entry point. */
50
+ implicitlyLoadedBefore: string[]; /** Per-import binding names imported from each dependency chunk, keyed by the imported chunk's file name. */
51
+ importedBindings: Record<string, string[]>; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
52
+ isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite/Rolldown/Rollup input options. */
53
+ isEntry: boolean; /** Whether this chunk is an implicit entry point, loaded after another entry via `implicitlyLoadedAfterOneOf`. */
54
+ isImplicitEntry: boolean; /** File names of chunks that are dynamically imported by this chunk. */
55
+ dynamicImports: string[]; /** File names of chunks that are statically imported by this chunk. */
57
56
  imports: string[];
58
57
  /**
59
58
  * Per-module render stats for every module included in this chunk,
60
59
  * keyed by the module's original file path.
61
60
  */
62
- modules: Record<string, RenderedModule>; /** The rendered JavaScript source code of this chunk. */
63
- code: string; /** Source map for this chunk, or `null` when source maps are not enabled. */
64
- map: SourceMap | null;
61
+ modules: Record<string, RenderedModule>; /** IDs of all modules included in this chunk, in the order they appear in the bundle. */
62
+ moduleIds: string[];
63
+ /**
64
+ * The rendered JavaScript source code of this chunk.,
65
+ * Available when options.stats.source = true (default false)
66
+ */
67
+ code?: string;
68
+ /**
69
+ * Source map for this chunk, or `null` when source maps are not enabled.
70
+ * Available when options.stats.source = true (default: false)
71
+ */
72
+ map?: SourceMap | null; /** Optional Vite-specific metadata. Only present when using Vite. */
73
+ viteMetadata?: {
74
+ /** Set of asset file names imported by this chunk (e.g. images, fonts). */importedAssets: Set<string>; /** Set of CSS file names imported by this chunk. */
75
+ importedCss: Set<string>;
76
+ };
65
77
  };
66
78
  /**
67
79
  * Stats for an individual module included in an output chunk.
68
- *
69
- * @example
70
- * {
71
- * code: 'export { add } from "./math.js";',
72
- * originalLength: 512,
73
- * removedExports: ['subtract'],
74
- * renderedExports: ['add'],
75
- * renderedLength: 34,
76
- * }
77
80
  */
78
81
  type RenderedModule = {
79
82
  /**
80
- * The module code that Vite, Rolldown or Rollup included in the bundle, or `null` when the
83
+ * The module code that Vite/Rolldown/Rollup included in the bundle, or `null` when the
81
84
  * module was fully tree-shaken.
85
+ * Available only when options.stats.source = true (default false)
82
86
  */
83
- readonly code: string | null; /** Size of the original module source in bytes, before any transformations. */
87
+ readonly code?: string | null; /** Size of the original module source in bytes, before any transformations. */
84
88
  originalLength: number; /** Exports removed from this module by tree-shaking. */
85
89
  removedExports: string[]; /** Exports from this module that are retained in the final bundle. */
86
90
  renderedExports: string[]; /** Size of the rendered module code in bytes. */
@@ -96,48 +100,14 @@ type SourceMap = {
96
100
  mappings: string; /** Original symbol names referenced by the mappings. */
97
101
  names: string[]; /** Paths to the original source files. */
98
102
  sources: string[]; /** Optional inline content of each original source file, parallel to `sources`. */
99
- sourcesContent?: string[]; /** Source map specification version — always `3`. */
103
+ sourcesContent?: string[] | undefined; /** Source map specification version — always `3`. */
100
104
  version: number;
101
105
  };
102
106
  /**
103
- * The complete output bundle produced by Vite, Rolldown or Rollup — a map from emitted file name
107
+ * The complete output bundle produced by Vite/Rolldown/Rollup — a map from emitted file name
104
108
  * to its corresponding asset or chunk descriptor.
105
109
  */
106
110
  type OutputBundle = Record<string, OutputAsset | OutputChunk>;
107
- /**
108
- * Relevant subset of Vite, Rolldown, Rollup's output options passed to the `generateBundle` hook.
109
- *
110
- * @example
111
- * { dir: 'dist' }
112
- */
113
- type OutputOptions = {
114
- /** Output directory for the generated files. */dir?: string;
115
- };
116
- /**
117
- * Subset of the Vite, Rolldown, Rollup plugin hook context (`this`) used by this plugin.
118
- */
119
- type PluginContext = {
120
- /** Log an informational message through Vite, Rolldown, Rollup's logging pipeline. */info: (message: string) => void; /** Log a warning through bundler's logging pipeline without stopping the build. */
121
- warn: (message: string) => void;
122
- };
123
- /**
124
- * Minimum plugin interface compatible with Vite, Rolldown and Rollup.
125
- *
126
- * @example
127
- * {
128
- * name: 'rollupStats',
129
- * async generateBundle(outputOptions, bundle) { ... },
130
- * }
131
- */
132
- type Plugin = {
133
- /** Unique identifier for the plugin, used in error messages and logs. */name: string;
134
- /**
135
- * Hook called after the bundle has been fully generated but before it is
136
- * written to disk. Receives the resolved output options and the complete
137
- * output bundle map.
138
- */
139
- generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
140
- };
141
111
  //#endregion
142
- export { OutputAsset, OutputBundle, OutputChunk, OutputOptions, Plugin, RenderedModule };
112
+ export { OutputAsset, OutputBundle, OutputChunk, RenderedModule };
143
113
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAYA;;;;;;;;;;;KAAY,WAAA;EAgCA,+DA9BV,IAAA;EAEA,KAAA,YAyDS;EAvDT,iBAAA,YA2Dc;EAzDd,MAAA,WAAiB,UAAA,EA0BjB;EAxBA,QAAA;AAAA;;;;;;;;;;;;;;;AAsEF;;;;;KAhDY,WAAA;EAyDV,yEAvDA,IAAA,WA2DA;EAzDA,OAAA;EAyDc;AACd;;;EArDA,cAAA,iBA8DA;EA5DA,cAAA,WAgEA;EA9DA,OAAA;EAkEA;;;;EA7DA,IAAA,UAsEsB;EApEtB,cAAA,YAoEwC;EAlExC,QAAA,UAkEyB;EAhEzB,OAAA;EAgE+B;;;;EA3D/B,OAAA,EAAS,MAAA,SAAe,cAAA,GA2DyC;EAzDjE,IAAA,UAiEuB;EA/DvB,GAAA,EAAK,SAAA;AAAA;;AAkEL;;;;;;;;;;AAqBF;KAxEY,cAAA;;;;;WAKD,IAAA,iBAgFU;EA9EnB,cAAA,UAmEA;EAjEA,cAAA,YAwEQ;EAtER,eAAA,YAuEiB;EArEjB,cAAA;AAAA;;;;;;KAQG,SAAA;mEAEH,IAAA;EAEA,QAAA;EAEA,KAAA;EAEA,OAAA;EAEA,cAAA;EAEA,OAAA;AAAA;;;;;KAOU,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA;;;;;;;KAQ5C,aAAA;kDAEV,GAAA;AAAA;;;;KAMG,aAAA;wFAEH,IAAA,GAAO,OAAA;EAEP,IAAA,GAAO,OAAA;AAAA;;;;;;;;;;KAYG,MAAA;2EAEV,IAAA;;;;;;EAMA,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,EAAe,aAAA,EACf,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAGA;;KAAY,WAAA;EACV,IAAA,WAgCkB;EA7BlB,KAAA;EA+BkB;;;;EAzBlB,MAAA,YAAkB,UAAA,EAAA;EAGlB,QAAA;EAMA;;;;EAAA,kBAAA;EAckB;;;;EARlB,gBAAA,iBAiBU;EAdV,iBAAA;EAGA,YAAA;IAkEwB,sFAhEtB,cAAA,EAAgB,GAAA,UA+EZ;IA7EJ,WAAA,EAAa,GAAA;EAAA;AAAA;;;;KAOL,WAAA;EACV,IAAA;EAeA;;;;EATA,IAAA,UA2BA;EAxBA,QAAA,UA2BA;EAxBA,mBAAA,UA8BA;EA3BA,eAAA,YAiCA;EA9BA,iBAAA,iBAoCS;EAjCT,OAAA;EAoCA;;;;EA9BA,cAAA,iBA+CE;EA5CF,sBAAA,YA8CE;EA3CF,gBAAA,EAAkB,MAAA,oBA2CA;EAxClB,cAAA,WA+CU;EA5CV,OAAA;EAGA,eAAA,WA+CS;EA5CT,cAAA,YAkDA;EA/CA,OAAA;EAqDA;;;AACA;EAhDA,OAAA,EAAS,MAAA,SAAe,cAAA;EAGxB,SAAA;EAsDA;;;;EAhDA,IAAA;EA0DA;;;AAOF;EA3DE,GAAA,GAAM,SAAA;EAGN,YAAA;IAwDsD,2EAtDpD,cAAA,EAAgB,GAAA,UAsDa;IApD7B,WAAA,EAAa,GAAA;EAAA;AAAA;;;;KAOL,cAAA;;;;;;WAMD,IAAA;EAGT,cAAA;EAGA,cAAA;EAGA,eAAA;EAGA,cAAA;AAAA;;;;;;KAQG,SAAA;mEAEH,IAAA;EAEA,QAAA;EAEA,KAAA;EAEA,OAAA;EAEA,cAAA;EAEA,OAAA;AAAA;;;;;KAOU,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rollup-plugin-stats",
3
3
  "description": "Vite/Rolldown/Rollup plugin to generate bundle stats JSON file",
4
- "version": "2.1.1-beta.0",
4
+ "version": "2.1.1-beta.3",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;KAWY,kBAAA;;AAAZ;;;EAKE,QAAA;EAAA;;;EAIA,KAAA,GAAQ,YAAA;EAKA;;;AACR;EADA,KAAA,GAAQ,gBAAA;AAAA;AAAA,KAGL,iCAAA,GACD,kBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,kBAAA;AAAA,iBAE9B,WAAA,CAAY,OAAA,GAAS,iCAAA,GAAyC,MAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;KAWY,kBAAA;;AAAZ;;;EAKE,QAAA;EAAA;;;EAIA,KAAA,GAAQ,YAAA;EAKA;;;AACR;EADA,KAAA,GAAQ,gBAAA;AAAA;AAAA,KAGL,iCAAA,GACD,kBAAA,KACE,aAAA,EAAe,aAAA,KAAkB,kBAAA;AAAA,iBAE9B,WAAA,CAAY,OAAA,GAAS,iCAAA,GAAyC,MAAA"}