rollup-plugin-stats 2.1.1-beta.1 → 2.1.1-beta.4
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 +3 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -26
- package/dist/index.d.mts +3 -26
- package/dist/index.mjs +3 -27
- package/dist/index.mjs.map +1 -1
- package/dist/src/plugin.cjs +35 -0
- package/dist/src/plugin.cjs.map +1 -0
- package/dist/src/plugin.d.cts +59 -0
- package/dist/src/plugin.d.cts.map +1 -0
- package/dist/src/plugin.d.mts +59 -0
- package/dist/src/plugin.d.mts.map +1 -0
- package/dist/src/plugin.mjs +32 -0
- package/dist/src/plugin.mjs.map +1 -0
- package/dist/src/types.d.cts +91 -120
- package/dist/src/types.d.cts.map +1 -1
- package/dist/src/types.d.mts +91 -120
- package/dist/src/types.d.mts.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
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 =
|
|
7
|
+
module.exports = src_default;
|
|
35
8
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
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 {
|
|
7
|
+
export { src_default as default };
|
|
32
8
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import
|
|
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"}
|
package/dist/src/types.d.cts
CHANGED
|
@@ -1,155 +1,126 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Standard source map v3 object mapping generated code back to original sources.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
* }
|
|
5
|
+
* @see https://sourcemaps.info/spec.html
|
|
6
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L98
|
|
7
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L26
|
|
13
8
|
*/
|
|
14
|
-
type
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
type SourceMap = {
|
|
10
|
+
/** Name of the generated file this source map corresponds to. */file: string; /** Base64 VLQ-encoded string describing the source mappings. */
|
|
11
|
+
mappings: string; /** Original symbol names referenced by the mappings. */
|
|
12
|
+
names: string[]; /** Paths to the original source files. */
|
|
13
|
+
sources: string[]; /** Optional inline content of each original source file, parallel to `sources`. */
|
|
14
|
+
sourcesContent?: string[] | undefined; /** Source map specification version — always `3`. */
|
|
15
|
+
version: number;
|
|
20
16
|
};
|
|
21
17
|
/**
|
|
22
|
-
* A generated
|
|
18
|
+
* A generated asset entry in the output bundle (e.g. CSS, images, JSON).
|
|
23
19
|
*
|
|
24
|
-
* @
|
|
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
|
-
* }
|
|
20
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L958
|
|
21
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L85
|
|
39
22
|
*/
|
|
40
|
-
type
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
type OutputAsset = {
|
|
24
|
+
type: 'asset'; /** The emitted file name of the asset relative to the output directory. */
|
|
25
|
+
fileName: string;
|
|
43
26
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
27
|
+
* The asset name, or `undefined` when not available.
|
|
28
|
+
* @deprecated Use `names` instead.
|
|
46
29
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isEntry: boolean;
|
|
30
|
+
name: string | undefined; /** All entry names that reference this asset. */
|
|
31
|
+
names: string[];
|
|
50
32
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
33
|
+
* The original file name of the source asset before any transformations, or `null` when not applicable.
|
|
34
|
+
* @deprecated Use `originalFileNames` instead.
|
|
53
35
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fileName: string; /** File names of chunks that are statically imported by this chunk. */
|
|
57
|
-
imports: string[];
|
|
36
|
+
originalFileName: string | null; /** The original file names of the source assets before any transformations. */
|
|
37
|
+
originalFileNames: string[];
|
|
58
38
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
39
|
+
* The asset content as a string (text assets) or a `Uint8Array` (binary assets).
|
|
40
|
+
* Available when options.stats.source = true (default false)
|
|
41
|
+
*/
|
|
42
|
+
source?: string | Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Rollup - Whether this asset requires a code reference (`import.meta.ROLLUP_FILE_URL_<id>`)
|
|
45
|
+
* to be included in the bundle.
|
|
46
|
+
*
|
|
47
|
+
* @see https://github.com/rollup/rollup/issues/4774
|
|
61
48
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
needsCodeReference?: boolean; /** Vite - specific metadata */
|
|
50
|
+
viteMetadata?: {
|
|
51
|
+
/** 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. */
|
|
52
|
+
importedCss: Set<string>;
|
|
53
|
+
};
|
|
65
54
|
};
|
|
66
55
|
/**
|
|
67
56
|
* Stats for an individual module included in an output chunk.
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
* {
|
|
71
|
-
* code: 'export { add } from "./math.js";',
|
|
72
|
-
* originalLength: 512,
|
|
73
|
-
* removedExports: ['subtract'],
|
|
74
|
-
* renderedExports: ['add'],
|
|
75
|
-
* renderedLength: 34,
|
|
76
|
-
* }
|
|
57
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L963
|
|
58
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L40
|
|
77
59
|
*/
|
|
78
60
|
type RenderedModule = {
|
|
79
61
|
/**
|
|
80
62
|
* The module code that Vite/Rolldown/Rollup included in the bundle, or `null` when the
|
|
81
63
|
* module was fully tree-shaken.
|
|
64
|
+
* Available only when options.stats.source = true (default false)
|
|
82
65
|
*/
|
|
83
|
-
readonly code
|
|
84
|
-
originalLength: number; /**
|
|
85
|
-
removedExports
|
|
86
|
-
renderedExports: string[]; /**
|
|
87
|
-
renderedLength
|
|
66
|
+
readonly code?: string | null; /** Size of the original module source in bytes, before any transformations. */
|
|
67
|
+
originalLength: number; /** Rollup - exports removed from this module by tree-shaking. */
|
|
68
|
+
removedExports?: string[]; /** Exports from this module that are retained in the final bundle. */
|
|
69
|
+
renderedExports: string[]; /** Rollup - size of the rendered module code in bytes. */
|
|
70
|
+
renderedLength?: number;
|
|
88
71
|
};
|
|
89
72
|
/**
|
|
90
|
-
*
|
|
73
|
+
* A generated JavaScript chunk entry in the output bundle.
|
|
91
74
|
*
|
|
92
|
-
* @see https://
|
|
75
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L992
|
|
76
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L85
|
|
93
77
|
*/
|
|
94
|
-
type
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
type OutputChunk = {
|
|
79
|
+
type: 'chunk'; /** The chunk name as used in `chunkFileNames` and `entryFileNames` patterns */
|
|
80
|
+
name: string; /** The emitted file name of the chunk relative to the output directory. */
|
|
81
|
+
fileName: string; /** The file name of this chunk before content hashes are applied. */
|
|
82
|
+
preliminaryFileName: string; /** Rollup - file names of assets referenced via `import.meta.ROLLUP_FILE_URL_<id>` in this chunk. */
|
|
83
|
+
referencedFiles?: string[]; /** The file name of the source map for this chunk, or `null` when source maps are not generated. */
|
|
84
|
+
sourcemapFileName: string | null; /** Names exported by this chunk. */
|
|
85
|
+
exports: string[];
|
|
86
|
+
/**
|
|
87
|
+
* The module ID of the entry point that this chunk acts as a facade for,
|
|
88
|
+
* or `null` when this chunk is not an entry facade.
|
|
89
|
+
*/
|
|
90
|
+
facadeModuleId: string | null; /** Rollup - file names of chunks that should be loaded before this implicit entry point. */
|
|
91
|
+
implicitlyLoadedBefore?: string[]; /** Rollup - per-import binding names imported from each dependency chunk, keyed by the imported chunk's file name. */
|
|
92
|
+
importedBindings?: Record<string, string[]>; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
|
|
93
|
+
isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite/Rolldown/Rollup input options. */
|
|
94
|
+
isEntry: boolean; /** Rollup - whether this chunk is an implicit entry point, loaded after another entry via `implicitlyLoadedAfterOneOf`. */
|
|
95
|
+
isImplicitEntry: boolean; /** File names of chunks that are dynamically imported by this chunk. */
|
|
96
|
+
dynamicImports: string[]; /** File names of chunks that are statically imported by this chunk. */
|
|
97
|
+
imports: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Per-module render stats for every module included in this chunk,
|
|
100
|
+
* keyed by the module's original file path.
|
|
101
|
+
*/
|
|
102
|
+
modules: Record<string, RenderedModule>; /** IDs of all modules included in this chunk, in the order they appear in the bundle. */
|
|
103
|
+
moduleIds: string[];
|
|
104
|
+
/**
|
|
105
|
+
* The rendered JavaScript source code of this chunk.,
|
|
106
|
+
* Available when options.stats.source = true (default false)
|
|
107
|
+
*/
|
|
108
|
+
code?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Source map for this chunk, or `null` when source maps are not enabled.
|
|
111
|
+
* Available when options.stats.source = true (default: false)
|
|
112
|
+
*/
|
|
113
|
+
map?: SourceMap | null; /** Vite - Optional specific metadata */
|
|
114
|
+
viteMetadata?: {
|
|
115
|
+
/** 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. */
|
|
116
|
+
importedCss: Set<string>;
|
|
117
|
+
};
|
|
101
118
|
};
|
|
102
119
|
/**
|
|
103
120
|
* The complete output bundle produced by Vite/Rolldown/Rollup — a map from emitted file name
|
|
104
121
|
* to its corresponding asset or chunk descriptor.
|
|
105
122
|
*/
|
|
106
123
|
type OutputBundle = Record<string, OutputAsset | OutputChunk>;
|
|
107
|
-
/**
|
|
108
|
-
* A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,
|
|
109
|
-
* containing only the fields this plugin uses to generate a stats file for a specific output.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* { dir: 'dist', format: 'es' }
|
|
113
|
-
*/
|
|
114
|
-
type OutputOptions = {
|
|
115
|
-
/** Output directory for the generated files. */dir?: string | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Output format.
|
|
118
|
-
*
|
|
119
|
-
* - `'es'` / `'esm'` / `'module'` — ES module
|
|
120
|
-
* - `'cjs'` / `'commonjs'` — CommonJS
|
|
121
|
-
* - `'iife'` — Immediately Invoked Function Expression
|
|
122
|
-
* - `'umd'` — Universal Module Definition
|
|
123
|
-
* - `'amd'` — Asynchronous Module Definition (Rollup only)
|
|
124
|
-
* - `'system'` / `'systemjs'` — SystemJS (Rollup only)
|
|
125
|
-
*/
|
|
126
|
-
format?: 'es' | 'esm' | 'module' | 'cjs' | 'commonjs' | 'iife' | 'umd' | 'amd' | 'system' | 'systemjs' | undefined;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Subset of the Vite/RollDown/Rollup plugin hook context (`this`) used by this plugin.
|
|
130
|
-
*/
|
|
131
|
-
type PluginContext = {
|
|
132
|
-
/** 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. */
|
|
133
|
-
warn: (message: string) => void;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Minimum plugin interface compatible with Vite/Rolldown/Rollup.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* {
|
|
140
|
-
* name: 'rollupStats',
|
|
141
|
-
* async generateBundle(outputOptions, bundle) { ... },
|
|
142
|
-
* }
|
|
143
|
-
*/
|
|
144
|
-
type Plugin = {
|
|
145
|
-
/** Unique identifier for the plugin, used in error messages and logs. */name: string;
|
|
146
|
-
/**
|
|
147
|
-
* Hook called after the bundle has been fully generated but before it is
|
|
148
|
-
* written to disk. Receives the resolved output options and the complete
|
|
149
|
-
* output bundle map.
|
|
150
|
-
*/
|
|
151
|
-
generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
|
|
152
|
-
};
|
|
153
124
|
//#endregion
|
|
154
|
-
export { OutputAsset, OutputBundle, OutputChunk,
|
|
125
|
+
export { OutputAsset, OutputBundle, OutputChunk, RenderedModule };
|
|
155
126
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/src/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAOA;;;;;;KAAY,SAAA;EAQV,iEANA,IAAA,UAUA;EARA,QAAA,UAQO;EANP,KAAA,YAeqB;EAbrB,OAAA,YAyCkB;EAvClB,cAAA,yBAsDe;EApDf,OAAA;AAAA;;;;;;;KASU,WAAA;EACV,IAAA,WAmCA;EAhCA,QAAA;EAqCE;;;;EA/BF,IAAA,sBAiCkB;EA9BlB,KAAA;EAuCwB;;;;EAjCxB,gBAAA,iBA6CA;EA1CA,iBAAA;EAgDA;;;AASF;EAnDE,MAAA,YAAkB,UAAA;;;;;;;EAQlB,kBAAA,YAqHkB;EAlHlB,YAAA;IAyCA,sFAvCE,cAAA,EAAgB,GAAA,UA6ClB;IA3CE,WAAA,EAAa,GAAA;EAAA;AAAA;;;;;;KASL,cAAA;EAgEV;;;;;EAAA,SA1DS,IAAA,kBAyEe;EAtExB,cAAA,UA+EA;EA5EA,cAAA,aAkFM;EA/EN,eAAA,YAoFE;EAjFF,cAAA;AAAA;;;;AA2FF;;;KAlFY,WAAA;EACV,IAAA,WAiFyB;EA9EzB,IAAA,UA8E+B;EA3E/B,QAAA,UA2EwC;EAxExC,mBAAA,UAwEiE;EArEjE,eAAA;EAGA,iBAAA;EAGA,OAAA;;;;;EAMA,cAAA;EAGA,sBAAA;EAGA,gBAAA,GAAmB,MAAA;EAGnB,cAAA;EAGA,OAAA;EAGA,eAAA;EAGA,cAAA;EAGA,OAAA;;;;;EAMA,OAAA,EAAS,MAAA,SAAe,cAAA;EAGxB,SAAA;;;;;EAMA,IAAA;;;;;EAMA,GAAA,GAAM,SAAA;EAGN,YAAA;+EAEE,cAAA,EAAgB,GAAA;IAEhB,WAAA,EAAa,GAAA;EAAA;AAAA;;;;;KAQL,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA"}
|
package/dist/src/types.d.mts
CHANGED
|
@@ -1,155 +1,126 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Standard source map v3 object mapping generated code back to original sources.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
* }
|
|
5
|
+
* @see https://sourcemaps.info/spec.html
|
|
6
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L98
|
|
7
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L26
|
|
13
8
|
*/
|
|
14
|
-
type
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
type SourceMap = {
|
|
10
|
+
/** Name of the generated file this source map corresponds to. */file: string; /** Base64 VLQ-encoded string describing the source mappings. */
|
|
11
|
+
mappings: string; /** Original symbol names referenced by the mappings. */
|
|
12
|
+
names: string[]; /** Paths to the original source files. */
|
|
13
|
+
sources: string[]; /** Optional inline content of each original source file, parallel to `sources`. */
|
|
14
|
+
sourcesContent?: string[] | undefined; /** Source map specification version — always `3`. */
|
|
15
|
+
version: number;
|
|
20
16
|
};
|
|
21
17
|
/**
|
|
22
|
-
* A generated
|
|
18
|
+
* A generated asset entry in the output bundle (e.g. CSS, images, JSON).
|
|
23
19
|
*
|
|
24
|
-
* @
|
|
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
|
-
* }
|
|
20
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L958
|
|
21
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L85
|
|
39
22
|
*/
|
|
40
|
-
type
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
type OutputAsset = {
|
|
24
|
+
type: 'asset'; /** The emitted file name of the asset relative to the output directory. */
|
|
25
|
+
fileName: string;
|
|
43
26
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
27
|
+
* The asset name, or `undefined` when not available.
|
|
28
|
+
* @deprecated Use `names` instead.
|
|
46
29
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isEntry: boolean;
|
|
30
|
+
name: string | undefined; /** All entry names that reference this asset. */
|
|
31
|
+
names: string[];
|
|
50
32
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
33
|
+
* The original file name of the source asset before any transformations, or `null` when not applicable.
|
|
34
|
+
* @deprecated Use `originalFileNames` instead.
|
|
53
35
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fileName: string; /** File names of chunks that are statically imported by this chunk. */
|
|
57
|
-
imports: string[];
|
|
36
|
+
originalFileName: string | null; /** The original file names of the source assets before any transformations. */
|
|
37
|
+
originalFileNames: string[];
|
|
58
38
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
39
|
+
* The asset content as a string (text assets) or a `Uint8Array` (binary assets).
|
|
40
|
+
* Available when options.stats.source = true (default false)
|
|
41
|
+
*/
|
|
42
|
+
source?: string | Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Rollup - Whether this asset requires a code reference (`import.meta.ROLLUP_FILE_URL_<id>`)
|
|
45
|
+
* to be included in the bundle.
|
|
46
|
+
*
|
|
47
|
+
* @see https://github.com/rollup/rollup/issues/4774
|
|
61
48
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
needsCodeReference?: boolean; /** Vite - specific metadata */
|
|
50
|
+
viteMetadata?: {
|
|
51
|
+
/** 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. */
|
|
52
|
+
importedCss: Set<string>;
|
|
53
|
+
};
|
|
65
54
|
};
|
|
66
55
|
/**
|
|
67
56
|
* Stats for an individual module included in an output chunk.
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
* {
|
|
71
|
-
* code: 'export { add } from "./math.js";',
|
|
72
|
-
* originalLength: 512,
|
|
73
|
-
* removedExports: ['subtract'],
|
|
74
|
-
* renderedExports: ['add'],
|
|
75
|
-
* renderedLength: 34,
|
|
76
|
-
* }
|
|
57
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L963
|
|
58
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L40
|
|
77
59
|
*/
|
|
78
60
|
type RenderedModule = {
|
|
79
61
|
/**
|
|
80
62
|
* The module code that Vite/Rolldown/Rollup included in the bundle, or `null` when the
|
|
81
63
|
* module was fully tree-shaken.
|
|
64
|
+
* Available only when options.stats.source = true (default false)
|
|
82
65
|
*/
|
|
83
|
-
readonly code
|
|
84
|
-
originalLength: number; /**
|
|
85
|
-
removedExports
|
|
86
|
-
renderedExports: string[]; /**
|
|
87
|
-
renderedLength
|
|
66
|
+
readonly code?: string | null; /** Size of the original module source in bytes, before any transformations. */
|
|
67
|
+
originalLength: number; /** Rollup - exports removed from this module by tree-shaking. */
|
|
68
|
+
removedExports?: string[]; /** Exports from this module that are retained in the final bundle. */
|
|
69
|
+
renderedExports: string[]; /** Rollup - size of the rendered module code in bytes. */
|
|
70
|
+
renderedLength?: number;
|
|
88
71
|
};
|
|
89
72
|
/**
|
|
90
|
-
*
|
|
73
|
+
* A generated JavaScript chunk entry in the output bundle.
|
|
91
74
|
*
|
|
92
|
-
* @see https://
|
|
75
|
+
* @see https://github.com/rollup/rollup/blob/master/src/rollup/types.d.ts#L992
|
|
76
|
+
* @see https://github.com/rolldown/rolldown/blob/main/packages/rolldown/src/types/rolldown-output.ts#L85
|
|
93
77
|
*/
|
|
94
|
-
type
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
type OutputChunk = {
|
|
79
|
+
type: 'chunk'; /** The chunk name as used in `chunkFileNames` and `entryFileNames` patterns */
|
|
80
|
+
name: string; /** The emitted file name of the chunk relative to the output directory. */
|
|
81
|
+
fileName: string; /** The file name of this chunk before content hashes are applied. */
|
|
82
|
+
preliminaryFileName: string; /** Rollup - file names of assets referenced via `import.meta.ROLLUP_FILE_URL_<id>` in this chunk. */
|
|
83
|
+
referencedFiles?: string[]; /** The file name of the source map for this chunk, or `null` when source maps are not generated. */
|
|
84
|
+
sourcemapFileName: string | null; /** Names exported by this chunk. */
|
|
85
|
+
exports: string[];
|
|
86
|
+
/**
|
|
87
|
+
* The module ID of the entry point that this chunk acts as a facade for,
|
|
88
|
+
* or `null` when this chunk is not an entry facade.
|
|
89
|
+
*/
|
|
90
|
+
facadeModuleId: string | null; /** Rollup - file names of chunks that should be loaded before this implicit entry point. */
|
|
91
|
+
implicitlyLoadedBefore?: string[]; /** Rollup - per-import binding names imported from each dependency chunk, keyed by the imported chunk's file name. */
|
|
92
|
+
importedBindings?: Record<string, string[]>; /** Whether this chunk is a dynamic entry point (i.e. produced by a dynamic `import()`). */
|
|
93
|
+
isDynamicEntry: boolean; /** Whether this chunk is a static entry point declared in the Vite/Rolldown/Rollup input options. */
|
|
94
|
+
isEntry: boolean; /** Rollup - whether this chunk is an implicit entry point, loaded after another entry via `implicitlyLoadedAfterOneOf`. */
|
|
95
|
+
isImplicitEntry: boolean; /** File names of chunks that are dynamically imported by this chunk. */
|
|
96
|
+
dynamicImports: string[]; /** File names of chunks that are statically imported by this chunk. */
|
|
97
|
+
imports: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Per-module render stats for every module included in this chunk,
|
|
100
|
+
* keyed by the module's original file path.
|
|
101
|
+
*/
|
|
102
|
+
modules: Record<string, RenderedModule>; /** IDs of all modules included in this chunk, in the order they appear in the bundle. */
|
|
103
|
+
moduleIds: string[];
|
|
104
|
+
/**
|
|
105
|
+
* The rendered JavaScript source code of this chunk.,
|
|
106
|
+
* Available when options.stats.source = true (default false)
|
|
107
|
+
*/
|
|
108
|
+
code?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Source map for this chunk, or `null` when source maps are not enabled.
|
|
111
|
+
* Available when options.stats.source = true (default: false)
|
|
112
|
+
*/
|
|
113
|
+
map?: SourceMap | null; /** Vite - Optional specific metadata */
|
|
114
|
+
viteMetadata?: {
|
|
115
|
+
/** 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. */
|
|
116
|
+
importedCss: Set<string>;
|
|
117
|
+
};
|
|
101
118
|
};
|
|
102
119
|
/**
|
|
103
120
|
* The complete output bundle produced by Vite/Rolldown/Rollup — a map from emitted file name
|
|
104
121
|
* to its corresponding asset or chunk descriptor.
|
|
105
122
|
*/
|
|
106
123
|
type OutputBundle = Record<string, OutputAsset | OutputChunk>;
|
|
107
|
-
/**
|
|
108
|
-
* A subset of resolved output options provided to the `generateBundle` hook by Vite/Rolldown/Rollup,
|
|
109
|
-
* containing only the fields this plugin uses to generate a stats file for a specific output.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* { dir: 'dist', format: 'es' }
|
|
113
|
-
*/
|
|
114
|
-
type OutputOptions = {
|
|
115
|
-
/** Output directory for the generated files. */dir?: string | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Output format.
|
|
118
|
-
*
|
|
119
|
-
* - `'es'` / `'esm'` / `'module'` — ES module
|
|
120
|
-
* - `'cjs'` / `'commonjs'` — CommonJS
|
|
121
|
-
* - `'iife'` — Immediately Invoked Function Expression
|
|
122
|
-
* - `'umd'` — Universal Module Definition
|
|
123
|
-
* - `'amd'` — Asynchronous Module Definition (Rollup only)
|
|
124
|
-
* - `'system'` / `'systemjs'` — SystemJS (Rollup only)
|
|
125
|
-
*/
|
|
126
|
-
format?: 'es' | 'esm' | 'module' | 'cjs' | 'commonjs' | 'iife' | 'umd' | 'amd' | 'system' | 'systemjs' | undefined;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Subset of the Vite/RollDown/Rollup plugin hook context (`this`) used by this plugin.
|
|
130
|
-
*/
|
|
131
|
-
type PluginContext = {
|
|
132
|
-
/** 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. */
|
|
133
|
-
warn: (message: string) => void;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Minimum plugin interface compatible with Vite/Rolldown/Rollup.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* {
|
|
140
|
-
* name: 'rollupStats',
|
|
141
|
-
* async generateBundle(outputOptions, bundle) { ... },
|
|
142
|
-
* }
|
|
143
|
-
*/
|
|
144
|
-
type Plugin = {
|
|
145
|
-
/** Unique identifier for the plugin, used in error messages and logs. */name: string;
|
|
146
|
-
/**
|
|
147
|
-
* Hook called after the bundle has been fully generated but before it is
|
|
148
|
-
* written to disk. Receives the resolved output options and the complete
|
|
149
|
-
* output bundle map.
|
|
150
|
-
*/
|
|
151
|
-
generateBundle?: (this: PluginContext, outputOptions: OutputOptions, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
|
|
152
|
-
};
|
|
153
124
|
//#endregion
|
|
154
|
-
export { OutputAsset, OutputBundle, OutputChunk,
|
|
125
|
+
export { OutputAsset, OutputBundle, OutputChunk, RenderedModule };
|
|
155
126
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/src/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;AAOA;;;;;;KAAY,SAAA;EAQV,iEANA,IAAA,UAUA;EARA,QAAA,UAQO;EANP,KAAA,YAeqB;EAbrB,OAAA,YAyCkB;EAvClB,cAAA,yBAsDe;EApDf,OAAA;AAAA;;;;;;;KASU,WAAA;EACV,IAAA,WAmCA;EAhCA,QAAA;EAqCE;;;;EA/BF,IAAA,sBAiCkB;EA9BlB,KAAA;EAuCwB;;;;EAjCxB,gBAAA,iBA6CA;EA1CA,iBAAA;EAgDA;;;AASF;EAnDE,MAAA,YAAkB,UAAA;;;;;;;EAQlB,kBAAA,YAqHkB;EAlHlB,YAAA;IAyCA,sFAvCE,cAAA,EAAgB,GAAA,UA6ClB;IA3CE,WAAA,EAAa,GAAA;EAAA;AAAA;;;;;;KASL,cAAA;EAgEV;;;;;EAAA,SA1DS,IAAA,kBAyEe;EAtExB,cAAA,UA+EA;EA5EA,cAAA,aAkFM;EA/EN,eAAA,YAoFE;EAjFF,cAAA;AAAA;;;;AA2FF;;;KAlFY,WAAA;EACV,IAAA,WAiFyB;EA9EzB,IAAA,UA8E+B;EA3E/B,QAAA,UA2EwC;EAxExC,mBAAA,UAwEiE;EArEjE,eAAA;EAGA,iBAAA;EAGA,OAAA;;;;;EAMA,cAAA;EAGA,sBAAA;EAGA,gBAAA,GAAmB,MAAA;EAGnB,cAAA;EAGA,OAAA;EAGA,eAAA;EAGA,cAAA;EAGA,OAAA;;;;;EAMA,OAAA,EAAS,MAAA,SAAe,cAAA;EAGxB,SAAA;;;;;EAMA,IAAA;;;;;EAMA,GAAA,GAAM,SAAA;EAGN,YAAA;+EAEE,cAAA,EAAgB,GAAA;IAEhB,WAAA,EAAa,GAAA;EAAA;AAAA;;;;;KAQL,YAAA,GAAe,MAAA,SAAe,WAAA,GAAc,WAAA"}
|
package/package.json
CHANGED
package/dist/index.d.cts.map
DELETED
|
@@ -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"}
|
package/dist/index.d.mts.map
DELETED
|
@@ -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"}
|