@powerlines/plugin-webpack 0.5.132 → 0.5.133

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 (130) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/helpers/index.cjs +2 -3
  3. package/dist/helpers/index.d.cts +1 -3
  4. package/dist/helpers/index.d.mts +1 -3
  5. package/dist/helpers/index.mjs +1 -2
  6. package/dist/helpers/unplugin.cjs +11 -2
  7. package/dist/helpers/unplugin.d.cts +6 -2
  8. package/dist/helpers/unplugin.d.mts +6 -2
  9. package/dist/helpers/unplugin.mjs +9 -1
  10. package/dist/index.cjs +8 -50
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +3 -46
  14. package/dist/powerlines/schemas/fs.cjs +226 -0
  15. package/dist/powerlines/schemas/fs.mjs +224 -0
  16. package/dist/powerlines/src/api.cjs +580 -0
  17. package/dist/powerlines/src/api.mjs +578 -0
  18. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -0
  19. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -0
  20. package/dist/powerlines/src/internal/helpers/environment.cjs +52 -0
  21. package/dist/powerlines/src/internal/helpers/environment.mjs +48 -0
  22. package/dist/powerlines/src/internal/helpers/generate-types.cjs +51 -0
  23. package/dist/powerlines/src/internal/helpers/generate-types.mjs +49 -0
  24. package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -0
  25. package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -0
  26. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -0
  27. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -0
  28. package/dist/powerlines/src/internal/helpers/install.cjs +37 -0
  29. package/dist/powerlines/src/internal/helpers/install.mjs +36 -0
  30. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +98 -0
  31. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +94 -0
  32. package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
  33. package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
  34. package/dist/powerlines/src/lib/build/webpack.cjs +47 -0
  35. package/dist/powerlines/src/lib/build/webpack.mjs +45 -0
  36. package/dist/powerlines/src/lib/config-file.cjs +79 -0
  37. package/dist/powerlines/src/lib/config-file.mjs +76 -0
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
  40. package/dist/powerlines/src/lib/contexts/context.cjs +933 -0
  41. package/dist/powerlines/src/lib/contexts/context.mjs +931 -0
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -0
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -0
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -0
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -0
  46. package/dist/powerlines/src/lib/entry.cjs +69 -0
  47. package/dist/powerlines/src/lib/entry.mjs +67 -0
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +830 -0
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +828 -0
  58. package/dist/powerlines/src/lib/logger.cjs +58 -0
  59. package/dist/powerlines/src/lib/logger.mjs +55 -0
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -0
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -0
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -0
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -0
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +3 -0
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +5 -0
  70. package/dist/powerlines/src/lib/unplugin/plugin.cjs +128 -0
  71. package/dist/powerlines/src/lib/unplugin/plugin.mjs +127 -0
  72. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  73. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  74. package/dist/powerlines/src/lib/utilities/meta.cjs +45 -0
  75. package/dist/powerlines/src/lib/utilities/meta.mjs +41 -0
  76. package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
  77. package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -0
  78. package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -0
  79. package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -0
  80. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
  81. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
  82. package/dist/powerlines/src/types/babel.d.mts +4 -0
  83. package/dist/powerlines/src/types/build.cjs +15 -0
  84. package/dist/powerlines/src/types/build.d.cts +149 -0
  85. package/dist/powerlines/src/types/build.d.mts +149 -0
  86. package/dist/powerlines/src/types/build.mjs +14 -0
  87. package/dist/powerlines/src/types/commands.cjs +16 -0
  88. package/dist/powerlines/src/types/commands.d.cts +8 -0
  89. package/dist/powerlines/src/types/commands.d.mts +9 -0
  90. package/dist/powerlines/src/types/commands.mjs +15 -0
  91. package/dist/powerlines/src/types/config.d.cts +377 -0
  92. package/dist/powerlines/src/types/config.d.mts +378 -0
  93. package/dist/powerlines/src/types/context.d.cts +403 -0
  94. package/dist/powerlines/src/types/context.d.mts +405 -0
  95. package/dist/powerlines/src/types/fs.d.cts +486 -0
  96. package/dist/powerlines/src/types/fs.d.mts +486 -0
  97. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  98. package/dist/powerlines/src/types/plugin.cjs +32 -0
  99. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  100. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  101. package/dist/powerlines/src/types/plugin.mjs +31 -0
  102. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  103. package/dist/powerlines/src/types/resolved.d.mts +83 -0
  104. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  105. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  106. package/dist/types/index.cjs +0 -2
  107. package/dist/types/index.d.cts +1 -2
  108. package/dist/types/index.d.mts +1 -2
  109. package/dist/types/index.mjs +0 -3
  110. package/dist/types/plugin.cjs +0 -1
  111. package/dist/types/plugin.d.cts +12 -1
  112. package/dist/types/plugin.d.mts +12 -1
  113. package/dist/types/plugin.mjs +0 -2
  114. package/package.json +5 -5
  115. package/dist/helpers-B15z10jN.mjs +0 -1
  116. package/dist/helpers-LF26RHol.cjs +0 -0
  117. package/dist/index-9iG2qHLe.d.mts +0 -1
  118. package/dist/index-D4ELpJXS.d.cts +0 -1
  119. package/dist/index-D6CnpA_r.d.cts +0 -1
  120. package/dist/index-DL0uimUT.d.mts +0 -1
  121. package/dist/plugin-C5bG6Zu0.d.mts +0 -1772
  122. package/dist/plugin-Cl1J-dKa.d.cts +0 -1769
  123. package/dist/plugin-ifZVa20V.mjs +0 -1
  124. package/dist/plugin-pBKbb5K9.cjs +0 -0
  125. package/dist/types-U3zd8PTP.mjs +0 -1
  126. package/dist/types-o3zWarRp.cjs +0 -0
  127. package/dist/unplugin-Bo9KoKSB.d.cts +0 -7
  128. package/dist/unplugin-Ct4wZxE5.d.mts +0 -7
  129. package/dist/unplugin-GJmHohOE.mjs +0 -4617
  130. package/dist/unplugin-bKYETUU8.cjs +0 -4661
@@ -0,0 +1,138 @@
1
+ import { UNPLUGIN_BUILD_VARIANTS } from "../types/build.mjs";
2
+ import { KNOWN_HOOKS } from "../types/plugin.mjs";
3
+ import { isFunction } from "@stryke/type-checks/is-function";
4
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
5
+ import { isSetString } from "@stryke/type-checks/is-set-string";
6
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
7
+
8
+ //#region ../powerlines/src/plugin-utils/helpers.ts
9
+ /**
10
+ * Type guard to check if an object is a {@link Plugin}
11
+ *
12
+ * @param value - The object to check
13
+ * @returns True if the object is a {@link Plugin}, false otherwise
14
+ */
15
+ function isPlugin(value) {
16
+ return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.api) || "api" in value && isSetObject(value.api)) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && KNOWN_HOOKS.every((hook) => isUndefined(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && isSetObject(value[hook]))) && UNPLUGIN_BUILD_VARIANTS.every((variant) => isUndefined(value[variant]) || variant in value && isSetObject(value[variant]));
17
+ }
18
+ /**
19
+ * Type guard to check if an object is a {@link PluginConfigObject}
20
+ *
21
+ * @param value - The object to check
22
+ * @returns True if the object is a {@link PluginConfigObject}, false otherwise
23
+ */
24
+ function isPluginConfigObject(value) {
25
+ return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
26
+ }
27
+ /**
28
+ * Type guard to check if an object is a {@link PluginConfigTuple}
29
+ *
30
+ * @param value - The object to check
31
+ * @returns True if the object is a {@link PluginConfigTuple}, false otherwise
32
+ */
33
+ function isPluginConfigTuple(value) {
34
+ return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
35
+ }
36
+ /**
37
+ * Type guard to check if an object is a {@link PluginConfig}
38
+ *
39
+ * @param value - The object to check
40
+ * @returns True if the object is a {@link PluginConfig}, false otherwise
41
+ */
42
+ function isPluginConfig(value) {
43
+ return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value) || Array.isArray(value) && value.every((item) => isPluginConfig(item));
44
+ }
45
+ /**
46
+ * Type guard to check if an value is a {@link PluginHook} function
47
+ *
48
+ * @param value - The value to check
49
+ * @returns True if the value is a {@link PluginHook} function, false otherwise
50
+ */
51
+ function isPluginHookObject(value) {
52
+ return isSetObject(value) && "handler" in value && isFunction(value.handler);
53
+ }
54
+ /**
55
+ * Type guard to check if an value is a {@link PluginHook} function
56
+ *
57
+ * @param value - The value to check
58
+ * @returns True if the value is a {@link PluginHook} function, false otherwise
59
+ */
60
+ function isPluginHookFunction(value) {
61
+ return isFunction(value) || isPluginHookObject(value);
62
+ }
63
+ /**
64
+ * Type guard to check if an object is a {@link PluginHook}
65
+ *
66
+ * @param value - The object to check
67
+ * @returns True if the object is a {@link PluginHook}, false otherwise
68
+ */
69
+ function isPluginHook(value) {
70
+ return isPluginHookFunction(value) || isPluginHookObject(value);
71
+ }
72
+ /**
73
+ * Extract the hook handler function from a plugin hook
74
+ *
75
+ * @param pluginHook - The plugin hook to extract the handler function from
76
+ * @returns The hook handler function
77
+ */
78
+ function getHookHandler(pluginHook) {
79
+ return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
80
+ }
81
+ /**
82
+ * Check if a hook is external.
83
+ *
84
+ * @param hook - The name of the hook to check.
85
+ * @returns True if the hook is external, false otherwise.
86
+ */
87
+ function isHookExternal(hook) {
88
+ return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
89
+ }
90
+ /**
91
+ * Check if a plugin should be deduplicated.
92
+ *
93
+ * @param plugin - The plugin to check
94
+ * @param plugins - The list of plugins to check against
95
+ * @returns True if the plugin should be deduplicated, false otherwise
96
+ */
97
+ function checkDedupe(plugin, plugins) {
98
+ return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
99
+ }
100
+ /**
101
+ * Add a plugin hook to the hooks list.
102
+ *
103
+ * @param context - The plugin context
104
+ * @param plugin - The plugin to add the hook from
105
+ * @param pluginHook - The plugin hook to add
106
+ * @param hooksList - The list of hooks to add to
107
+ */
108
+ function addPluginHook(context, plugin, pluginHook, hooksList) {
109
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) hooksList.push(isFunction(pluginHook) ? {
110
+ plugin,
111
+ handler: getHookHandler(pluginHook).bind(context)
112
+ } : {
113
+ plugin,
114
+ ...pluginHook,
115
+ handler: getHookHandler(pluginHook).bind(context)
116
+ });
117
+ }
118
+ /**
119
+ * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.
120
+ *
121
+ * @param config - The plugin configuration to check
122
+ * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations
123
+ */
124
+ function findInvalidPluginConfig(config) {
125
+ if (isPluginConfig(config)) return null;
126
+ if (Array.isArray(config)) {
127
+ const invalidItems = [];
128
+ config.forEach((item) => {
129
+ const invalid = findInvalidPluginConfig(item);
130
+ if (invalid) invalidItems.push(...invalid.map((i) => JSON.stringify(i, null, 2)));
131
+ });
132
+ return invalidItems.length > 0 ? invalidItems : null;
133
+ }
134
+ return [JSON.stringify(config, null, 2)];
135
+ }
136
+
137
+ //#endregion
138
+ export { addPluginHook, checkDedupe, findInvalidPluginConfig, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };
@@ -0,0 +1,36 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_replace = require("@stryke/path/replace");
3
+
4
+ //#region ../powerlines/src/plugin-utils/paths.ts
5
+ /**
6
+ * Replaces tokens in the given path string with their corresponding values from the context.
7
+ *
8
+ * @remarks
9
+ * The following tokens are supported:
10
+ * - `{workspaceRoot}` - The root directory of the workspace.
11
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
12
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
13
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
14
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
15
+ * - `{cachePath}` - The environment's directory for cached files.
16
+ * - `{dataPath}` - The environment's directory for data files.
17
+ * - `{logPath}` - The environment's directory for log files.
18
+ * - `{tempPath}` - The environment's directory for temporary files.
19
+ * - `{configPath}` - The environment's directory for configuration files.
20
+ * - `{outputPath}` - The configured output directory for the project.
21
+ * - `{buildPath}` - The configured distribution directory for the project.
22
+ * - `{artifactsPath}` - The configured directory for build artifacts.
23
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
24
+ * - `{entryPath}` - The configured directory for generated entry files.
25
+ *
26
+ * @param context - The context containing the values for the path tokens.
27
+ * @param path - The path string with tokens to replace.
28
+ * @returns The path string with tokens replaced by their corresponding values from the context.
29
+ */
30
+ function replacePathTokens(context, path) {
31
+ if (!path) return path;
32
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
33
+ }
34
+
35
+ //#endregion
36
+ exports.replacePathTokens = replacePathTokens;
@@ -0,0 +1,35 @@
1
+ import { replacePath } from "@stryke/path/replace";
2
+
3
+ //#region ../powerlines/src/plugin-utils/paths.ts
4
+ /**
5
+ * Replaces tokens in the given path string with their corresponding values from the context.
6
+ *
7
+ * @remarks
8
+ * The following tokens are supported:
9
+ * - `{workspaceRoot}` - The root directory of the workspace.
10
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
11
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
12
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
13
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
14
+ * - `{cachePath}` - The environment's directory for cached files.
15
+ * - `{dataPath}` - The environment's directory for data files.
16
+ * - `{logPath}` - The environment's directory for log files.
17
+ * - `{tempPath}` - The environment's directory for temporary files.
18
+ * - `{configPath}` - The environment's directory for configuration files.
19
+ * - `{outputPath}` - The configured output directory for the project.
20
+ * - `{buildPath}` - The configured distribution directory for the project.
21
+ * - `{artifactsPath}` - The configured directory for build artifacts.
22
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
23
+ * - `{entryPath}` - The configured directory for generated entry files.
24
+ *
25
+ * @param context - The context containing the values for the path tokens.
26
+ * @param path - The path string with tokens to replace.
27
+ * @returns The path string with tokens replaced by their corresponding values from the context.
28
+ */
29
+ function replacePathTokens(context, path) {
30
+ if (!path) return path;
31
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
32
+ }
33
+
34
+ //#endregion
35
+ export { replacePathTokens };
@@ -0,0 +1,4 @@
1
+ import "./config.mjs";
2
+ import "./context.mjs";
3
+ import "@babel/core";
4
+ import "@babel/helper-plugin-utils";
@@ -0,0 +1,15 @@
1
+
2
+ //#region ../powerlines/src/types/build.ts
3
+ const UNPLUGIN_BUILD_VARIANTS = [
4
+ "rollup",
5
+ "webpack",
6
+ "rspack",
7
+ "vite",
8
+ "esbuild",
9
+ "farm",
10
+ "unloader",
11
+ "rolldown"
12
+ ];
13
+
14
+ //#endregion
15
+ exports.UNPLUGIN_BUILD_VARIANTS = UNPLUGIN_BUILD_VARIANTS;
@@ -0,0 +1,149 @@
1
+ import { Configuration } from "webpack";
2
+
3
+ //#region ../powerlines/src/types/build.d.ts
4
+
5
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
6
+ interface BuildConfig {
7
+ /**
8
+ * The platform to build the project for
9
+ *
10
+ * @defaultValue "neutral"
11
+ */
12
+ platform?: "node" | "browser" | "neutral";
13
+ /**
14
+ * Array of strings indicating the polyfills to include for the build.
15
+ *
16
+ * @remarks
17
+ * 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).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * {
22
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
23
+ * }
24
+ * ```
25
+ */
26
+ polyfill?: string[];
27
+ /**
28
+ * 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.
29
+ *
30
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
31
+ */
32
+ mainFields?: string[];
33
+ /**
34
+ * Array of strings indicating what conditions should be used for module resolution.
35
+ */
36
+ conditions?: string[];
37
+ /**
38
+ * Array of strings indicating what file extensions should be used for module resolution.
39
+ *
40
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
41
+ */
42
+ extensions?: string[];
43
+ /**
44
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
45
+ *
46
+ * @remarks
47
+ * 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.
48
+ */
49
+ dedupe?: string[];
50
+ /**
51
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
52
+ */
53
+ builtins?: (string | RegExp)[];
54
+ /**
55
+ * Define global variable replacements.
56
+ *
57
+ * @remarks
58
+ * 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.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * {
63
+ * define: {
64
+ * __VERSION__: '"1.0.0"',
65
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
66
+ * }
67
+ * }
68
+ * ```
69
+ *
70
+ * @see https://esbuild.github.io/api/#define
71
+ * @see https://vitejs.dev/config/build-options.html#define
72
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
73
+ */
74
+ define?: Record<string, any>;
75
+ /**
76
+ * Global variables that will have import statements injected where necessary
77
+ *
78
+ * @remarks
79
+ * 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.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * {
84
+ * inject: {
85
+ * process: 'process/browser',
86
+ * Buffer: ['buffer', 'Buffer'],
87
+ * }
88
+ * }
89
+ * ```
90
+ *
91
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
92
+ */
93
+ inject?: Record<string, string | string[]>;
94
+ /**
95
+ * The alias mappings to use for module resolution during the build process.
96
+ *
97
+ * @remarks
98
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * {
103
+ * alias: {
104
+ * "@utils": "./src/utils",
105
+ * "@components": "./src/components"
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
111
+ */
112
+ alias?: Record<string, string> | Array<{
113
+ find: string | RegExp;
114
+ replacement: string;
115
+ }>;
116
+ /**
117
+ * A list of modules that should not be bundled, even if they are external dependencies.
118
+ *
119
+ * @remarks
120
+ * 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.
121
+ */
122
+ external?: (string | RegExp)[];
123
+ /**
124
+ * A list of modules that should always be bundled, even if they are external dependencies.
125
+ */
126
+ noExternal?: (string | RegExp)[];
127
+ /**
128
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
129
+ */
130
+ skipNodeModulesBundle?: boolean;
131
+ /**
132
+ * 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.
133
+ *
134
+ * @defaultValue false
135
+ */
136
+ keepProcessEnv?: boolean;
137
+ /**
138
+ * An optional set of override options to apply to the selected build variant.
139
+ *
140
+ * @remarks
141
+ * 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.
142
+ */
143
+ override?: Record<string, any>;
144
+ }
145
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
146
+ type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
147
+ type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
148
+ //#endregion
149
+ export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, WebpackBuildConfig, WebpackResolvedBuildConfig };
@@ -0,0 +1,149 @@
1
+ import { Configuration } from "webpack";
2
+
3
+ //#region ../powerlines/src/types/build.d.ts
4
+
5
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
6
+ interface BuildConfig {
7
+ /**
8
+ * The platform to build the project for
9
+ *
10
+ * @defaultValue "neutral"
11
+ */
12
+ platform?: "node" | "browser" | "neutral";
13
+ /**
14
+ * Array of strings indicating the polyfills to include for the build.
15
+ *
16
+ * @remarks
17
+ * 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).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * {
22
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
23
+ * }
24
+ * ```
25
+ */
26
+ polyfill?: string[];
27
+ /**
28
+ * 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.
29
+ *
30
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
31
+ */
32
+ mainFields?: string[];
33
+ /**
34
+ * Array of strings indicating what conditions should be used for module resolution.
35
+ */
36
+ conditions?: string[];
37
+ /**
38
+ * Array of strings indicating what file extensions should be used for module resolution.
39
+ *
40
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
41
+ */
42
+ extensions?: string[];
43
+ /**
44
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
45
+ *
46
+ * @remarks
47
+ * 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.
48
+ */
49
+ dedupe?: string[];
50
+ /**
51
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
52
+ */
53
+ builtins?: (string | RegExp)[];
54
+ /**
55
+ * Define global variable replacements.
56
+ *
57
+ * @remarks
58
+ * 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.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * {
63
+ * define: {
64
+ * __VERSION__: '"1.0.0"',
65
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
66
+ * }
67
+ * }
68
+ * ```
69
+ *
70
+ * @see https://esbuild.github.io/api/#define
71
+ * @see https://vitejs.dev/config/build-options.html#define
72
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
73
+ */
74
+ define?: Record<string, any>;
75
+ /**
76
+ * Global variables that will have import statements injected where necessary
77
+ *
78
+ * @remarks
79
+ * 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.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * {
84
+ * inject: {
85
+ * process: 'process/browser',
86
+ * Buffer: ['buffer', 'Buffer'],
87
+ * }
88
+ * }
89
+ * ```
90
+ *
91
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
92
+ */
93
+ inject?: Record<string, string | string[]>;
94
+ /**
95
+ * The alias mappings to use for module resolution during the build process.
96
+ *
97
+ * @remarks
98
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * {
103
+ * alias: {
104
+ * "@utils": "./src/utils",
105
+ * "@components": "./src/components"
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
111
+ */
112
+ alias?: Record<string, string> | Array<{
113
+ find: string | RegExp;
114
+ replacement: string;
115
+ }>;
116
+ /**
117
+ * A list of modules that should not be bundled, even if they are external dependencies.
118
+ *
119
+ * @remarks
120
+ * 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.
121
+ */
122
+ external?: (string | RegExp)[];
123
+ /**
124
+ * A list of modules that should always be bundled, even if they are external dependencies.
125
+ */
126
+ noExternal?: (string | RegExp)[];
127
+ /**
128
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
129
+ */
130
+ skipNodeModulesBundle?: boolean;
131
+ /**
132
+ * 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.
133
+ *
134
+ * @defaultValue false
135
+ */
136
+ keepProcessEnv?: boolean;
137
+ /**
138
+ * An optional set of override options to apply to the selected build variant.
139
+ *
140
+ * @remarks
141
+ * 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.
142
+ */
143
+ override?: Record<string, any>;
144
+ }
145
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
146
+ type WebpackBuildConfig = Omit<Configuration, "name" | "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw"> & BuildConfig;
147
+ type WebpackResolvedBuildConfig = Configuration & BuildResolvedConfig;
148
+ //#endregion
149
+ export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, WebpackBuildConfig, WebpackResolvedBuildConfig };
@@ -0,0 +1,14 @@
1
+ //#region ../powerlines/src/types/build.ts
2
+ const UNPLUGIN_BUILD_VARIANTS = [
3
+ "rollup",
4
+ "webpack",
5
+ "rspack",
6
+ "vite",
7
+ "esbuild",
8
+ "farm",
9
+ "unloader",
10
+ "rolldown"
11
+ ];
12
+
13
+ //#endregion
14
+ export { UNPLUGIN_BUILD_VARIANTS };
@@ -0,0 +1,16 @@
1
+
2
+ //#region ../powerlines/src/types/commands.ts
3
+ const SUPPORTED_COMMANDS = [
4
+ "new",
5
+ "clean",
6
+ "prepare",
7
+ "lint",
8
+ "test",
9
+ "build",
10
+ "docs",
11
+ "deploy",
12
+ "finalize"
13
+ ];
14
+
15
+ //#endregion
16
+ exports.SUPPORTED_COMMANDS = SUPPORTED_COMMANDS;
@@ -0,0 +1,8 @@
1
+ import { MaybePromise } from "@stryke/types/base";
2
+ import { ArrayValues } from "@stryke/types/array";
3
+
4
+ //#region ../powerlines/src/types/commands.d.ts
5
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
6
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
7
+ //#endregion
8
+ export { CommandType };
@@ -0,0 +1,9 @@
1
+ import "./context.mjs";
2
+ import { MaybePromise } from "@stryke/types/base";
3
+ import { ArrayValues } from "@stryke/types/array";
4
+
5
+ //#region ../powerlines/src/types/commands.d.ts
6
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
7
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
8
+ //#endregion
9
+ export { CommandType };
@@ -0,0 +1,15 @@
1
+ //#region ../powerlines/src/types/commands.ts
2
+ const SUPPORTED_COMMANDS = [
3
+ "new",
4
+ "clean",
5
+ "prepare",
6
+ "lint",
7
+ "test",
8
+ "build",
9
+ "docs",
10
+ "deploy",
11
+ "finalize"
12
+ ];
13
+
14
+ //#endregion
15
+ export { SUPPORTED_COMMANDS };