@powerlines/plugin-webpack 0.5.130 → 0.5.131

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