@powerlines/plugin-id 0.9.132 → 0.9.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/components/index.cjs +2 -3
  3. package/dist/components/index.d.cts +1 -3
  4. package/dist/components/index.d.mts +1 -3
  5. package/dist/components/index.mjs +1 -2
  6. package/dist/components/nanoid.cjs +103 -2
  7. package/dist/components/nanoid.d.cts +12 -2
  8. package/dist/components/nanoid.d.mts +12 -2
  9. package/dist/components/nanoid.mjs +102 -1
  10. package/dist/index.cjs +6 -35
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +2 -4
  14. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  15. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  16. package/dist/powerlines/src/types/babel.d.mts +2 -0
  17. package/dist/powerlines/src/types/build.d.cts +145 -0
  18. package/dist/powerlines/src/types/build.d.mts +145 -0
  19. package/dist/powerlines/src/types/commands.d.cts +8 -0
  20. package/dist/powerlines/src/types/commands.d.mts +9 -0
  21. package/dist/powerlines/src/types/config.d.cts +376 -0
  22. package/dist/powerlines/src/types/config.d.mts +376 -0
  23. package/dist/powerlines/src/types/context.d.cts +403 -0
  24. package/dist/powerlines/src/types/context.d.mts +405 -0
  25. package/dist/powerlines/src/types/fs.d.cts +486 -0
  26. package/dist/powerlines/src/types/fs.d.mts +486 -0
  27. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  28. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  29. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  30. package/dist/powerlines/src/types/resolved.d.cts +81 -0
  31. package/dist/powerlines/src/types/resolved.d.mts +81 -0
  32. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  33. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  34. package/dist/types/index.cjs +0 -2
  35. package/dist/types/index.d.cts +1 -2
  36. package/dist/types/index.d.mts +1 -2
  37. package/dist/types/index.mjs +0 -3
  38. package/dist/types/plugin.cjs +0 -1
  39. package/dist/types/plugin.d.cts +37 -1
  40. package/dist/types/plugin.d.mts +37 -1
  41. package/dist/types/plugin.mjs +0 -2
  42. package/package.json +4 -4
  43. package/dist/components-BWLXb7a2.cjs +0 -0
  44. package/dist/components-kh0CpIG2.mjs +0 -1
  45. package/dist/index-9iG2qHLe.d.mts +0 -1
  46. package/dist/index-D4ELpJXS.d.cts +0 -1
  47. package/dist/index-D6CnpA_r.d.cts +0 -1
  48. package/dist/index-DL0uimUT.d.mts +0 -1
  49. package/dist/nanoid-BnZ5rqH7.d.cts +0 -13
  50. package/dist/nanoid-CDBSPS2R.d.mts +0 -13
  51. package/dist/nanoid-Ck7ultxE.mjs +0 -122
  52. package/dist/nanoid-DvIF2L1a.cjs +0 -128
  53. package/dist/plugin-C39QU9V6.d.mts +0 -1789
  54. package/dist/plugin-ifZVa20V.mjs +0 -1
  55. package/dist/plugin-mX-X7dCb.d.cts +0 -1789
  56. package/dist/plugin-pBKbb5K9.cjs +0 -0
  57. package/dist/types-U3zd8PTP.mjs +0 -1
  58. package/dist/types-o3zWarRp.cjs +0 -0
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
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;
@@ -1,4 +1,3 @@
1
- const require_nanoid = require('../nanoid-DvIF2L1a.cjs');
2
- require('../components-BWLXb7a2.cjs');
1
+ const require_components_nanoid = require('./nanoid.cjs');
3
2
 
4
- exports.nanoidModule = require_nanoid.nanoidModule;
3
+ exports.nanoidModule = require_components_nanoid.nanoidModule;
@@ -1,4 +1,2 @@
1
- import "../plugin-mX-X7dCb.cjs";
2
- import { t as nanoidModule } from "../nanoid-BnZ5rqH7.cjs";
3
- import "../index-D6CnpA_r.cjs";
1
+ import { nanoidModule } from "./nanoid.cjs";
4
2
  export { nanoidModule };
@@ -1,4 +1,2 @@
1
- import "../plugin-C39QU9V6.mjs";
2
- import { t as nanoidModule } from "../nanoid-CDBSPS2R.mjs";
3
- import "../index-DL0uimUT.mjs";
1
+ import { nanoidModule } from "./nanoid.mjs";
4
2
  export { nanoidModule };
@@ -1,4 +1,3 @@
1
- import { t as nanoidModule } from "../nanoid-Ck7ultxE.mjs";
2
- import "../components-kh0CpIG2.mjs";
1
+ import { nanoidModule } from "./nanoid.mjs";
3
2
 
4
3
  export { nanoidModule };
@@ -1,3 +1,104 @@
1
- const require_nanoid = require('../nanoid-DvIF2L1a.cjs');
1
+ const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
2
2
 
3
- exports.nanoidModule = require_nanoid.nanoidModule;
3
+ //#region src/components/nanoid.ts
4
+ /**
5
+ * Generates the nanoid module content.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the nanoid module code.
9
+ */
10
+ function nanoidModule(context) {
11
+ return `
12
+ /**
13
+ * The ID module provides a set of utilities for generating unique identifiers.
14
+ *
15
+ * @module ${context.config.output.builtinPrefix}:id
16
+ */
17
+
18
+ ${require_file_header.getFileHeader(context)}
19
+
20
+ /**
21
+ * Generate a random string
22
+ *
23
+ * @param array - The array to fill with random values
24
+ * @returns The array filled with random values
25
+ */
26
+ export function getRandom(array: Uint8Array) {
27
+ if (array === null) {
28
+ throw new StormError({ type: "general", code: 9 });
29
+ }
30
+
31
+ // Fill the array with random values
32
+ for (let i = 0; i < array.length; i++) {
33
+ array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)
34
+ }
35
+
36
+ return array;
37
+ }
38
+
39
+ /**
40
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
41
+ *
42
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
43
+ * @returns A unique identifier following the nanoid format
44
+ */
45
+ export function uniqueId(size?: number | undefined): string;
46
+
47
+ /**
48
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
49
+ *
50
+ * @param prefix - The prefix to use for the unique identifier
51
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
52
+ * @returns A unique identifier following the nanoid format
53
+ */
54
+ export function uniqueId(prefix?: string, size?: number | undefined): string;
55
+
56
+ /**
57
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
58
+ *
59
+ * @param param - The parameter to use for the unique identifier, can be a string or number
60
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
61
+ * @returns A unique identifier following the nanoid format
62
+ */
63
+ export function uniqueId(param?: string | number | undefined, size?: number | undefined): string {
64
+ if (typeof param === "number") {
65
+ size = param;
66
+ } else if (!param || !size) {
67
+ size = 21; // Default size if not provided
68
+ }
69
+
70
+ // Use our custom getRandom function to fill a Uint8Array with random values.
71
+ const randomBytes = getRandom(new Uint8Array(typeof param === "string" ? size - (param.length + 1) : size));
72
+
73
+ let result = "";
74
+ if (typeof param === "string") {
75
+ // If the parameter is a string, use it as a prefix.
76
+ result = param + "_";
77
+ }
78
+
79
+ return result + randomBytes.reduce((id, byte) => {
80
+ // It is incorrect to use bytes exceeding the alphabet size.
81
+ // The following mask reduces the random byte in the 0-255 value
82
+ // range to the 0-63 value range. Therefore, adding hacks, such
83
+ // as empty string fallback or magic numbers, is unnecessary because
84
+ // the bitmask trims bytes down to the alphabet size.
85
+ byte &= 63;
86
+ if (byte < 36) {
87
+ // \`0-9a-z\`
88
+ id += byte.toString(36);
89
+ } else if (byte < 62) {
90
+ // \`A-Z\`
91
+ id += (byte - 26).toString(36).toUpperCase();
92
+ } else if (byte > 62) {
93
+ id += "-";
94
+ } else {
95
+ id += "_";
96
+ }
97
+ return id;
98
+ }, "");
99
+ }
100
+ `;
101
+ }
102
+
103
+ //#endregion
104
+ exports.nanoidModule = nanoidModule;
@@ -1,3 +1,13 @@
1
- import "../plugin-mX-X7dCb.cjs";
2
- import { t as nanoidModule } from "../nanoid-BnZ5rqH7.cjs";
1
+ import { IdPluginContext } from "../types/plugin.cjs";
2
+
3
+ //#region src/components/nanoid.d.ts
4
+
5
+ /**
6
+ * Generates the nanoid module content.
7
+ *
8
+ * @param context - The build context containing runtime information.
9
+ * @returns A string representing the nanoid module code.
10
+ */
11
+ declare function nanoidModule(context: IdPluginContext): string;
12
+ //#endregion
3
13
  export { nanoidModule };
@@ -1,3 +1,13 @@
1
- import "../plugin-C39QU9V6.mjs";
2
- import { t as nanoidModule } from "../nanoid-CDBSPS2R.mjs";
1
+ import { IdPluginContext } from "../types/plugin.mjs";
2
+
3
+ //#region src/components/nanoid.d.ts
4
+
5
+ /**
6
+ * Generates the nanoid module content.
7
+ *
8
+ * @param context - The build context containing runtime information.
9
+ * @returns A string representing the nanoid module code.
10
+ */
11
+ declare function nanoidModule(context: IdPluginContext): string;
12
+ //#endregion
3
13
  export { nanoidModule };
@@ -1,3 +1,104 @@
1
- import { t as nanoidModule } from "../nanoid-Ck7ultxE.mjs";
1
+ import { getFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
2
2
 
3
+ //#region src/components/nanoid.ts
4
+ /**
5
+ * Generates the nanoid module content.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the nanoid module code.
9
+ */
10
+ function nanoidModule(context) {
11
+ return `
12
+ /**
13
+ * The ID module provides a set of utilities for generating unique identifiers.
14
+ *
15
+ * @module ${context.config.output.builtinPrefix}:id
16
+ */
17
+
18
+ ${getFileHeader(context)}
19
+
20
+ /**
21
+ * Generate a random string
22
+ *
23
+ * @param array - The array to fill with random values
24
+ * @returns The array filled with random values
25
+ */
26
+ export function getRandom(array: Uint8Array) {
27
+ if (array === null) {
28
+ throw new StormError({ type: "general", code: 9 });
29
+ }
30
+
31
+ // Fill the array with random values
32
+ for (let i = 0; i < array.length; i++) {
33
+ array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)
34
+ }
35
+
36
+ return array;
37
+ }
38
+
39
+ /**
40
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
41
+ *
42
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
43
+ * @returns A unique identifier following the nanoid format
44
+ */
45
+ export function uniqueId(size?: number | undefined): string;
46
+
47
+ /**
48
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
49
+ *
50
+ * @param prefix - The prefix to use for the unique identifier
51
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
52
+ * @returns A unique identifier following the nanoid format
53
+ */
54
+ export function uniqueId(prefix?: string, size?: number | undefined): string;
55
+
56
+ /**
57
+ * A platform agnostic version of the [nanoid](https://github.com/ai/nanoid) package with some modifications.
58
+ *
59
+ * @param param - The parameter to use for the unique identifier, can be a string or number
60
+ * @param size - The size of the string to generate. Defaults to 21 if not provided.
61
+ * @returns A unique identifier following the nanoid format
62
+ */
63
+ export function uniqueId(param?: string | number | undefined, size?: number | undefined): string {
64
+ if (typeof param === "number") {
65
+ size = param;
66
+ } else if (!param || !size) {
67
+ size = 21; // Default size if not provided
68
+ }
69
+
70
+ // Use our custom getRandom function to fill a Uint8Array with random values.
71
+ const randomBytes = getRandom(new Uint8Array(typeof param === "string" ? size - (param.length + 1) : size));
72
+
73
+ let result = "";
74
+ if (typeof param === "string") {
75
+ // If the parameter is a string, use it as a prefix.
76
+ result = param + "_";
77
+ }
78
+
79
+ return result + randomBytes.reduce((id, byte) => {
80
+ // It is incorrect to use bytes exceeding the alphabet size.
81
+ // The following mask reduces the random byte in the 0-255 value
82
+ // range to the 0-63 value range. Therefore, adding hacks, such
83
+ // as empty string fallback or magic numbers, is unnecessary because
84
+ // the bitmask trims bytes down to the alphabet size.
85
+ byte &= 63;
86
+ if (byte < 36) {
87
+ // \`0-9a-z\`
88
+ id += byte.toString(36);
89
+ } else if (byte < 62) {
90
+ // \`A-Z\`
91
+ id += (byte - 26).toString(36).toUpperCase();
92
+ } else if (byte > 62) {
93
+ id += "-";
94
+ } else {
95
+ id += "_";
96
+ }
97
+ return id;
98
+ }, "");
99
+ }
100
+ `;
101
+ }
102
+
103
+ //#endregion
3
104
  export { nanoidModule };
package/dist/index.cjs CHANGED
@@ -1,38 +1,10 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
- value: mod,
25
- enumerable: true
26
- }) : target, mod));
27
-
28
- //#endregion
29
- const require_nanoid = require('./nanoid-DvIF2L1a.cjs');
30
- require('./components-BWLXb7a2.cjs');
31
- require('./plugin-pBKbb5K9.cjs');
32
- require('./types-o3zWarRp.cjs');
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_components_nanoid = require('./components/nanoid.cjs');
4
+ require('./components/index.cjs');
33
5
  let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
34
6
  let defu = require("defu");
35
- defu = __toESM(defu);
7
+ defu = require_rolldown_runtime.__toESM(defu);
36
8
 
37
9
  //#region src/index.ts
38
10
  /**
@@ -57,7 +29,7 @@ function plugin(options = {}) {
57
29
  switch (this.config.id.type) {
58
30
  case "nanoid":
59
31
  default:
60
- idModule = require_nanoid.nanoidModule;
32
+ idModule = require_components_nanoid.nanoidModule;
61
33
  break;
62
34
  }
63
35
  await this.emitBuiltin(await Promise.resolve(idModule(this)), "id", "id.ts");
@@ -67,7 +39,6 @@ function plugin(options = {}) {
67
39
  var src_default = plugin;
68
40
 
69
41
  //#endregion
70
- exports.__toESM = __toESM;
71
42
  exports.default = src_default;
72
- exports.nanoidModule = require_nanoid.nanoidModule;
43
+ exports.nanoidModule = require_components_nanoid.nanoidModule;
73
44
  exports.plugin = plugin;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { a as UniqueIdFormatType, c as __ΩIdPluginResolvedConfig, d as Plugin, i as IdPluginUserConfig, l as __ΩIdPluginUserConfig, n as IdPluginOptions, o as __ΩIdPluginContext, r as IdPluginResolvedConfig, s as __ΩIdPluginOptions, t as IdPluginContext, u as __ΩUniqueIdFormatType } from "./plugin-mX-X7dCb.cjs";
2
- import { t as nanoidModule } from "./nanoid-BnZ5rqH7.cjs";
3
- import "./index-D6CnpA_r.cjs";
4
- import "./index-D4ELpJXS.cjs";
1
+ import { Plugin } from "./powerlines/src/types/plugin.cjs";
2
+ import { IdPluginContext, IdPluginOptions, IdPluginResolvedConfig, IdPluginUserConfig, UniqueIdFormatType, __ΩIdPluginContext, __ΩIdPluginOptions, __ΩIdPluginResolvedConfig, __ΩIdPluginUserConfig, __ΩUniqueIdFormatType } from "./types/plugin.cjs";
3
+ import { nanoidModule } from "./components/nanoid.cjs";
5
4
 
6
5
  //#region src/index.d.ts
7
6
 
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { a as UniqueIdFormatType, c as __ΩIdPluginResolvedConfig, d as Plugin, i as IdPluginUserConfig, l as __ΩIdPluginUserConfig, n as IdPluginOptions, o as __ΩIdPluginContext, r as IdPluginResolvedConfig, s as __ΩIdPluginOptions, t as IdPluginContext, u as __ΩUniqueIdFormatType } from "./plugin-C39QU9V6.mjs";
2
- import { t as nanoidModule } from "./nanoid-CDBSPS2R.mjs";
3
- import "./index-DL0uimUT.mjs";
4
- import "./index-9iG2qHLe.mjs";
1
+ import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
+ import { IdPluginContext, IdPluginOptions, IdPluginResolvedConfig, IdPluginUserConfig, UniqueIdFormatType, __ΩIdPluginContext, __ΩIdPluginOptions, __ΩIdPluginResolvedConfig, __ΩIdPluginUserConfig, __ΩUniqueIdFormatType } from "./types/plugin.mjs";
3
+ import { nanoidModule } from "./components/nanoid.mjs";
4
+ import "./components/index.mjs";
5
+ import "./types/index.mjs";
5
6
 
6
7
  //#region src/index.d.ts
7
-
8
8
  /**
9
9
  * A Powerlines plugin to assist in developing other Powerlines plugins.
10
10
  */
package/dist/index.mjs CHANGED
@@ -1,7 +1,5 @@
1
- import { t as nanoidModule } from "./nanoid-Ck7ultxE.mjs";
2
- import "./components-kh0CpIG2.mjs";
3
- import "./plugin-ifZVa20V.mjs";
4
- import "./types-U3zd8PTP.mjs";
1
+ import { nanoidModule } from "./components/nanoid.mjs";
2
+ import "./components/index.mjs";
5
3
  import { LogLevelLabel } from "@storm-software/config-tools/types";
6
4
  import defu from "defu";
7
5
 
@@ -0,0 +1,22 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
3
+
4
+ //#region ../powerlines/src/lib/utilities/file-header.ts
5
+ function getBaseFileHeader(context) {
6
+ return `
7
+ // Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
8
+ // Note: Do not edit this file manually - it will be overwritten automatically
9
+ `;
10
+ }
11
+ function getFileHeader(context, options = {}) {
12
+ const { directive = null, prettierIgnore = false } = options;
13
+ return `/* eslint-disable */
14
+ // biome-ignore lint: disable
15
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
16
+ ${getBaseFileHeader(context)}
17
+
18
+ `;
19
+ }
20
+
21
+ //#endregion
22
+ exports.getFileHeader = getFileHeader;
@@ -0,0 +1,21 @@
1
+ import { titleCase } from "@stryke/string-format/title-case";
2
+
3
+ //#region ../powerlines/src/lib/utilities/file-header.ts
4
+ function getBaseFileHeader(context) {
5
+ return `
6
+ // Generated with ${titleCase(context.config.framework)}
7
+ // Note: Do not edit this file manually - it will be overwritten automatically
8
+ `;
9
+ }
10
+ function getFileHeader(context, options = {}) {
11
+ const { directive = null, prettierIgnore = false } = options;
12
+ return `/* eslint-disable */
13
+ // biome-ignore lint: disable
14
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
15
+ ${getBaseFileHeader(context)}
16
+
17
+ `;
18
+ }
19
+
20
+ //#endregion
21
+ export { getFileHeader };
@@ -0,0 +1,2 @@
1
+ import "./context.mjs";
2
+ import "./config.mjs";
@@ -0,0 +1,145 @@
1
+ //#region ../powerlines/src/types/build.d.ts
2
+
3
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
4
+ interface BuildConfig {
5
+ /**
6
+ * The platform to build the project for
7
+ *
8
+ * @defaultValue "neutral"
9
+ */
10
+ platform?: "node" | "browser" | "neutral";
11
+ /**
12
+ * Array of strings indicating the polyfills to include for the build.
13
+ *
14
+ * @remarks
15
+ * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * {
20
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
21
+ * }
22
+ * ```
23
+ */
24
+ polyfill?: string[];
25
+ /**
26
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
27
+ *
28
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
29
+ */
30
+ mainFields?: string[];
31
+ /**
32
+ * Array of strings indicating what conditions should be used for module resolution.
33
+ */
34
+ conditions?: string[];
35
+ /**
36
+ * Array of strings indicating what file extensions should be used for module resolution.
37
+ *
38
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
39
+ */
40
+ extensions?: string[];
41
+ /**
42
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
43
+ *
44
+ * @remarks
45
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
46
+ */
47
+ dedupe?: string[];
48
+ /**
49
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
50
+ */
51
+ builtins?: (string | RegExp)[];
52
+ /**
53
+ * Define global variable replacements.
54
+ *
55
+ * @remarks
56
+ * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * {
61
+ * define: {
62
+ * __VERSION__: '"1.0.0"',
63
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
64
+ * }
65
+ * }
66
+ * ```
67
+ *
68
+ * @see https://esbuild.github.io/api/#define
69
+ * @see https://vitejs.dev/config/build-options.html#define
70
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
71
+ */
72
+ define?: Record<string, any>;
73
+ /**
74
+ * Global variables that will have import statements injected where necessary
75
+ *
76
+ * @remarks
77
+ * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * {
82
+ * inject: {
83
+ * process: 'process/browser',
84
+ * Buffer: ['buffer', 'Buffer'],
85
+ * }
86
+ * }
87
+ * ```
88
+ *
89
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
90
+ */
91
+ inject?: Record<string, string | string[]>;
92
+ /**
93
+ * The alias mappings to use for module resolution during the build process.
94
+ *
95
+ * @remarks
96
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * {
101
+ * alias: {
102
+ * "@utils": "./src/utils",
103
+ * "@components": "./src/components"
104
+ * }
105
+ * }
106
+ * ```
107
+ *
108
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
109
+ */
110
+ alias?: Record<string, string> | Array<{
111
+ find: string | RegExp;
112
+ replacement: string;
113
+ }>;
114
+ /**
115
+ * A list of modules that should not be bundled, even if they are external dependencies.
116
+ *
117
+ * @remarks
118
+ * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
119
+ */
120
+ external?: (string | RegExp)[];
121
+ /**
122
+ * A list of modules that should always be bundled, even if they are external dependencies.
123
+ */
124
+ noExternal?: (string | RegExp)[];
125
+ /**
126
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
127
+ */
128
+ skipNodeModulesBundle?: boolean;
129
+ /**
130
+ * If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime. Otherwise, it is statically replaced as an empty object.
131
+ *
132
+ * @defaultValue false
133
+ */
134
+ keepProcessEnv?: boolean;
135
+ /**
136
+ * An optional set of override options to apply to the selected build variant.
137
+ *
138
+ * @remarks
139
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
140
+ */
141
+ override?: Record<string, any>;
142
+ }
143
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
144
+ //#endregion
145
+ export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant };