@relative-ci/rollup-plugin 5.3.1-alpha.0 → 5.3.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src/plugin.cjs → plugin.cjs} +12 -12
- package/dist/plugin.d.cts +53 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +53 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/{src/plugin.mjs → plugin.mjs} +11 -11
- package/dist/plugin.mjs.map +1 -0
- package/package.json +9 -10
- package/dist/src/plugin.d.cts +0 -27
- package/dist/src/plugin.d.cts.map +0 -1
- package/dist/src/plugin.d.mts +0 -27
- package/dist/src/plugin.d.mts.map +0 -1
- package/dist/src/plugin.mjs.map +0 -1
- package/dist/src/types.d.cts +0 -8
- package/dist/src/types.d.cts.map +0 -1
- package/dist/src/types.d.mts +0 -8
- package/dist/src/types.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -14,6 +14,12 @@ To get started, follow [RelativeCI Setup guide for rollup-plugin](https://relati
|
|
|
14
14
|
[](https://github.com/relative-ci/agent/actions/workflows/ci.yml)
|
|
15
15
|
[](https://github.com/relative-ci/agent/actions/workflows/codeql.yml)
|
|
16
16
|
|
|
17
|
+
[](https://npmx.dev/package/@relative-ci/rollup-plugin)
|
|
18
|
+
[](https://npmx.dev/package/@relative-ci/rollup-plugin)
|
|
19
|
+
[](https://npmx.dev/package/@relative-ci/rollup-plugin)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
17
23
|
## Other packages
|
|
18
24
|
|
|
19
25
|
### [`@relative-ci/cli`](https://github.com/relative-ci/agent/tree/master/packages/cli)
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { relativeCiAgent } from "./
|
|
1
|
+
import { relativeCiAgent } from "./plugin.cjs";
|
|
2
2
|
export = relativeCiAgent;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { relativeCiAgent } from "./
|
|
1
|
+
import { relativeCiAgent } from "./plugin.mjs";
|
|
2
2
|
export { relativeCiAgent as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_runtime = require('
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
let lodash = require("lodash");
|
|
3
3
|
lodash = require_runtime.__toESM(lodash);
|
|
4
4
|
let rollup_plugin_stats_extract = require("rollup-plugin-stats/extract");
|
|
@@ -27,20 +27,20 @@ const DEFAULT_OPTIONS = {
|
|
|
27
27
|
const relativeCiAgent = (userOptions = {}) => ({
|
|
28
28
|
name: PLUGIN_NAME,
|
|
29
29
|
async generateBundle(__, bundle) {
|
|
30
|
-
const options = lodash.default.merge({}, DEFAULT_OPTIONS, userOptions);
|
|
31
|
-
(0, _relative_ci_core.debug)(options);
|
|
32
|
-
const { enabled, failOnError, includeCommitMessage, stats: statsOptions = {}, ...agentOptions } = options;
|
|
33
|
-
if (!enabled) {
|
|
34
|
-
(0, _relative_ci_core.debug)(`${PLUGIN_NAME} is disabled, skip sending data`);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
30
|
const logger = {
|
|
38
31
|
log: console.log,
|
|
39
32
|
info: this.info,
|
|
40
33
|
warn: this.warn,
|
|
41
34
|
error: this.error,
|
|
42
|
-
debug:
|
|
35
|
+
debug: _relative_ci_core.debug
|
|
43
36
|
};
|
|
37
|
+
const options = lodash.default.merge({}, DEFAULT_OPTIONS, userOptions);
|
|
38
|
+
logger.debug(options);
|
|
39
|
+
const { enabled, failOnError, includeCommitMessage, stats: statsOptions = {}, ...agentOptions } = options;
|
|
40
|
+
if (!enabled) {
|
|
41
|
+
logger.debug(`${PLUGIN_NAME} is disabled, skip sending data.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
44
|
const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;
|
|
45
45
|
const bundleWebpackStats = (0, rollup_plugin_webpack_stats_transform.bundleToWebpackStats)((0, rollup_plugin_stats_extract.default)(bundle, {
|
|
46
46
|
source: true,
|
|
@@ -57,12 +57,12 @@ const relativeCiAgent = (userOptions = {}) => ({
|
|
|
57
57
|
data: bundleWebpackStats
|
|
58
58
|
}]), envParams, agentOptions, logger));
|
|
59
59
|
} catch (pluginError) {
|
|
60
|
-
const error = pluginError instanceof Error ? pluginError : String(pluginError);
|
|
60
|
+
const error = pluginError instanceof Error ? pluginError.message : String(pluginError);
|
|
61
61
|
if (failOnError) {
|
|
62
|
-
|
|
62
|
+
logger.error(error);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
logger.warn(error);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { OutputBundle } from "rollup-plugin-stats";
|
|
2
|
+
import { StatsOptions } from "rollup-plugin-stats/extract";
|
|
3
|
+
import { BundleTransformOptions } from "rollup-plugin-webpack-stats/transform";
|
|
4
|
+
import { PluginConfig } from "@relative-ci/core";
|
|
5
|
+
|
|
6
|
+
//#region src/plugin.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.
|
|
9
|
+
*/
|
|
10
|
+
type PluginContext = {
|
|
11
|
+
info: (message: string) => void;
|
|
12
|
+
warn: (message: string) => void;
|
|
13
|
+
error: (message: string) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Minimum plugin interface compatible with Vite/Rolldown/Rollup.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* {
|
|
20
|
+
* name: 'rollupStats',
|
|
21
|
+
* async generateBundle(outputOptions, bundle) { ... },
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
type Plugin = {
|
|
25
|
+
/** Unique identifier for the plugin, used in error messages and logs. */name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Hook called after the bundle has been fully generated but before it is
|
|
28
|
+
* written to disk. Receives the resolved output options and the complete
|
|
29
|
+
* output bundle map.
|
|
30
|
+
*/
|
|
31
|
+
generateBundle?: (this: PluginContext, outputOptions: unknown, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
type RelativeCiAgentOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Plugin is enabled - sends data to RelativeCI
|
|
36
|
+
* @default env-ci isCi value
|
|
37
|
+
*/
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Throw error when validation or ingestion fails
|
|
41
|
+
* @default {false}
|
|
42
|
+
*/
|
|
43
|
+
failOnError?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Rollup/Vite/Rolldown stats options
|
|
46
|
+
* @default assets, chunks, modules
|
|
47
|
+
*/
|
|
48
|
+
stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;
|
|
49
|
+
} & PluginConfig;
|
|
50
|
+
declare const relativeCiAgent: (userOptions?: RelativeCiAgentOptions) => Plugin;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { relativeCiAgent };
|
|
53
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;;AAgB2B;KAStB,aAAA;EACH,IAAA,GAAO,OAAA;EACP,IAAA,GAAO,OAAA;EACP,KAAA,GAAQ,OAAA;AAAA;;;;;;;AAYV;;;KAAY,MAAA;EAYA,yEAVV,IAAA;EAYmB;;;;;EALnB,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,WACA,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA;AAAA,KAGT,sBAAA;EALD;;;;EAUF,OAAA;EALG;;;;EAUH,WAAA;EAKuC;;;;EAAvC,KAAA,GAAQ,IAAA,CAAK,YAAA,cAA0B,sBAAA;AAAA,IACrC,YAAA;AAAA,cAeS,eAAA,GAAmB,WAAA,GAAa,sBAAA,KAA8B,MAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StatsOptions } from "rollup-plugin-stats/extract";
|
|
2
|
+
import { BundleTransformOptions } from "rollup-plugin-webpack-stats/transform";
|
|
3
|
+
import { PluginConfig } from "@relative-ci/core";
|
|
4
|
+
import { OutputBundle } from "rollup-plugin-stats";
|
|
5
|
+
|
|
6
|
+
//#region src/plugin.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.
|
|
9
|
+
*/
|
|
10
|
+
type PluginContext = {
|
|
11
|
+
info: (message: string) => void;
|
|
12
|
+
warn: (message: string) => void;
|
|
13
|
+
error: (message: string) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Minimum plugin interface compatible with Vite/Rolldown/Rollup.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* {
|
|
20
|
+
* name: 'rollupStats',
|
|
21
|
+
* async generateBundle(outputOptions, bundle) { ... },
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
type Plugin = {
|
|
25
|
+
/** Unique identifier for the plugin, used in error messages and logs. */name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Hook called after the bundle has been fully generated but before it is
|
|
28
|
+
* written to disk. Receives the resolved output options and the complete
|
|
29
|
+
* output bundle map.
|
|
30
|
+
*/
|
|
31
|
+
generateBundle?: (this: PluginContext, outputOptions: unknown, bundle: OutputBundle, isWrite: boolean) => void | Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
type RelativeCiAgentOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Plugin is enabled - sends data to RelativeCI
|
|
36
|
+
* @default env-ci isCi value
|
|
37
|
+
*/
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Throw error when validation or ingestion fails
|
|
41
|
+
* @default {false}
|
|
42
|
+
*/
|
|
43
|
+
failOnError?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Rollup/Vite/Rolldown stats options
|
|
46
|
+
* @default assets, chunks, modules
|
|
47
|
+
*/
|
|
48
|
+
stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;
|
|
49
|
+
} & PluginConfig;
|
|
50
|
+
declare const relativeCiAgent: (userOptions?: RelativeCiAgentOptions) => Plugin;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { relativeCiAgent };
|
|
53
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;;;;;AAgB2B;KAStB,aAAA;EACH,IAAA,GAAO,OAAA;EACP,IAAA,GAAO,OAAA;EACP,KAAA,GAAQ,OAAA;AAAA;;;;;;;AAYV;;;KAAY,MAAA;EAYA,yEAVV,IAAA;EAYmB;;;;;EALnB,cAAA,IACE,IAAA,EAAM,aAAA,EACN,aAAA,WACA,MAAA,EAAQ,YAAA,EACR,OAAA,qBACU,OAAA;AAAA;AAAA,KAGT,sBAAA;EALD;;;;EAUF,OAAA;EALG;;;;EAUH,WAAA;EAKuC;;;;EAAvC,KAAA,GAAQ,IAAA,CAAK,YAAA,cAA0B,sBAAA;AAAA,IACrC,YAAA;AAAA,cAeS,eAAA,GAAmB,WAAA,GAAa,sBAAA,KAA8B,MAAA"}
|
|
@@ -22,20 +22,20 @@ const DEFAULT_OPTIONS = {
|
|
|
22
22
|
const relativeCiAgent = (userOptions = {}) => ({
|
|
23
23
|
name: PLUGIN_NAME,
|
|
24
24
|
async generateBundle(__, bundle) {
|
|
25
|
-
const options = _.merge({}, DEFAULT_OPTIONS, userOptions);
|
|
26
|
-
debug(options);
|
|
27
|
-
const { enabled, failOnError, includeCommitMessage, stats: statsOptions = {}, ...agentOptions } = options;
|
|
28
|
-
if (!enabled) {
|
|
29
|
-
debug(`${PLUGIN_NAME} is disabled, skip sending data`);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
25
|
const logger = {
|
|
33
26
|
log: console.log,
|
|
34
27
|
info: this.info,
|
|
35
28
|
warn: this.warn,
|
|
36
29
|
error: this.error,
|
|
37
|
-
debug
|
|
30
|
+
debug
|
|
38
31
|
};
|
|
32
|
+
const options = _.merge({}, DEFAULT_OPTIONS, userOptions);
|
|
33
|
+
logger.debug(options);
|
|
34
|
+
const { enabled, failOnError, includeCommitMessage, stats: statsOptions = {}, ...agentOptions } = options;
|
|
35
|
+
if (!enabled) {
|
|
36
|
+
logger.debug(`${PLUGIN_NAME} is disabled, skip sending data.`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
39
|
const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;
|
|
40
40
|
const bundleWebpackStats = bundleToWebpackStats(extractStats(bundle, {
|
|
41
41
|
source: true,
|
|
@@ -52,12 +52,12 @@ const relativeCiAgent = (userOptions = {}) => ({
|
|
|
52
52
|
data: bundleWebpackStats
|
|
53
53
|
}]), envParams, agentOptions, logger));
|
|
54
54
|
} catch (pluginError) {
|
|
55
|
-
const error = pluginError instanceof Error ? pluginError : String(pluginError);
|
|
55
|
+
const error = pluginError instanceof Error ? pluginError.message : String(pluginError);
|
|
56
56
|
if (failOnError) {
|
|
57
|
-
|
|
57
|
+
logger.error(error);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
logger.warn(error);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import _ from 'lodash';\nimport { type OutputBundle } from 'rollup-plugin-stats';\n// eslint-disable-next-line import/no-unresolved\nimport extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n// eslint-disable-next-line import/no-unresolved\nimport { bundleToWebpackStats } from 'rollup-plugin-webpack-stats/transform';\nimport type { BundleTransformOptions } from 'rollup-plugin-webpack-stats/transform';\n\nimport {\n type Logger,\n type PluginConfig,\n SOURCE_WEBPACK_STATS,\n debug,\n filterArtifacts,\n logResponse,\n validateWebpackStats,\n} from '@relative-ci/core';\nimport loadEnv, { isCi } from '@relative-ci/core/env';\nimport ingest from '@relative-ci/core/ingest';\n\nconst PLUGIN_NAME = 'RelativeCiAgent';\n\n/**\n * Subset of the Vite/Rolldown/Rollup plugin hook context (`this`) used by this plugin.\n */\ntype PluginContext = {\n info: (message: string) => void;\n warn: (message: string) => void;\n error: (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: unknown,\n bundle: OutputBundle,\n isWrite: boolean,\n ) => void | Promise<void>;\n};\n\ntype RelativeCiAgentOptions = {\n /**\n * Plugin is enabled - sends data to RelativeCI\n * @default env-ci isCi value\n */\n enabled?: boolean;\n /**\n * Throw error when validation or ingestion fails\n * @default {false}\n */\n failOnError?: boolean;\n /**\n * Rollup/Vite/Rolldown stats options\n * @default assets, chunks, modules\n */\n stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;\n} & PluginConfig;\n\nconst DEFAULT_OPTIONS = {\n enabled: isCi(),\n failOnError: false,\n includeCommitMessage: true,\n payloadFilepath: undefined,\n compress: false,\n stats: {\n assets: true,\n chunks: true,\n modules: true,\n },\n};\n\nexport const relativeCiAgent = (userOptions: RelativeCiAgentOptions = {}): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(__, bundle) {\n const logger: Logger = {\n log: console.log, // eslint-disable-line no-console\n info: this.info,\n warn: this.warn,\n error: this.error,\n debug, // send debug messages to the inline utility for consistent debugging across plugins\n };\n\n const options = _.merge({}, DEFAULT_OPTIONS, userOptions) as RelativeCiAgentOptions;\n\n logger.debug(options);\n\n const {\n enabled,\n failOnError,\n includeCommitMessage,\n stats: statsOptions = {},\n ...agentOptions\n } = options;\n\n // Skip if not enabled\n if (!enabled) {\n logger.debug(`${PLUGIN_NAME} is disabled, skip sending data.`);\n return;\n }\n\n // 1. Extract bundle stats from rollup/vite/rolldown\n const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;\n\n const bundleStats = extractStats(bundle, {\n source: true, // extract stats source to calculate module size\n ...extractStatsOptions,\n });\n\n // 2. Transform bundle stats to supported format\n const bundleWebpackStats = bundleToWebpackStats(bundleStats, { moduleOriginalSize, transform });\n\n // 3. Ingest data\n // catch error to prevent process failure on error\n try {\n validateWebpackStats(bundleWebpackStats);\n\n const envParams = await loadEnv(\n { agentType: 'rollup-plugin' },\n { includeCommitMessage },\n logger,\n );\n const artifactsData = filterArtifacts([\n { key: SOURCE_WEBPACK_STATS, data: bundleWebpackStats },\n ]);\n const response = await ingest(artifactsData, envParams, agentOptions, logger);\n\n logResponse(response);\n } catch (pluginError: unknown) {\n const error = pluginError instanceof Error ? pluginError.message : String(pluginError);\n\n // Propagate the error to the bundler if failOnError is enabled, otherwise log a warning and continue\n if (failOnError) {\n logger.error(error);\n return;\n }\n\n logger.warn(error);\n }\n },\n});\n"],"mappings":";;;;;;;;AAoBA,MAAM,cAAc;AAuDpB,MAAM,kBAAkB;CACtB,SAAS,MAAM;CACf,aAAa;CACb,sBAAsB;CACtB,iBAAiB;CACjB,UAAU;CACV,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,SAAS;EACV;CACF;AAED,MAAa,mBAAmB,cAAsC,EAAE,MAAc;CACpF,MAAM;CACN,MAAM,eAAe,IAAI,QAAQ;EAC/B,MAAM,SAAiB;GACrB,KAAK,QAAQ;GACb,MAAM,KAAK;GACX,MAAM,KAAK;GACX,OAAO,KAAK;GACZ;GACD;EAED,MAAM,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,YAAY;AAEzD,SAAO,MAAM,QAAQ;EAErB,MAAM,EACJ,SACA,aACA,sBACA,OAAO,eAAe,EAAE,EACxB,GAAG,iBACD;AAGJ,MAAI,CAAC,SAAS;AACZ,UAAO,MAAM,GAAG,YAAY,kCAAkC;AAC9D;;EAIF,MAAM,EAAE,oBAAoB,WAAW,GAAG,wBAAwB;EAQlE,MAAM,qBAAqB,qBANP,aAAa,QAAQ;GACvC,QAAQ;GACR,GAAG;GACJ,CAG0D,EAAE;GAAE;GAAoB;GAAW,CAAC;AAI/F,MAAI;AACF,wBAAqB,mBAAmB;GAExC,MAAM,YAAY,MAAM,QACtB,EAAE,WAAW,iBAAiB,EAC9B,EAAE,sBAAsB,EACxB,OACD;AAMD,eAAY,MAFW,OAHD,gBAAgB,CACpC;IAAE,KAAK;IAAsB,MAAM;IAAoB,CACxD,CAC0C,EAAE,WAAW,cAAc,OAAO,CAExD;WACd,aAAsB;GAC7B,MAAM,QAAQ,uBAAuB,QAAQ,YAAY,UAAU,OAAO,YAAY;AAGtF,OAAI,aAAa;AACf,WAAO,MAAM,MAAM;AACnB;;AAGF,UAAO,KAAK,MAAM;;;CAGvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relative-ci/rollup-plugin",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2-beta.0",
|
|
4
4
|
"description": "Rollup/Vite/Rolldown plugin that sends bundle stats and CI build information to RelativeCI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"relative-ci",
|
|
@@ -68,17 +68,16 @@
|
|
|
68
68
|
"@rollup/plugin-replace": "6.0.3",
|
|
69
69
|
"@types/lodash": "4.17.24",
|
|
70
70
|
"rimraf": "6.1.3",
|
|
71
|
-
"
|
|
72
|
-
"tsdown": "0.21.2",
|
|
71
|
+
"tsdown": "0.21.10",
|
|
73
72
|
"typescript": "5.9.3",
|
|
74
|
-
"vite": "7.3.
|
|
75
|
-
"vitest": "4.1.
|
|
73
|
+
"vite": "7.3.2",
|
|
74
|
+
"vitest": "4.1.5"
|
|
76
75
|
},
|
|
77
76
|
"dependencies": {
|
|
78
|
-
"@relative-ci/core": "5.3.
|
|
79
|
-
"lodash": "4.
|
|
80
|
-
"rollup-plugin-stats": "2.
|
|
81
|
-
"rollup-plugin-webpack-stats": "3.
|
|
77
|
+
"@relative-ci/core": "5.3.2-beta.0",
|
|
78
|
+
"lodash": "4.18.1",
|
|
79
|
+
"rollup-plugin-stats": "2.1.2",
|
|
80
|
+
"rollup-plugin-webpack-stats": "3.1.2"
|
|
82
81
|
},
|
|
83
82
|
"peerDependencies": {
|
|
84
83
|
"rolldown": "^1.0.0-beta.0",
|
|
@@ -96,5 +95,5 @@
|
|
|
96
95
|
"optional": true
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "e5f31882da338d6e2be195ed4e1d9b5b4c4dff91"
|
|
100
99
|
}
|
package/dist/src/plugin.d.cts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "./types.cjs";
|
|
2
|
-
import { StatsOptions } from "rollup-plugin-stats/extract";
|
|
3
|
-
import { BundleTransformOptions } from "rollup-plugin-webpack-stats/transform";
|
|
4
|
-
import { PluginConfig } from "@relative-ci/core";
|
|
5
|
-
|
|
6
|
-
//#region src/plugin.d.ts
|
|
7
|
-
type RelativeCiAgentOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* Plugin is enabled - sends data to RelativeCI
|
|
10
|
-
* @default env-ci isCi value
|
|
11
|
-
*/
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Throw error when validation or ingestion fails
|
|
15
|
-
* @default {false}
|
|
16
|
-
*/
|
|
17
|
-
failOnError?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Rollup/Vite/Rolldown stats options
|
|
20
|
-
* @default assets, chunks, modules
|
|
21
|
-
*/
|
|
22
|
-
stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;
|
|
23
|
-
} & PluginConfig;
|
|
24
|
-
declare const relativeCiAgent: (userOptions?: RelativeCiAgentOptions) => Plugin;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { relativeCiAgent };
|
|
27
|
-
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;KAsBK,sBAAA;;AAJiC;;;EASpC,OAAA;EAUQ;;;;EALR,WAAA;EALA;;;;EAUA,KAAA,GAAQ,IAAA,CAAK,YAAA,cAA0B,sBAAA;AAAA,IACrC,YAAA;AAAA,cAeS,eAAA,GAAmB,WAAA,GAAa,sBAAA,KAA8B,MAAA"}
|
package/dist/src/plugin.d.mts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "./types.mjs";
|
|
2
|
-
import { StatsOptions } from "rollup-plugin-stats/extract";
|
|
3
|
-
import { BundleTransformOptions } from "rollup-plugin-webpack-stats/transform";
|
|
4
|
-
import { PluginConfig } from "@relative-ci/core";
|
|
5
|
-
|
|
6
|
-
//#region src/plugin.d.ts
|
|
7
|
-
type RelativeCiAgentOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* Plugin is enabled - sends data to RelativeCI
|
|
10
|
-
* @default env-ci isCi value
|
|
11
|
-
*/
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Throw error when validation or ingestion fails
|
|
15
|
-
* @default {false}
|
|
16
|
-
*/
|
|
17
|
-
failOnError?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Rollup/Vite/Rolldown stats options
|
|
20
|
-
* @default assets, chunks, modules
|
|
21
|
-
*/
|
|
22
|
-
stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;
|
|
23
|
-
} & PluginConfig;
|
|
24
|
-
declare const relativeCiAgent: (userOptions?: RelativeCiAgentOptions) => Plugin;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { relativeCiAgent };
|
|
27
|
-
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;KAsBK,sBAAA;;AAJiC;;;EASpC,OAAA;EAUQ;;;;EALR,WAAA;EALA;;;;EAUA,KAAA,GAAQ,IAAA,CAAK,YAAA,cAA0B,sBAAA;AAAA,IACrC,YAAA;AAAA,cAeS,eAAA,GAAmB,WAAA,GAAa,sBAAA,KAA8B,MAAA"}
|
package/dist/src/plugin.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import _ from 'lodash';\n// eslint-disable-next-line import/no-unresolved\nimport extractStats, { type StatsOptions } from 'rollup-plugin-stats/extract';\n// eslint-disable-next-line import/no-unresolved\nimport { bundleToWebpackStats } from 'rollup-plugin-webpack-stats/transform';\nimport type { BundleTransformOptions } from 'rollup-plugin-webpack-stats/transform';\n\nimport {\n type Logger,\n type PluginConfig,\n SOURCE_WEBPACK_STATS,\n debug,\n filterArtifacts,\n logResponse,\n validateWebpackStats,\n} from '@relative-ci/core';\nimport loadEnv, { isCi } from '@relative-ci/core/env';\nimport ingest from '@relative-ci/core/ingest';\nimport type { Plugin } from './types';\n\nconst PLUGIN_NAME = 'RelativeCiAgent';\n\ntype RelativeCiAgentOptions = {\n /**\n * Plugin is enabled - sends data to RelativeCI\n * @default env-ci isCi value\n */\n enabled?: boolean;\n /**\n * Throw error when validation or ingestion fails\n * @default {false}\n */\n failOnError?: boolean;\n /**\n * Rollup/Vite/Rolldown stats options\n * @default assets, chunks, modules\n */\n stats?: Omit<StatsOptions, 'source'> & BundleTransformOptions;\n} & PluginConfig;\n\nconst DEFAULT_OPTIONS = {\n enabled: isCi(),\n failOnError: false,\n includeCommitMessage: true,\n payloadFilepath: undefined,\n compress: false,\n stats: {\n assets: true,\n chunks: true,\n modules: true,\n },\n};\n\nexport const relativeCiAgent = (userOptions: RelativeCiAgentOptions = {}): Plugin => ({\n name: PLUGIN_NAME,\n async generateBundle(__, bundle) {\n const options = _.merge({}, DEFAULT_OPTIONS, userOptions) as RelativeCiAgentOptions;\n\n debug(options);\n\n const {\n enabled,\n failOnError,\n includeCommitMessage,\n stats: statsOptions = {},\n ...agentOptions\n } = options;\n\n // Skip if not enabled\n if (!enabled) {\n debug(`${PLUGIN_NAME} is disabled, skip sending data`);\n return;\n }\n\n const logger: Logger = {\n log: console.log, // eslint-disable-line no-console\n info: this.info,\n warn: this.warn,\n error: this.error,\n debug: this.debug,\n };\n\n // 1. Extract bundle stats from rollup/vite/rolldown\n const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;\n\n const bundleStats = extractStats(bundle, {\n source: true, // extract stats source to calculate module size\n ...extractStatsOptions,\n });\n\n // 2. Transform bundle stats to supported format\n const bundleWebpackStats = bundleToWebpackStats(bundleStats, { moduleOriginalSize, transform });\n\n // 3. Ingest data\n // catch error to prevent process failure on error\n try {\n validateWebpackStats(bundleWebpackStats);\n\n const envParams = await loadEnv(\n { agentType: 'rollup-plugin' },\n { includeCommitMessage },\n logger,\n );\n const artifactsData = filterArtifacts([\n { key: SOURCE_WEBPACK_STATS, data: bundleWebpackStats },\n ]);\n const response = await ingest(artifactsData, envParams, agentOptions, logger);\n\n logResponse(response);\n } catch (pluginError: unknown) {\n const error = pluginError instanceof Error ? pluginError : String(pluginError);\n\n if (failOnError) {\n this.error(error);\n return;\n }\n\n this.warn(error);\n }\n },\n});\n"],"mappings":";;;;;;;;AAoBA,MAAM,cAAc;AAoBpB,MAAM,kBAAkB;CACtB,SAAS,MAAM;CACf,aAAa;CACb,sBAAsB;CACtB,iBAAiB;CACjB,UAAU;CACV,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,SAAS;EACV;CACF;AAED,MAAa,mBAAmB,cAAsC,EAAE,MAAc;CACpF,MAAM;CACN,MAAM,eAAe,IAAI,QAAQ;EAC/B,MAAM,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,YAAY;AAEzD,QAAM,QAAQ;EAEd,MAAM,EACJ,SACA,aACA,sBACA,OAAO,eAAe,EAAE,EACxB,GAAG,iBACD;AAGJ,MAAI,CAAC,SAAS;AACZ,SAAM,GAAG,YAAY,iCAAiC;AACtD;;EAGF,MAAM,SAAiB;GACrB,KAAK,QAAQ;GACb,MAAM,KAAK;GACX,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,OAAO,KAAK;GACb;EAGD,MAAM,EAAE,oBAAoB,WAAW,GAAG,wBAAwB;EAQlE,MAAM,qBAAqB,qBANP,aAAa,QAAQ;GACvC,QAAQ;GACR,GAAG;GACJ,CAAC,EAG2D;GAAE;GAAoB;GAAW,CAAC;AAI/F,MAAI;AACF,wBAAqB,mBAAmB;GAExC,MAAM,YAAY,MAAM,QACtB,EAAE,WAAW,iBAAiB,EAC9B,EAAE,sBAAsB,EACxB,OACD;AAMD,eAFiB,MAAM,OAHD,gBAAgB,CACpC;IAAE,KAAK;IAAsB,MAAM;IAAoB,CACxD,CAAC,EAC2C,WAAW,cAAc,OAAO,CAExD;WACd,aAAsB;GAC7B,MAAM,QAAQ,uBAAuB,QAAQ,cAAc,OAAO,YAAY;AAE9E,OAAI,aAAa;AACf,SAAK,MAAM,MAAM;AACjB;;AAGF,QAAK,KAAK,MAAM;;;CAGrB"}
|
package/dist/src/types.d.cts
DELETED
package/dist/src/types.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;KAGY,QAAA,GAAS,QAAA,GAAa,MAAA"}
|
package/dist/src/types.d.mts
DELETED
package/dist/src/types.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;KAGY,QAAA,GAAS,QAAA,GAAa,MAAA"}
|