@relative-ci/rollup-plugin 5.3.0-rc.7 → 5.3.0-rc.8
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin.cjs +71 -0
- package/dist/plugin.d.cts +27 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +27 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +67 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/types.d.cts +8 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +8 -0
- package/dist/types.d.mts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { relativeCiAgent } from './plugin';\n\nexport default relativeCiAgent;\n"],"mappings":";;;AAEA,kBAAe"}
|
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let lodash = require("lodash");
|
|
3
|
+
lodash = require_runtime.__toESM(lodash);
|
|
4
|
+
let rollup_plugin_stats_extract = require("rollup-plugin-stats/extract");
|
|
5
|
+
rollup_plugin_stats_extract = require_runtime.__toESM(rollup_plugin_stats_extract);
|
|
6
|
+
let rollup_plugin_webpack_stats_transform = require("rollup-plugin-webpack-stats/transform");
|
|
7
|
+
let _relative_ci_core = require("@relative-ci/core");
|
|
8
|
+
let _relative_ci_core_env = require("@relative-ci/core/env");
|
|
9
|
+
_relative_ci_core_env = require_runtime.__toESM(_relative_ci_core_env);
|
|
10
|
+
let _relative_ci_core_ingest = require("@relative-ci/core/ingest");
|
|
11
|
+
_relative_ci_core_ingest = require_runtime.__toESM(_relative_ci_core_ingest);
|
|
12
|
+
|
|
13
|
+
//#region src/plugin.ts
|
|
14
|
+
const PLUGIN_NAME = "RelativeCiAgent";
|
|
15
|
+
const DEFAULT_OPTIONS = {
|
|
16
|
+
enabled: (0, _relative_ci_core_env.isCi)(),
|
|
17
|
+
failOnError: false,
|
|
18
|
+
includeCommitMessage: true,
|
|
19
|
+
payloadFilepath: void 0,
|
|
20
|
+
compress: false,
|
|
21
|
+
stats: {
|
|
22
|
+
assets: true,
|
|
23
|
+
chunks: true,
|
|
24
|
+
modules: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const relativeCiAgent = (userOptions = {}) => ({
|
|
28
|
+
name: PLUGIN_NAME,
|
|
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
|
+
const logger = {
|
|
38
|
+
log: console.log,
|
|
39
|
+
info: this.info,
|
|
40
|
+
warn: this.warn,
|
|
41
|
+
error: this.error,
|
|
42
|
+
debug: this.debug
|
|
43
|
+
};
|
|
44
|
+
const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;
|
|
45
|
+
const bundleWebpackStats = (0, rollup_plugin_webpack_stats_transform.bundleToWebpackStats)((0, rollup_plugin_stats_extract.default)(bundle, {
|
|
46
|
+
source: true,
|
|
47
|
+
...extractStatsOptions
|
|
48
|
+
}), {
|
|
49
|
+
moduleOriginalSize,
|
|
50
|
+
transform
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
(0, _relative_ci_core.validateWebpackStats)(bundleWebpackStats);
|
|
54
|
+
const envParams = await (0, _relative_ci_core_env.default)({ agentType: "rollup-plugin" }, { includeCommitMessage }, logger);
|
|
55
|
+
(0, _relative_ci_core.logResponse)(await (0, _relative_ci_core_ingest.default)((0, _relative_ci_core.filterArtifacts)([{
|
|
56
|
+
key: _relative_ci_core.SOURCE_WEBPACK_STATS,
|
|
57
|
+
data: bundleWebpackStats
|
|
58
|
+
}]), envParams, agentOptions, logger));
|
|
59
|
+
} catch (pluginError) {
|
|
60
|
+
const error = pluginError instanceof Error ? pluginError : String(pluginError);
|
|
61
|
+
if (failOnError) {
|
|
62
|
+
this.error(error);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.warn(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.relativeCiAgent = relativeCiAgent;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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/plugin.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import extractStats from "rollup-plugin-stats/extract";
|
|
3
|
+
import { bundleToWebpackStats } from "rollup-plugin-webpack-stats/transform";
|
|
4
|
+
import { SOURCE_WEBPACK_STATS, debug, filterArtifacts, logResponse, validateWebpackStats } from "@relative-ci/core";
|
|
5
|
+
import loadEnv, { isCi } from "@relative-ci/core/env";
|
|
6
|
+
import ingest from "@relative-ci/core/ingest";
|
|
7
|
+
|
|
8
|
+
//#region src/plugin.ts
|
|
9
|
+
const PLUGIN_NAME = "RelativeCiAgent";
|
|
10
|
+
const DEFAULT_OPTIONS = {
|
|
11
|
+
enabled: isCi(),
|
|
12
|
+
failOnError: false,
|
|
13
|
+
includeCommitMessage: true,
|
|
14
|
+
payloadFilepath: void 0,
|
|
15
|
+
compress: false,
|
|
16
|
+
stats: {
|
|
17
|
+
assets: true,
|
|
18
|
+
chunks: true,
|
|
19
|
+
modules: true
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const relativeCiAgent = (userOptions = {}) => ({
|
|
23
|
+
name: PLUGIN_NAME,
|
|
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
|
+
const logger = {
|
|
33
|
+
log: console.log,
|
|
34
|
+
info: this.info,
|
|
35
|
+
warn: this.warn,
|
|
36
|
+
error: this.error,
|
|
37
|
+
debug: this.debug
|
|
38
|
+
};
|
|
39
|
+
const { moduleOriginalSize, transform, ...extractStatsOptions } = statsOptions;
|
|
40
|
+
const bundleWebpackStats = bundleToWebpackStats(extractStats(bundle, {
|
|
41
|
+
source: true,
|
|
42
|
+
...extractStatsOptions
|
|
43
|
+
}), {
|
|
44
|
+
moduleOriginalSize,
|
|
45
|
+
transform
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
validateWebpackStats(bundleWebpackStats);
|
|
49
|
+
const envParams = await loadEnv({ agentType: "rollup-plugin" }, { includeCommitMessage }, logger);
|
|
50
|
+
logResponse(await ingest(filterArtifacts([{
|
|
51
|
+
key: SOURCE_WEBPACK_STATS,
|
|
52
|
+
data: bundleWebpackStats
|
|
53
|
+
}]), envParams, agentOptions, logger));
|
|
54
|
+
} catch (pluginError) {
|
|
55
|
+
const error = pluginError instanceof Error ? pluginError : String(pluginError);
|
|
56
|
+
if (failOnError) {
|
|
57
|
+
this.error(error);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.warn(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { relativeCiAgent };
|
|
67
|
+
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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/types.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,QAAA,GAAS,QAAA,GAAa,MAAA"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;KAGY,QAAA,GAAS,QAAA,GAAa,MAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relative-ci/rollup-plugin",
|
|
3
|
-
"version": "5.3.0-rc.
|
|
3
|
+
"version": "5.3.0-rc.8",
|
|
4
4
|
"description": "Rollup/Vite/Rolldown plugin that sends bundle stats and CI build information to RelativeCI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"relative-ci",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vitest": "4.0.18"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@relative-ci/core": "5.3.0-rc.
|
|
78
|
+
"@relative-ci/core": "5.3.0-rc.8",
|
|
79
79
|
"lodash": "4.17.23",
|
|
80
80
|
"rollup-plugin-stats": "2.0.0",
|
|
81
81
|
"rollup-plugin-webpack-stats": "3.0.0"
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"optional": true
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "2f64a27c152ac5ed168addbad874171f3c281a54"
|
|
100
100
|
}
|