@powerlines/plugin-webpack 0.5.241 → 0.5.243

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 (114) hide show
  1. package/dist/helpers/unplugin.cjs +2 -3
  2. package/dist/helpers/unplugin.mjs +1 -2
  3. package/dist/index.cjs +2 -2
  4. package/dist/index.d.cts +3 -2
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +3 -3
  7. package/dist/types/plugin.d.cts +3 -3
  8. package/dist/types/plugin.d.mts +3 -3
  9. package/package.json +96 -15
  10. package/dist/powerlines/package.cjs +0 -11
  11. package/dist/powerlines/package.mjs +0 -5
  12. package/dist/powerlines/schemas/fs.cjs +0 -226
  13. package/dist/powerlines/schemas/fs.mjs +0 -224
  14. package/dist/powerlines/src/api.cjs +0 -568
  15. package/dist/powerlines/src/api.mjs +0 -566
  16. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -50
  17. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -47
  18. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -78
  19. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -76
  20. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -65
  21. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  22. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  23. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -63
  24. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -24
  25. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -23
  26. package/dist/powerlines/src/internal/helpers/install.cjs +0 -36
  27. package/dist/powerlines/src/internal/helpers/install.mjs +0 -35
  28. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -97
  29. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -93
  30. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  31. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  32. package/dist/powerlines/src/lib/build/webpack.cjs +0 -38
  33. package/dist/powerlines/src/lib/build/webpack.mjs +0 -36
  34. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  35. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  36. package/dist/powerlines/src/lib/constants/environments.cjs +0 -8
  37. package/dist/powerlines/src/lib/constants/environments.mjs +0 -6
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  40. package/dist/powerlines/src/lib/contexts/context.cjs +0 -951
  41. package/dist/powerlines/src/lib/contexts/context.mjs +0 -949
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -78
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -77
  46. package/dist/powerlines/src/lib/entry.cjs +0 -85
  47. package/dist/powerlines/src/lib/entry.mjs +0 -83
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -912
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -910
  58. package/dist/powerlines/src/lib/logger.cjs +0 -58
  59. package/dist/powerlines/src/lib/logger.mjs +0 -55
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -103
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -101
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -4
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -6
  70. package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +0 -66
  71. package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +0 -65
  72. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -71
  73. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -70
  74. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  75. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  76. package/dist/powerlines/src/lib/utilities/format.cjs +0 -48
  77. package/dist/powerlines/src/lib/utilities/format.mjs +0 -46
  78. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -44
  79. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -40
  80. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  81. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  82. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
  83. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
  84. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  85. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  86. package/dist/powerlines/src/types/api.d.cts +0 -104
  87. package/dist/powerlines/src/types/api.d.mts +0 -104
  88. package/dist/powerlines/src/types/babel.d.mts +0 -2
  89. package/dist/powerlines/src/types/build.cjs +0 -23
  90. package/dist/powerlines/src/types/build.d.cts +0 -185
  91. package/dist/powerlines/src/types/build.d.mts +0 -185
  92. package/dist/powerlines/src/types/build.mjs +0 -21
  93. package/dist/powerlines/src/types/commands.cjs +0 -16
  94. package/dist/powerlines/src/types/commands.d.cts +0 -8
  95. package/dist/powerlines/src/types/commands.d.mts +0 -9
  96. package/dist/powerlines/src/types/commands.mjs +0 -15
  97. package/dist/powerlines/src/types/config.d.cts +0 -424
  98. package/dist/powerlines/src/types/config.d.mts +0 -425
  99. package/dist/powerlines/src/types/context.d.cts +0 -514
  100. package/dist/powerlines/src/types/context.d.mts +0 -514
  101. package/dist/powerlines/src/types/fs.d.cts +0 -486
  102. package/dist/powerlines/src/types/fs.d.mts +0 -486
  103. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  104. package/dist/powerlines/src/types/hooks.d.mts +0 -32
  105. package/dist/powerlines/src/types/plugin.cjs +0 -33
  106. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  107. package/dist/powerlines/src/types/plugin.d.mts +0 -205
  108. package/dist/powerlines/src/types/plugin.mjs +0 -32
  109. package/dist/powerlines/src/types/resolved.d.cts +0 -93
  110. package/dist/powerlines/src/types/resolved.d.mts +0 -93
  111. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  112. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
  113. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
  114. package/dist/powerlines/src/types/unplugin.d.mts +0 -23
@@ -1,951 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- const require_tsconfig = require('../typescript/tsconfig.cjs');
3
- const require_config_file = require('../config-file.cjs');
4
- const require_resolver = require('../../internal/helpers/resolver.cjs');
5
- const require_helpers = require('../../plugin-utils/helpers.cjs');
6
- const require_paths = require('../../plugin-utils/paths.cjs');
7
- const require_entry = require('../entry.cjs');
8
- const require_logger = require('../logger.cjs');
9
- const require_vfs = require('../fs/vfs.cjs');
10
- const require_meta = require('../utilities/meta.cjs');
11
- let defu = require("defu");
12
- defu = require_rolldown_runtime.__toESM(defu);
13
- let __stryke_helpers_omit = require("@stryke/helpers/omit");
14
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
15
- let __stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
16
- let __stryke_convert_to_array = require("@stryke/convert/to-array");
17
- let __stryke_fs_resolve = require("@stryke/fs/resolve");
18
- let __stryke_path_append = require("@stryke/path/append");
19
- let __stryke_path_replace = require("@stryke/path/replace");
20
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
21
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
22
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
23
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
24
- let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
25
- let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
26
- let __stryke_fs_json = require("@stryke/fs/json");
27
- let __stryke_json_storm_json = require("@stryke/json/storm-json");
28
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
29
- let __stryke_fs_exists = require("@stryke/fs/exists");
30
- let __stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
31
- let __stryke_hash_hash_files = require("@stryke/hash/hash-files");
32
- let __stryke_hash_murmurhash = require("@stryke/hash/murmurhash");
33
- let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
34
- let __stryke_http_fetch = require("@stryke/http/fetch");
35
- let __stryke_path_join = require("@stryke/path/join");
36
- let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
37
- let __stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
38
- let bundle_require = require("bundle-require");
39
- let flat_cache = require("flat-cache");
40
- let oxc_parser = require("oxc-parser");
41
- let undici = require("undici");
42
-
43
- //#region ../powerlines/src/lib/contexts/context.ts
44
- const configCache = /* @__PURE__ */ new WeakMap();
45
- const envPathCache = /* @__PURE__ */ new WeakMap();
46
- (0, undici.setGlobalDispatcher)(new undici.Agent({ keepAliveTimeout: 1e4 }).compose(undici.interceptors.retry({
47
- maxRetries: 3,
48
- minTimeout: 1e3,
49
- maxTimeout: 1e4,
50
- timeoutFactor: 2,
51
- retryAfter: true
52
- })));
53
- var PowerlinesContext = class PowerlinesContext {
54
- /**
55
- * Internal references storage
56
- *
57
- * @danger
58
- * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
59
- *
60
- * @internal
61
- */
62
- #internal = {};
63
- #workspaceConfig;
64
- #checksum = null;
65
- #buildId = (0, __stryke_unique_id_uuid.uuid)();
66
- #releaseId = (0, __stryke_unique_id_uuid.uuid)();
67
- #timestamp = Date.now();
68
- #fs;
69
- #tsconfig;
70
- #parserCache;
71
- #requestCache;
72
- #getConfigProps(config = {}) {
73
- return (0, defu.default)({
74
- variant: config.build?.variant,
75
- projectType: config.type,
76
- projectRoot: config.root,
77
- name: config.name,
78
- title: config.title,
79
- organization: config.organization,
80
- compatibilityDate: config.compatibilityDate,
81
- description: config.description,
82
- sourceRoot: config.sourceRoot,
83
- configFile: config.configFile,
84
- customLogger: config.customLogger,
85
- logLevel: config.logLevel,
86
- tsconfig: config.tsconfig,
87
- tsconfigRaw: config.tsconfigRaw,
88
- skipCache: config.skipCache,
89
- autoInstall: config.autoInstall,
90
- entry: config.entry,
91
- output: config.output,
92
- plugins: config.plugins,
93
- mode: config.mode,
94
- lint: config.lint,
95
- transform: config.transform,
96
- build: config.build,
97
- framework: config.framework,
98
- ...config
99
- }, { output: config.framework ? {
100
- artifactsPath: `.${config.framework ?? "powerlines"}`,
101
- dts: (0, __stryke_path_join.joinPaths)(config.root ?? this.config.projectRoot, `${config.framework ?? "powerlines"}.d.ts`)
102
- } : {} });
103
- }
104
- /**
105
- * Create a new Storm context from the workspace root and user config.
106
- *
107
- * @param workspaceRoot - The root directory of the workspace.
108
- * @param config - The user configuration options.
109
- * @returns A promise that resolves to the new context.
110
- */
111
- static async from(workspaceRoot, config) {
112
- const context = new PowerlinesContext(await require_config_file.loadWorkspaceConfig(workspaceRoot, config.root));
113
- await context.withUserConfig(config);
114
- const powerlinesPath = await (0, __stryke_fs_resolve.resolvePackage)("powerlines");
115
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
116
- context.powerlinesPath = powerlinesPath;
117
- return context;
118
- }
119
- /**
120
- * An object containing the dependencies that should be installed for the project
121
- */
122
- dependencies = {};
123
- /**
124
- * An object containing the development dependencies that should be installed for the project
125
- */
126
- devDependencies = {};
127
- /**
128
- * The persisted meta information about the current build
129
- */
130
- persistedMeta = void 0;
131
- /**
132
- * The path to the Powerlines package
133
- */
134
- powerlinesPath;
135
- /**
136
- * The parsed `package.json` file for the project
137
- */
138
- packageJson;
139
- /**
140
- * The parsed `project.json` file for the project
141
- */
142
- projectJson = void 0;
143
- /**
144
- * The module resolver for the project
145
- */
146
- resolver;
147
- /**
148
- * The resolved configuration options
149
- */
150
- resolvePatterns = [];
151
- /**
152
- * Internal context fields and methods
153
- *
154
- * @danger
155
- * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
156
- *
157
- * @internal
158
- */
159
- get $$internal() {
160
- return this.#internal;
161
- }
162
- /**
163
- * Internal context fields and methods
164
- *
165
- * @danger
166
- * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
167
- *
168
- * @internal
169
- */
170
- set $$internal(value) {
171
- this.#internal = value;
172
- }
173
- /**
174
- * The resolved entry type definitions for the project
175
- */
176
- get entry() {
177
- const entry = this._entry;
178
- return require_entry.resolveEntriesSync(this, !entry || entry.length === 0 ? (0, __stryke_convert_to_array.toArray)(this.config.entry) : entry);
179
- }
180
- /**
181
- * The TypeScript configuration parsed from the tsconfig file
182
- */
183
- get tsconfig() {
184
- if (!this.#tsconfig) this.tsconfig = { tsconfigFilePath: this.config.tsconfig };
185
- return this.#tsconfig;
186
- }
187
- /**
188
- * Sets the TypeScript configuration parsed from the tsconfig file
189
- */
190
- set tsconfig(value) {
191
- this.#tsconfig = value;
192
- this.resolvePatterns = (0, bundle_require.tsconfigPathsToRegExp)(value?.options?.paths ?? {});
193
- }
194
- /**
195
- * The virtual file system interface for the project
196
- */
197
- get fs() {
198
- if (!this.#fs) this.#fs = require_vfs.VirtualFileSystem.createSync(this);
199
- return this.#fs;
200
- }
201
- /**
202
- * Get the checksum of the project's current state
203
- */
204
- get checksum() {
205
- return this.#checksum;
206
- }
207
- /**
208
- * The meta information about the current build
209
- */
210
- get meta() {
211
- return {
212
- buildId: this.#buildId,
213
- releaseId: this.#releaseId,
214
- checksum: this.#checksum,
215
- timestamp: this.#timestamp,
216
- projectRootHash: (0, __stryke_hash_murmurhash.murmurhash)({
217
- workspaceRoot: this.workspaceConfig?.workspaceRoot,
218
- projectRoot: this.config?.projectRoot
219
- }, { maxLength: require_meta.PROJECT_ROOT_HASH_LENGTH }),
220
- configHash: (0, __stryke_hash_murmurhash.murmurhash)(this.config, { maxLength: require_meta.CACHE_HASH_LENGTH })
221
- };
222
- }
223
- /**
224
- * The resolved configuration options
225
- */
226
- get config() {
227
- return this.resolvedConfig ?? {};
228
- }
229
- /**
230
- * The logger function
231
- */
232
- get log() {
233
- if (!this.logFn) this.logFn = this.createLog();
234
- return this.logFn;
235
- }
236
- /**
237
- * The workspace configuration
238
- */
239
- get workspaceConfig() {
240
- return this.#workspaceConfig;
241
- }
242
- /**
243
- * The environment paths for the project
244
- */
245
- get envPaths() {
246
- if (envPathCache.has({
247
- workspaceRoot: this.workspaceConfig.workspaceRoot,
248
- framework: this.config?.framework || "powerlines"
249
- })) return envPathCache.get({
250
- workspaceRoot: this.workspaceConfig.workspaceRoot,
251
- framework: this.config?.framework || "powerlines"
252
- });
253
- const envPaths = (0, __stryke_env_get_env_paths.getEnvPaths)({
254
- orgId: "storm-software",
255
- appId: this.config?.framework || "powerlines",
256
- workspaceRoot: this.workspaceConfig.workspaceRoot
257
- });
258
- envPathCache.set({
259
- workspaceRoot: this.workspaceConfig.workspaceRoot,
260
- framework: this.config?.framework || "powerlines"
261
- }, envPaths);
262
- return envPaths;
263
- }
264
- /**
265
- * Get the path to the artifacts directory for the project
266
- */
267
- get artifactsPath() {
268
- return (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsPath);
269
- }
270
- /**
271
- * Get the path to the builtin modules used by the project
272
- */
273
- get builtinsPath() {
274
- return (0, __stryke_path_join.joinPaths)(this.artifactsPath, "builtins");
275
- }
276
- /**
277
- * Get the path to the entry directory for the project
278
- */
279
- get entryPath() {
280
- return (0, __stryke_path_join.joinPaths)(this.artifactsPath, "entry");
281
- }
282
- /**
283
- * Get the path to the data directory for the project
284
- */
285
- get dataPath() {
286
- return (0, __stryke_path_join.joinPaths)(this.envPaths.data, "projects", require_meta.getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
287
- }
288
- /**
289
- * Get the path to the cache directory for the project
290
- */
291
- get cachePath() {
292
- return (0, __stryke_path_join.joinPaths)(this.envPaths.cache, "projects", (0, __stryke_hash_murmurhash.murmurhash)({
293
- checksum: this.#checksum,
294
- config: this.meta.configHash
295
- }, { maxLength: require_meta.CACHE_HASH_LENGTH }));
296
- }
297
- /**
298
- * Get the path to the generated declaration file for the project
299
- */
300
- get dtsPath() {
301
- return this.config.output.dts ? (0, __stryke_path_append.appendPath)(this.config.output.dts, this.workspaceConfig.workspaceRoot) : (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "powerlines.d.ts");
302
- }
303
- /**
304
- * Get the project root relative to the workspace root
305
- */
306
- get relativeToWorkspaceRoot() {
307
- return (0, __stryke_fs_get_workspace_root.relativeToWorkspaceRoot)(this.config.projectRoot);
308
- }
309
- /**
310
- * The builtin module id that exist in the Powerlines virtual file system
311
- */
312
- get builtins() {
313
- return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
314
- }
315
- /**
316
- * The alias mappings for the project used during module resolution
317
- *
318
- * @remarks
319
- * This includes both the built-in module aliases as well as any custom aliases defined in the build configuration.
320
- */
321
- get alias() {
322
- return this.builtins.reduce((ret, id) => {
323
- const moduleId = `${this.config?.framework || "powerlines"}:${id.replace(/^.*?:/, "")}`;
324
- if (!ret[moduleId]) {
325
- const path = this.fs.paths[id];
326
- if (path) ret[moduleId] = path;
327
- }
328
- return ret;
329
- }, this.config.build.alias ? Array.isArray(this.config.build.alias) ? this.config.build.alias.reduce((ret, alias) => {
330
- if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
331
- return ret;
332
- }, {}) : this.config.build.alias : {});
333
- }
334
- /**
335
- * Gets the parser cache.
336
- */
337
- get parserCache() {
338
- if (!this.#parserCache) this.#parserCache = (0, flat_cache.create)({
339
- cacheId: "parser",
340
- cacheDir: this.cachePath,
341
- ttl: 7200 * 1e3,
342
- lruSize: 5e3,
343
- persistInterval: 250
344
- });
345
- return this.#parserCache;
346
- }
347
- /**
348
- * Gets the request cache.
349
- */
350
- get requestCache() {
351
- if (!this.#requestCache) this.#requestCache = (0, flat_cache.create)({
352
- cacheId: "http",
353
- cacheDir: this.cachePath,
354
- ttl: 360 * 60 * 1e3,
355
- lruSize: 5e3,
356
- persistInterval: 250
357
- });
358
- return this.#requestCache;
359
- }
360
- /**
361
- * The entry points that exist in the Powerlines virtual file system
362
- */
363
- get _entry() {
364
- return Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "entry").map(([path, meta]) => {
365
- const typeDefinition = { file: path };
366
- if (meta.properties) {
367
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties.file)) typeDefinition.file = meta.properties.file;
368
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties.name)) typeDefinition.name = meta.properties.name;
369
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties["input.file"]) || (0, __stryke_type_checks_is_set_string.isSetString)(meta.properties["input.name"])) {
370
- typeDefinition.input ??= {};
371
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties["input.file"])) typeDefinition.input.file = meta.properties["input.file"];
372
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties["input.name"])) typeDefinition.input.name = meta.properties["input.name"];
373
- }
374
- if ((0, __stryke_type_checks_is_set_string.isSetString)(meta.properties.output)) typeDefinition.output = meta.properties.output;
375
- }
376
- return typeDefinition;
377
- }).filter(Boolean);
378
- }
379
- /**
380
- * A function to perform HTTP fetch requests
381
- *
382
- * @remarks
383
- * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
384
- *
385
- * @example
386
- * ```ts
387
- * const response = await context.fetch("https://api.example.com/data");
388
- * const data = await response.json();
389
- * ```
390
- *
391
- * @see https://github.com/nodejs/undici
392
- *
393
- * @param input - The URL to fetch.
394
- * @param options - The fetch request options.
395
- * @returns A promise that resolves to a response returned by the fetch.
396
- */
397
- async fetch(input, options = {}) {
398
- const cacheKey = (0, __stryke_hash_murmurhash.murmurhash)({
399
- input: input.toString(),
400
- options: JSON.stringify(options)
401
- });
402
- if (!this.config.skipCache && !options.skipCache) {
403
- const cached = this.requestCache.get(cacheKey);
404
- if (cached) return new undici.Response(cached.body, {
405
- status: cached.status,
406
- statusText: cached.statusText,
407
- headers: cached.headers
408
- });
409
- }
410
- const response = await (0, __stryke_http_fetch.fetchRequest)(input, {
411
- timeout: 12e3,
412
- ...options
413
- });
414
- const result = {
415
- body: await response.text(),
416
- status: response.status,
417
- statusText: response.statusText,
418
- headers: Object.fromEntries(response.headers.entries())
419
- };
420
- if (!this.config.skipCache && !options.skipCache) try {
421
- this.requestCache.set(cacheKey, result);
422
- } catch {}
423
- return new undici.Response(result.body, {
424
- status: result.status,
425
- statusText: result.statusText,
426
- headers: result.headers
427
- });
428
- }
429
- /**
430
- * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
431
- *
432
- * @remarks
433
- * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
434
- *
435
- * @example
436
- * ```ts
437
- * const ast = context.parse("const x: number = 42;");
438
- * ```
439
- *
440
- * @see https://rollupjs.org/plugin-development/#this-parse
441
- * @see https://github.com/oxc/oxc
442
- *
443
- * @param code - The source code to parse.
444
- * @param options - The options to pass to the parser.
445
- * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
446
- */
447
- async parse(code, options = {}) {
448
- const cacheKey = (0, __stryke_hash_murmurhash.murmurhash)({
449
- code,
450
- options
451
- });
452
- let result;
453
- if (!this.config.skipCache) {
454
- result = this.parserCache.get(cacheKey);
455
- if (result) return result;
456
- }
457
- result = await (0, oxc_parser.parse)(`source.${options.lang || "ts"}`, code, {
458
- ...options,
459
- sourceType: "module",
460
- showSemanticErrors: this.config.mode === "development"
461
- });
462
- if (!this.config.skipCache) this.parserCache.set(cacheKey, result);
463
- return result;
464
- }
465
- /**
466
- * A helper function to resolve modules in the Virtual File System
467
- *
468
- * @remarks
469
- * This function can be used to resolve modules relative to the project root directory.
470
- *
471
- * @example
472
- * ```ts
473
- * const resolved = await context.resolve("some-module", "/path/to/importer");
474
- * ```
475
- *
476
- * @param id - The module to resolve.
477
- * @param importer - An optional path to the importer module.
478
- * @param options - Additional resolution options.
479
- * @returns A promise that resolves to the resolved module path.
480
- */
481
- async resolve(id, importer, options = {}) {
482
- let moduleId = id;
483
- if (this.config.build.alias) {
484
- if (Array.isArray(this.config.build.alias)) {
485
- const alias = this.config.build.alias.find((a) => (0, bundle_require.match)(moduleId, [a.find]));
486
- if (alias) moduleId = alias.replacement;
487
- } else if ((0, __stryke_type_checks_is_set_object.isSetObject)(this.config.build.alias) && this.config.build.alias[id]) moduleId = this.config.build.alias[id];
488
- }
489
- if (this.fs.isVirtual(moduleId)) {
490
- const result = await this.fs.resolve(moduleId, importer, {
491
- conditions: this.config.build.conditions,
492
- extensions: this.config.build.extensions,
493
- ...options
494
- });
495
- if (!result) return;
496
- return {
497
- id: `\0${result}`,
498
- external: this.config.projectType !== "application"
499
- };
500
- }
501
- if (this.config.build.skipNodeModulesBundle) {
502
- if ((0, bundle_require.match)(moduleId, this.resolvePatterns) || (0, bundle_require.match)(moduleId, this.config.build.noExternal)) return;
503
- if ((0, bundle_require.match)(moduleId, this.config.build.external) || moduleId.startsWith("node:")) return {
504
- id: moduleId,
505
- external: true
506
- };
507
- if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(moduleId)) return {
508
- id: moduleId,
509
- external: true
510
- };
511
- } else {
512
- if ((0, bundle_require.match)(moduleId, this.config.build.noExternal)) return;
513
- if ((0, bundle_require.match)(moduleId, this.config.build.external) || moduleId.startsWith("node:")) return {
514
- id: moduleId,
515
- external: true
516
- };
517
- }
518
- }
519
- /**
520
- * A helper function to load modules from the Virtual File System
521
- *
522
- * @remarks
523
- * This function can be used to load modules relative to the project root directory.
524
- *
525
- * @example
526
- * ```ts
527
- * const module = await context.load("some-module", "/path/to/importer");
528
- * ```
529
- *
530
- * @param id - The module to load.
531
- * @returns A promise that resolves to the loaded module.
532
- */
533
- async load(id) {
534
- const resolvedId = await this.fs.resolve(id);
535
- if (!resolvedId) return;
536
- const code = await this.fs.read(resolvedId);
537
- if (!code) return;
538
- return {
539
- code,
540
- map: null
541
- };
542
- }
543
- /**
544
- * Get the builtin virtual files that exist in the Powerlines virtual file system
545
- */
546
- async getBuiltins() {
547
- return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([id, meta]) => {
548
- const code = await this.fs.read(id);
549
- const path = this.fs.paths[id];
550
- return {
551
- ...meta,
552
- path,
553
- code
554
- };
555
- }));
556
- }
557
- /**
558
- * Resolves a file and writes it to the VFS if it does not already exist
559
- *
560
- * @param code - The source code of the file
561
- * @param path - The path to write the file to
562
- * @param options - Additional options for writing the file
563
- */
564
- async emit(code, path, options = {}) {
565
- const filePath = options.extension ? (0, __stryke_path_file_path_fns.findFileExtensionSafe)(path) ? options.extension.startsWith(".") ? path.replace((0, __stryke_path_file_path_fns.findFileDotExtensionSafe)(path), options.extension) : path.replace((0, __stryke_path_file_path_fns.findFileExtensionSafe)(path), options.extension) : options.extension.startsWith(".") ? `${path}${options.extension}` : `${path}.${options.extension}` : (0, __stryke_path_file_path_fns.findFileExtensionSafe)(path) ? path : `${path}.ts`;
566
- if ((0, __stryke_type_checks_is_function.isFunction)(this.emitFile) && options.emitWithBundler) return this.emitFile({
567
- needsCodeReference: options.needsCodeReference,
568
- originalFileName: options.originalFileName,
569
- fileName: filePath,
570
- source: code,
571
- type: "asset"
572
- });
573
- return this.fs.write(filePath, code, options);
574
- }
575
- /**
576
- * Synchronously resolves a file and writes it to the VFS if it does not already exist
577
- *
578
- * @param code - The source code of the file
579
- * @param path - The path to write the file to
580
- * @param options - Additional options for writing the file
581
- */
582
- emitSync(code, path, options = {}) {
583
- const filePath = options.extension ? (0, __stryke_path_file_path_fns.findFileExtensionSafe)(path) ? options.extension.startsWith(".") ? path.replace((0, __stryke_path_file_path_fns.findFileDotExtensionSafe)(path), options.extension) : path.replace((0, __stryke_path_file_path_fns.findFileExtensionSafe)(path), options.extension) : options.extension.startsWith(".") ? `${path}${options.extension}` : `${path}.${options.extension}` : (0, __stryke_path_file_path_fns.findFileExtensionSafe)(path) ? path : `${path}.ts`;
584
- if ((0, __stryke_type_checks_is_function.isFunction)(this.emitFile) && options.emitWithBundler) return this.emitFile({
585
- needsCodeReference: options.needsCodeReference,
586
- originalFileName: options.originalFileName,
587
- fileName: filePath,
588
- source: code,
589
- type: "asset"
590
- });
591
- return this.fs.writeSync(filePath, code, options);
592
- }
593
- /**
594
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
595
- *
596
- * @param code - The source code of the entry file
597
- * @param path - A path to write the entry file to
598
- * @param options - Optional write file options
599
- */
600
- async emitEntry(code, path, options = {}) {
601
- return this.emit(code, (0, __stryke_path_append.appendPath)(path, this.entryPath), (0, defu.default)({ meta: {
602
- type: "entry",
603
- properties: {
604
- file: (0, __stryke_path_append.appendPath)(path, this.entryPath),
605
- name: options?.name,
606
- output: options?.output,
607
- "input.file": options?.input?.file,
608
- "input.name": options?.input?.name
609
- }
610
- } }, (0, __stryke_helpers_omit.omit)(options, ["name"])));
611
- }
612
- /**
613
- * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
614
- *
615
- * @param code - The source code of the entry file
616
- * @param path - A path to write the entry file to
617
- * @param options - Optional write file options
618
- */
619
- emitEntrySync(code, path, options = {}) {
620
- return this.emitSync(code, (0, __stryke_path_append.appendPath)(path, this.entryPath), (0, defu.default)({ meta: {
621
- type: "entry",
622
- properties: {
623
- file: (0, __stryke_path_append.appendPath)(path, this.entryPath),
624
- name: options?.name,
625
- output: options?.output,
626
- "input.file": options?.input?.file,
627
- "input.name": options?.input?.name
628
- }
629
- } }, (0, __stryke_helpers_omit.omit)(options, ["name"])));
630
- }
631
- /**
632
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
633
- *
634
- * @param code - The source code of the builtin file
635
- * @param id - The unique identifier of the builtin file
636
- * @param options - Optional write file options
637
- */
638
- async emitBuiltin(code, id, options = {}) {
639
- if (!this.builtinsPath) throw new Error(`The builtins path is not set. Cannot emit builtin file with id "${id}".`);
640
- if (!(0, __stryke_type_checks_is_set_string.isSetString)(id)) throw new Error(`The builtin id must be a non-empty string. Received: ${String(id)}`);
641
- return this.emit(code, (0, __stryke_path_append.appendPath)(id, this.builtinsPath), (0, defu.default)(options, { meta: {
642
- type: "builtin",
643
- id
644
- } }));
645
- }
646
- /**
647
- * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
648
- *
649
- * @param code - The source code of the builtin file
650
- * @param id - The unique identifier of the builtin file
651
- * @param options - Optional write file options
652
- */
653
- emitBuiltinSync(code, id, options = {}) {
654
- if (!this.builtinsPath) throw new Error(`The builtins path is not set. Cannot emit builtin file with id "${id}".`);
655
- if (!(0, __stryke_type_checks_is_set_string.isSetString)(id)) throw new Error(`The builtin id must be a non-empty string. Received: ${String(id)}`);
656
- return this.emitSync(code, (0, __stryke_path_append.appendPath)(id, this.builtinsPath), (0, defu.default)(options, { meta: {
657
- type: "builtin",
658
- id
659
- } }));
660
- }
661
- /**
662
- * Update the context using a new user configuration options
663
- *
664
- * @param userConfig - The new user configuration options.
665
- */
666
- async withUserConfig(userConfig, options = { isHighPriority: true }) {
667
- this.mergeUserConfig(userConfig);
668
- await this.init(this.config.userConfig, options);
669
- }
670
- /**
671
- * Update the context using a new inline configuration options
672
- *
673
- * @param inlineConfig - The new inline configuration options.
674
- */
675
- async withInlineConfig(inlineConfig, options = { isHighPriority: true }) {
676
- this.config.inlineConfig = inlineConfig;
677
- if (inlineConfig.command === "new") {
678
- const workspacePackageJsonPath = (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, "package.json");
679
- if (!(0, __stryke_fs_exists.existsSync)(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
680
- this.packageJson = await (0, __stryke_fs_json.readJsonFile)(workspacePackageJsonPath);
681
- this.workspaceConfig.repository ??= (0, __stryke_type_checks_is_set_string.isSetString)(this.packageJson?.repository) ? this.packageJson.repository : this.packageJson?.repository?.url;
682
- }
683
- await this.init(this.config.inlineConfig, options);
684
- }
685
- /**
686
- * A logging function for fatal messages
687
- *
688
- * @param message - The message to log.
689
- */
690
- fatal(message) {
691
- this.log(__storm_software_config_tools_types.LogLevelLabel.FATAL, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
692
- }
693
- /**
694
- * A logging function for error messages
695
- *
696
- * @param message - The message to log.
697
- */
698
- error(message) {
699
- this.log(__storm_software_config_tools_types.LogLevelLabel.ERROR, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
700
- }
701
- /**
702
- * A logging function for warning messages
703
- *
704
- * @param message - The message to log.
705
- */
706
- warn(message) {
707
- this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
708
- }
709
- /**
710
- * A logging function for informational messages
711
- *
712
- * @param message - The message to log.
713
- */
714
- info(message) {
715
- this.log(__storm_software_config_tools_types.LogLevelLabel.INFO, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
716
- }
717
- /**
718
- * A logging function for debug messages
719
- *
720
- * @param message - The message to log.
721
- */
722
- debug(message) {
723
- this.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
724
- }
725
- /**
726
- * A logging function for trace messages
727
- *
728
- * @param message - The message to log.
729
- */
730
- trace(message) {
731
- this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
732
- }
733
- /**
734
- * Create a new logger instance
735
- *
736
- * @param name - The name to use for the logger instance
737
- * @returns A logger function
738
- */
739
- createLog(name = null) {
740
- return require_logger.createLog(name, {
741
- ...this.config,
742
- logLevel: (0, __stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel
743
- });
744
- }
745
- /**
746
- * Extend the current logger instance with a new name
747
- *
748
- * @param name - The name to use for the extended logger instance
749
- * @returns A logger function
750
- */
751
- extendLog(name) {
752
- return require_logger.extendLog(this.log, name);
753
- }
754
- /**
755
- * Generates a checksum representing the current context state
756
- *
757
- * @param root - The root directory of the project to generate the checksum for
758
- * @returns A promise that resolves to a string representing the checksum
759
- */
760
- async generateChecksum(root = this.config.projectRoot) {
761
- this.#checksum = await (0, __stryke_hash_hash_files.hashDirectory)(root, { ignore: [
762
- "node_modules",
763
- ".git",
764
- ".nx",
765
- ".cache",
766
- "tmp",
767
- "dist"
768
- ] });
769
- return this.#checksum;
770
- }
771
- /**
772
- * Creates a new StormContext instance.
773
- *
774
- * @param workspaceConfig - The workspace configuration.
775
- */
776
- constructor(workspaceConfig) {
777
- this.#workspaceConfig = workspaceConfig;
778
- envPathCache.set({
779
- workspaceRoot: workspaceConfig.workspaceRoot,
780
- framework: "powerlines"
781
- }, (0, __stryke_env_get_env_paths.getEnvPaths)({
782
- orgId: ((0, __stryke_type_checks_is_set_object.isSetObject)(workspaceConfig.organization) ? workspaceConfig.organization.name : workspaceConfig.organization) || "storm-software",
783
- appId: "powerlines",
784
- workspaceRoot: workspaceConfig.workspaceRoot
785
- }));
786
- }
787
- /**
788
- * The resolved configuration for this context
789
- */
790
- resolvedConfig = {};
791
- /**
792
- * A logger function specific to this context
793
- */
794
- logFn;
795
- /**
796
- * Initialize the context with the provided configuration options
797
- *
798
- * @param config - The partial user configuration to use for initialization.
799
- */
800
- async init(config = {}, options = { isHighPriority: true }) {
801
- const cacheKey = {
802
- projectRoot: config.root ?? this.config.projectRoot ?? this.config.userConfig?.root ?? this.config.inlineConfig?.root,
803
- mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,
804
- skipCache: config.skipCache ?? this.config.skipCache ?? false,
805
- configFile: config.configFile ?? this.config.configFile,
806
- framework: config.framework ?? this.config.framework ?? "powerlines",
807
- command: this.config.inlineConfig?.command,
808
- alias: this.config.build?.alias ?? config.build?.alias
809
- };
810
- if (configCache.has(cacheKey)) {
811
- const result = configCache.get(cacheKey);
812
- this.projectJson = result.projectJson;
813
- this.packageJson = result.packageJson;
814
- this.#checksum = result.checksum;
815
- this.resolver = result.resolver;
816
- this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
817
- } else {
818
- const projectJsonPath = (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, "project.json");
819
- if ((0, __stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, __stryke_fs_json.readJsonFile)(projectJsonPath);
820
- const packageJsonPath = (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, "package.json");
821
- if ((0, __stryke_fs_exists.existsSync)(packageJsonPath)) this.packageJson = await (0, __stryke_fs_json.readJsonFile)(packageJsonPath);
822
- this.#checksum = await this.generateChecksum(cacheKey.projectRoot);
823
- this.resolver = require_resolver.createResolver({
824
- workspaceRoot: this.workspaceConfig.workspaceRoot,
825
- projectRoot: cacheKey.projectRoot,
826
- cacheDir: this.cachePath,
827
- mode: cacheKey.mode,
828
- logLevel: config.logLevel || this.config.logLevel || this.workspaceConfig.logLevel || "info",
829
- skipCache: cacheKey.skipCache,
830
- alias: this.config.build?.alias ? Array.isArray(this.config.build.alias) ? this.config.build.alias.reduce((ret, alias) => {
831
- ret[alias.find.toString()] = alias.replacement;
832
- return ret;
833
- }, {}) : this.config.build.alias : {}
834
- });
835
- const userConfig = await require_config_file.loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
836
- this.mergeUserConfig(userConfig.config);
837
- configCache.set(cacheKey, {
838
- projectJson: this.projectJson,
839
- packageJson: this.packageJson,
840
- checksum: this.#checksum,
841
- resolver: this.resolver,
842
- userConfig
843
- });
844
- }
845
- config.tsconfig ??= require_tsconfig.getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
846
- if ((0, __stryke_type_checks_is_set_object.isSetObject)(config)) this.resolvedConfig = (0, defu.default)({
847
- inlineConfig: this.config.inlineConfig,
848
- userConfig: this.config.userConfig
849
- }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
850
- command: this.config.inlineConfig?.command,
851
- ...this.#getConfigProps(this.config.inlineConfig)
852
- }, this.#getConfigProps(this.config.userConfig), {
853
- mode: this.workspaceConfig?.mode,
854
- logLevel: this.workspaceConfig?.logLevel,
855
- skipCache: this.workspaceConfig?.skipCache
856
- }, {
857
- name: this.projectJson?.name || this.packageJson?.name,
858
- version: this.packageJson?.version,
859
- description: this.packageJson?.description,
860
- sourceRoot: this.projectJson?.sourceRoot || (0, __stryke_path_append.appendPath)("src", cacheKey.projectRoot),
861
- output: (0, defu.default)(config.output ?? {}, {
862
- outputPath: cacheKey.projectRoot ? (0, __stryke_path_join.joinPaths)(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
863
- artifactsPath: `.${config.framework ?? "powerlines"}`,
864
- dts: (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
865
- assets: [
866
- { glob: "LICENSE" },
867
- {
868
- input: cacheKey.projectRoot,
869
- glob: "*.md"
870
- },
871
- {
872
- input: cacheKey.projectRoot,
873
- glob: "package.json"
874
- }
875
- ]
876
- })
877
- }, options.isHighPriority ? {} : this.#getConfigProps(config), {
878
- inlineConfig: {},
879
- userConfig: {},
880
- framework: "powerlines",
881
- mode: "production",
882
- projectType: "application",
883
- logLevel: "info",
884
- preview: false,
885
- environments: {},
886
- transform: { babel: {
887
- plugins: [],
888
- presets: []
889
- } },
890
- lint: { eslint: {} },
891
- build: {
892
- target: "esnext",
893
- platform: "neutral",
894
- override: {}
895
- }
896
- });
897
- this.config.entry = require_entry.getUniqueEntries(this.config.entry);
898
- if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
899
- this.config.title ??= (0, __stryke_string_format_title_case.titleCase)(this.config.name);
900
- this.config.organization ??= ((0, __stryke_type_checks_is_set_object.isSetObject)(this.workspaceConfig.organization) ? this.workspaceConfig.organization.name : this.workspaceConfig.organization) || ((0, __stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? this.packageJson?.author?.name : this.packageJson?.author) || this.config.name;
901
- if (this.config.userConfig.build?.external) this.config.userConfig.build.external = (0, __stryke_helpers_get_unique.getUnique)(this.config.userConfig.build.external);
902
- if (this.config.userConfig.build?.noExternal) this.config.userConfig.build.noExternal = (0, __stryke_helpers_get_unique.getUnique)(this.config.userConfig.build.noExternal);
903
- if (this.config.build.external) this.config.build.external = (0, __stryke_helpers_get_unique.getUnique)(this.config.build.external);
904
- if (this.config.build.noExternal) this.config.build.noExternal = (0, __stryke_helpers_get_unique.getUnique)(this.config.build.noExternal);
905
- this.config.output.format = (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
906
- if (this.config.projectRoot && this.config.projectRoot !== "." && this.config.projectRoot !== "./" && this.config.projectRoot !== this.workspaceConfig.workspaceRoot) {
907
- this.config.output.outputPath ??= (0, __stryke_path_join.joinPaths)("dist", this.config.projectRoot);
908
- this.config.output.buildPath ??= (0, __stryke_path_join.joinPaths)(this.config.projectRoot, "dist");
909
- } else {
910
- this.config.output.outputPath ??= "dist";
911
- this.config.output.buildPath ??= "dist";
912
- }
913
- this.config.output.assets = (0, __stryke_helpers_get_unique.getUniqueBy)(this.config.output.assets.map((asset) => {
914
- return {
915
- glob: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
916
- input: (0, __stryke_type_checks_is_string.isString)(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : (0, __stryke_path_is_parent_path.isParentPath)(asset.input, this.workspaceConfig.workspaceRoot) || asset.input === this.workspaceConfig.workspaceRoot ? asset.input : (0, __stryke_path_append.appendPath)(asset.input, this.workspaceConfig.workspaceRoot),
917
- output: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) && asset.output ? (0, __stryke_path_is_parent_path.isParentPath)(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : (0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.config.output.outputPath, (0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)(asset.output, (0, __stryke_path_replace.replacePath)(this.config.output.outputPath, this.workspaceConfig.workspaceRoot)), this.config.output.outputPath)), this.workspaceConfig.workspaceRoot) : (0, __stryke_path_append.appendPath)(this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
918
- ignore: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, __stryke_convert_to_array.toArray)(asset.ignore) : void 0
919
- };
920
- }), (a) => `${a.input}-${a.glob}-${a.output}`);
921
- this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
922
- if (require_helpers.isPlugin(plugin) && require_helpers.checkDedupe(plugin, ret.filter((p) => require_helpers.isPlugin(p)))) return ret;
923
- ret.push(plugin);
924
- return ret;
925
- }, []);
926
- if (this.config.tsconfig) this.config.tsconfig = require_paths.replacePathTokens(this, this.config.tsconfig);
927
- if (this.config.output.dts) if ((0, __stryke_type_checks_is_set_string.isSetString)(this.config.output.dts)) this.config.output.dts = require_paths.replacePathTokens(this, this.config.output.dts);
928
- else this.config.output.dts = (0, __stryke_path_join.joinPaths)(this.config.projectRoot, `${this.config.framework ?? "powerlines"}.d.ts`);
929
- if (this.config.build.polyfill) this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => require_paths.replacePathTokens(this, polyfill));
930
- if (this.config.output.assets) this.config.output.assets = this.config.output.assets.map((asset) => ({
931
- ...asset,
932
- glob: require_paths.replacePathTokens(this, asset.glob),
933
- ignore: asset.ignore ? asset.ignore.map((ignore) => require_paths.replacePathTokens(this, ignore)) : void 0,
934
- input: require_paths.replacePathTokens(this, asset.input),
935
- output: require_paths.replacePathTokens(this, asset.output)
936
- }));
937
- this.#fs ??= await require_vfs.VirtualFileSystem.create(this);
938
- }
939
- mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
940
- this.config.userConfig = (0, defu.default)({ entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : [] }, (0, __stryke_helpers_omit.omit)(from ?? {}, ["entry"]), (0, __stryke_helpers_omit.omit)(into ?? {}, ["entry"]));
941
- if (this.config.userConfig.output?.format) this.config.userConfig.output.format = (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(this.config.userConfig.output?.format));
942
- this.config.userConfig.plugins = (this.config.userConfig.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
943
- if (require_helpers.isPlugin(plugin) && require_helpers.checkDedupe(plugin, ret.filter((p) => require_helpers.isPlugin(p)))) return ret;
944
- ret.push(plugin);
945
- return ret;
946
- }, []);
947
- }
948
- };
949
-
950
- //#endregion
951
- exports.PowerlinesContext = PowerlinesContext;