@powerlines/plugin-unbuild 0.5.66 → 0.5.68

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 (46) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.mts +3 -2
  5. package/dist/index.mjs +1 -1
  6. package/dist/powerlines/src/lib/build/rollup.cjs +1 -0
  7. package/dist/powerlines/src/lib/build/rollup.mjs +1 -0
  8. package/dist/powerlines/src/lib/build/unbuild.cjs +1 -0
  9. package/dist/powerlines/src/lib/build/unbuild.mjs +1 -0
  10. package/dist/powerlines/src/lib/utilities/source-file.cjs +1 -0
  11. package/dist/powerlines/src/lib/utilities/source-file.mjs +1 -0
  12. package/dist/powerlines/src/types/babel.d.mts +2 -0
  13. package/dist/powerlines/src/types/build.d.cts +143 -0
  14. package/dist/powerlines/src/types/build.d.mts +144 -0
  15. package/dist/powerlines/src/types/commands.d.cts +8 -0
  16. package/dist/powerlines/src/types/commands.d.mts +9 -0
  17. package/dist/powerlines/src/types/config.d.cts +346 -0
  18. package/dist/powerlines/src/types/config.d.mts +346 -0
  19. package/dist/powerlines/src/types/context.d.cts +347 -0
  20. package/dist/powerlines/src/types/context.d.mts +349 -0
  21. package/dist/powerlines/src/types/fs.d.cts +458 -0
  22. package/dist/powerlines/src/types/fs.d.mts +458 -0
  23. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  24. package/dist/powerlines/src/types/plugin.d.cts +232 -0
  25. package/dist/powerlines/src/types/plugin.d.mts +232 -0
  26. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  27. package/dist/powerlines/src/types/resolved.d.mts +83 -0
  28. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  29. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  30. package/dist/types/index.cjs +0 -1
  31. package/dist/types/index.d.cts +1 -2
  32. package/dist/types/index.d.mts +1 -2
  33. package/dist/types/index.mjs +1 -1
  34. package/dist/types/plugin.cjs +0 -1
  35. package/dist/types/plugin.d.cts +12 -1
  36. package/dist/types/plugin.d.mts +12 -1
  37. package/dist/types/plugin.mjs +1 -1
  38. package/package.json +10 -10
  39. package/dist/index-BgAdqTbb.d.mts +0 -1
  40. package/dist/index-CEgs-Dz2.d.cts +0 -1
  41. package/dist/plugin-BcPZE-Tv.d.mts +0 -1653
  42. package/dist/plugin-Blqo7szl.d.cts +0 -1652
  43. package/dist/plugin-Bvn-he2n.mjs +0 -1
  44. package/dist/plugin-DHXHjv16.cjs +0 -0
  45. package/dist/types-B7VYa_Pp.mjs +0 -1
  46. package/dist/types-DHkg7xmX.cjs +0 -0
@@ -1,1653 +0,0 @@
1
- import "esbuild";
2
- import { SourceMap } from "magic-string";
3
- import { ArrayValues } from "@stryke/types/array";
4
- import { FunctionLike, MaybePromise, NonUndefined } from "@stryke/types/base";
5
- import { ExternalIdResult, HookFilter, TransformResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage, UnpluginOptions } from "unplugin";
6
- import { UnbuildOptions } from "@storm-software/unbuild/types";
7
- import { PreviewOptions, ResolvedPreviewOptions } from "vite";
8
- import { EnvPaths } from "@stryke/env/get-env-paths";
9
- import { FetchRequestOptions } from "@stryke/http/fetch";
10
- import { PackageJson } from "@stryke/types/package-json";
11
- import { Jiti } from "jiti";
12
- import { ParseResult, ParserOptions } from "oxc-parser";
13
- import { Range } from "semver";
14
- import { Project } from "ts-morph";
15
- import { RequestInfo, Response } from "undici";
16
- import { Format } from "@storm-software/build-tools/types";
17
- import { LogLevelLabel } from "@storm-software/config-tools/types";
18
- import { StormWorkspaceConfig } from "@storm-software/config/types";
19
- import { TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
20
- import { AssetGlob } from "@stryke/types/file";
21
- import { ResolveOptions } from "@stryke/fs/resolve";
22
- import { CompilerOptions, TsConfigJson } from "@stryke/types/tsconfig";
23
- import ts from "typescript";
24
-
25
- //#region ../powerlines/src/types/build.d.ts
26
- type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
27
- interface BuildConfig {
28
- /**
29
- * The platform to build the project for
30
- *
31
- * @defaultValue "neutral"
32
- */
33
- platform?: "node" | "browser" | "neutral";
34
- /**
35
- * Array of strings indicating the polyfills to include for the build.
36
- *
37
- * @remarks
38
- * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
39
- *
40
- * @example
41
- * ```ts
42
- * {
43
- * polyfill: ['{projectRoot}/custom-polyfill.ts']
44
- * }
45
- * ```
46
- */
47
- polyfill?: string[];
48
- /**
49
- * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
50
- *
51
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
52
- */
53
- mainFields?: string[];
54
- /**
55
- * Array of strings indicating what conditions should be used for module resolution.
56
- */
57
- conditions?: string[];
58
- /**
59
- * Array of strings indicating what file extensions should be used for module resolution.
60
- *
61
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
62
- */
63
- extensions?: string[];
64
- /**
65
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
66
- *
67
- * @remarks
68
- * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
69
- */
70
- dedupe?: string[];
71
- /**
72
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
73
- */
74
- builtins?: (string | RegExp)[];
75
- /**
76
- * Define global variable replacements.
77
- *
78
- * @remarks
79
- * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
80
- *
81
- * @example
82
- * ```ts
83
- * {
84
- * define: {
85
- * __VERSION__: '"1.0.0"',
86
- * __DEV__: 'process.env.NODE_ENV !== "production"'
87
- * }
88
- * }
89
- * ```
90
- *
91
- * @see https://esbuild.github.io/api/#define
92
- * @see https://vitejs.dev/config/build-options.html#define
93
- * @see https://github.com/rollup/plugins/tree/master/packages/replace
94
- */
95
- define?: Record<string, any>;
96
- /**
97
- * Global variables that will have import statements injected where necessary
98
- *
99
- * @remarks
100
- * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
101
- *
102
- * @example
103
- * ```ts
104
- * {
105
- * inject: {
106
- * process: 'process/browser',
107
- * Buffer: ['buffer', 'Buffer'],
108
- * }
109
- * }
110
- * ```
111
- *
112
- * @see https://github.com/rollup/plugins/tree/master/packages/inject
113
- */
114
- inject?: Record<string, string | string[]>;
115
- /**
116
- * The alias mappings to use for module resolution during the build process.
117
- *
118
- * @remarks
119
- * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
120
- *
121
- * @example
122
- * ```ts
123
- * {
124
- * alias: {
125
- * "@utils": "./src/utils",
126
- * "@components": "./src/components"
127
- * }
128
- * }
129
- * ```
130
- *
131
- * @see https://github.com/rollup/plugins/tree/master/packages/alias
132
- */
133
- alias?: Record<string, string> | Array<{
134
- find: string | RegExp;
135
- replacement: string;
136
- }>;
137
- /**
138
- * A list of modules that should not be bundled, even if they are external dependencies.
139
- *
140
- * @remarks
141
- * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
142
- */
143
- external?: (string | RegExp)[];
144
- /**
145
- * A list of modules that should always be bundled, even if they are external dependencies.
146
- */
147
- noExternal?: (string | RegExp)[];
148
- /**
149
- * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
150
- */
151
- skipNodeModulesBundle?: boolean;
152
- /**
153
- * An optional set of override options to apply to the selected build variant.
154
- *
155
- * @remarks
156
- * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
157
- */
158
- override?: Record<string, any>;
159
- }
160
- type BuildResolvedConfig = Omit<BuildConfig, "override">;
161
- type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
162
- type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
163
- //#endregion
164
- //#region ../powerlines/src/types/fs.d.ts
165
- declare enum StoragePreset {
166
- VIRTUAL = "virtual",
167
- FS = "fs",
168
- }
169
- /**
170
- * Interface defining the methods and properties for a storage adapter.
171
- */
172
- interface StorageAdapter {
173
- /**
174
- * A name identifying the storage adapter type.
175
- */
176
- name: string;
177
- /**
178
- * Checks if a key exists in the storage.
179
- *
180
- * @param key - The key to check for existence.
181
- * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
182
- */
183
- exists: (key: string) => Promise<boolean>;
184
- /**
185
- * Synchronously checks if a key exists in the storage.
186
- *
187
- * @param key - The key to check for existence.
188
- * @returns Returns `true` if the key exists, otherwise `false`.
189
- */
190
- existsSync: (key: string) => boolean;
191
- /**
192
- * Read a value associated with a key from the storage.
193
- *
194
- * @param key - The key to read the value for.
195
- * @returns A promise that resolves to the value if found, otherwise `null`.
196
- */
197
- get: (key: string) => Promise<string | null>;
198
- /**
199
- * Synchronously reads the value associated with a key from the storage.
200
- *
201
- * @param key - The key to read the value for.
202
- * @returns The value if found, otherwise `null`.
203
- */
204
- getSync: (key: string) => string | null;
205
- /**
206
- * Writes a value to the storage for the given key.
207
- *
208
- * @param key - The key to associate the value with.
209
- * @param value - The value to store.
210
- */
211
- set: (key: string, value: string) => Promise<void>;
212
- /**
213
- * Synchronously writes a value to the storage for the given key.
214
- *
215
- * @param key - The key to associate the value with.
216
- * @param value - The value to store.
217
- */
218
- setSync: (key: string, value: string) => void;
219
- /**
220
- * Removes a value from the storage.
221
- *
222
- * @param key - The key whose value should be removed.
223
- */
224
- remove: (key: string) => Promise<void>;
225
- /**
226
- * Synchronously removes a value from the storage.
227
- *
228
- * @param key - The key whose value should be removed.
229
- */
230
- removeSync: (key: string) => void;
231
- /**
232
- * Creates a directory at the specified path.
233
- *
234
- * @param dirPath - The path of the directory to create.
235
- */
236
- mkdir: (dirPath: string) => Promise<void>;
237
- /**
238
- * Synchronously creates a directory at the specified path.
239
- *
240
- * @param dirPath - The path of the directory to create.
241
- */
242
- mkdirSync: (dirPath: string) => void;
243
- /**
244
- * Remove all entries from the storage that match the provided base path.
245
- *
246
- * @param base - The base path or prefix to clear entries from.
247
- */
248
- clear: (base?: string) => Promise<void>;
249
- /**
250
- * Synchronously remove all entries from the storage that match the provided base path.
251
- *
252
- * @param base - The base path or prefix to clear entries from.
253
- */
254
- clearSync: (base?: string) => void;
255
- /**
256
- * Lists all keys under the provided base path.
257
- *
258
- * @param base - The base path or prefix to list keys from.
259
- * @returns A promise resolving to the list of keys.
260
- */
261
- list: (base?: string) => Promise<string[]>;
262
- /**
263
- * Synchronously lists all keys under the provided base path.
264
- *
265
- * @param base - The base path or prefix to list keys from.
266
- * @returns The list of keys.
267
- */
268
- listSync: (base?: string) => string[];
269
- /**
270
- * Checks if the given key is a directory.
271
- *
272
- * @param key - The key to check.
273
- * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
274
- */
275
- isDirectory: (key: string) => Promise<boolean>;
276
- /**
277
- * Synchronously checks if the given key is a directory.
278
- *
279
- * @param key - The key to check.
280
- * @returns `true` if the key is a directory, otherwise `false`.
281
- */
282
- isDirectorySync: (key: string) => boolean;
283
- /**
284
- * Checks if the given key is a file.
285
- *
286
- * @param key - The key to check.
287
- * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
288
- */
289
- isFile: (key: string) => Promise<boolean>;
290
- /**
291
- * Synchronously checks if the given key is a file.
292
- *
293
- * @param key - The key to check.
294
- * @returns `true` if the key is a file, otherwise `false`.
295
- */
296
- isFileSync: (key: string) => boolean;
297
- /**
298
- * Releases any resources held by the storage adapter.
299
- */
300
- dispose: () => MaybePromise<void>;
301
- }
302
- /**
303
- * A mapping of file paths to storage adapter names and their corresponding {@link StorageAdapter} instances.
304
- */
305
- type StoragePort = Record<string, StorageAdapter>;
306
- interface VirtualFileMetadata {
307
- /**
308
- * The identifier for the file data.
309
- */
310
- id: string;
311
- /**
312
- * The timestamp of the virtual file.
313
- */
314
- timestamp: number;
315
- /**
316
- * The type of the file.
317
- *
318
- * @remarks
319
- * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
320
- * - `builtin`: Indicates that the file is a built-in module provided by the system.
321
- * - `entry`: Indicates that the file is an entry point for execution.
322
- * - `normal`: Indicates that the file is a standard file without any special role.
323
- */
324
- type: string;
325
- /**
326
- * Additional metadata associated with the file.
327
- */
328
- properties: Record<string, string>;
329
- }
330
- interface VirtualFileData {
331
- /**
332
- * The identifier for the file data.
333
- */
334
- id?: string;
335
- /**
336
- * The contents of the virtual file.
337
- */
338
- code: string;
339
- /**
340
- * The type of the file.
341
- *
342
- * @remarks
343
- * This string represents the purpose/function of the file in the virtual file system. A potential list of variants includes:
344
- * - `builtin`: Indicates that the file is a built-in module provided by the system.
345
- * - `entry`: Indicates that the file is an entry point for execution.
346
- * - `normal`: Indicates that the file is a standard file without any special role.
347
- */
348
- type?: string;
349
- /**
350
- * Additional metadata associated with the file.
351
- */
352
- properties?: Record<string, string>;
353
- }
354
- interface VirtualFile extends Required<VirtualFileData>, VirtualFileMetadata {
355
- /**
356
- * An additional name for the file.
357
- */
358
- path: string;
359
- /**
360
- * The timestamp of the virtual file.
361
- */
362
- timestamp: number;
363
- }
364
- interface WriteOptions {
365
- /**
366
- * Should the file skip formatting before being written?
367
- *
368
- * @defaultValue false
369
- */
370
- skipFormat?: boolean;
371
- /**
372
- * Additional metadata for the file.
373
- */
374
- meta?: VirtualFileMetadata;
375
- }
376
- interface ResolveOptions$1 extends ResolveOptions {
377
- /**
378
- * If true, the module is being resolved as an entry point.
379
- */
380
- isEntry?: boolean;
381
- /**
382
- * If true, the resolver will skip using the cache when resolving modules.
383
- */
384
- skipCache?: boolean;
385
- /**
386
- * An array of external modules or patterns to exclude from resolution.
387
- */
388
- external?: (string | RegExp)[];
389
- /**
390
- * An array of modules or patterns to include in the resolution, even if they are marked as external.
391
- */
392
- noExternal?: (string | RegExp)[];
393
- /**
394
- * An array of patterns to match when resolving modules.
395
- */
396
- skipNodeModulesBundle?: boolean;
397
- }
398
- interface VirtualFileSystemInterface {
399
- /**
400
- * The underlying file metadata.
401
- */
402
- metadata: Readonly<Record<string, VirtualFileMetadata>>;
403
- /**
404
- * A map of file paths to their module ids.
405
- */
406
- ids: Readonly<Record<string, string>>;
407
- /**
408
- * A map of module ids to their file paths.
409
- */
410
- paths: Readonly<Record<string, string>>;
411
- /**
412
- * Checks if a file exists in the virtual file system (VFS).
413
- *
414
- * @param path - The path or id of the file.
415
- * @returns `true` if the file exists, otherwise `false`.
416
- */
417
- exists: (path: string) => Promise<boolean>;
418
- /**
419
- * Synchronously Checks if a file exists in the virtual file system (VFS).
420
- *
421
- * @param path - The path or id of the file.
422
- * @returns `true` if the file exists, otherwise `false`.
423
- */
424
- existsSync: (path: string) => boolean;
425
- /**
426
- * Checks if a file is virtual in the virtual file system (VFS).
427
- *
428
- * @param path - The path or id of the file.
429
- * @returns `true` if the file is virtual, otherwise `false`.
430
- */
431
- isVirtual: (path: string) => boolean;
432
- /**
433
- * Checks if the given key is a directory.
434
- *
435
- * @param key - The key to check.
436
- * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
437
- */
438
- isDirectory: (key: string) => Promise<boolean>;
439
- /**
440
- * Synchronously checks if the given key is a directory.
441
- *
442
- * @param key - The key to check.
443
- * @returns `true` if the key is a directory, otherwise `false`.
444
- */
445
- isDirectorySync: (key: string) => boolean;
446
- /**
447
- * Checks if the given key is a file.
448
- *
449
- * @param key - The key to check.
450
- * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
451
- */
452
- isFile: (key: string) => Promise<boolean>;
453
- /**
454
- * Synchronously checks if the given key is a file.
455
- *
456
- * @param key - The key to check.
457
- * @returns `true` if the key is a file, otherwise `false`.
458
- */
459
- isFileSync: (key: string) => boolean;
460
- /**
461
- * Gets the metadata of a file in the virtual file system (VFS).
462
- *
463
- * @param path - The path or id of the file.
464
- * @returns The metadata of the file if it exists, otherwise undefined.
465
- */
466
- getMetadata: (path: string) => VirtualFileMetadata | undefined;
467
- /**
468
- * Lists files in a given path.
469
- *
470
- * @param path - The path to list files from.
471
- * @returns An array of file names in the specified path.
472
- */
473
- listSync: (path: string) => string[];
474
- /**
475
- * Lists files in a given path.
476
- *
477
- * @param path - The path to list files from.
478
- * @returns An array of file names in the specified path.
479
- */
480
- list: (path: string) => Promise<string[]>;
481
- /**
482
- * Removes a file or symbolic link in the virtual file system (VFS).
483
- *
484
- * @param path - The path to the file to remove.
485
- * @returns A promise that resolves when the file is removed.
486
- */
487
- removeSync: (path: string) => void;
488
- /**
489
- * Asynchronously removes a file or symbolic link in the virtual file system (VFS).
490
- *
491
- * @param path - The path to the file to remove.
492
- * @returns A promise that resolves when the file is removed.
493
- */
494
- remove: (path: string) => Promise<void>;
495
- /**
496
- * Reads a file from the virtual file system (VFS).
497
- *
498
- * @param path - The path or id of the file.
499
- * @returns The contents of the file if it exists, otherwise undefined.
500
- */
501
- read: (path: string) => Promise<string | undefined>;
502
- /**
503
- * Reads a file from the virtual file system (VFS).
504
- *
505
- * @param path - The path or id of the file.
506
- */
507
- readSync: (path: string) => string | undefined;
508
- /**
509
- * Writes a file to the virtual file system (VFS).
510
- *
511
- * @param path - The path to the file.
512
- * @param data - The contents of the file.
513
- * @param options - Options for writing the file.
514
- * @returns A promise that resolves when the file is written.
515
- */
516
- write: (path: string, data: string, options?: WriteOptions) => Promise<void>;
517
- /**
518
- * Writes a file to the virtual file system (VFS).
519
- *
520
- * @param path - The path to the file.
521
- * @param data - The contents of the file.
522
- * @param options - Options for writing the file.
523
- */
524
- writeSync: (path: string, data: string, options?: WriteOptions) => void;
525
- /**
526
- * Creates a directory at the specified path.
527
- *
528
- * @param dirPath - The path of the directory to create.
529
- */
530
- mkdir: (dirPath: string) => Promise<void>;
531
- /**
532
- * Synchronously creates a directory at the specified path.
533
- *
534
- * @param dirPath - The path of the directory to create.
535
- */
536
- mkdirSync: (dirPath: string) => void;
537
- /**
538
- * Moves a file from one path to another in the virtual file system (VFS).
539
- *
540
- * @param srcPath - The source path to move
541
- * @param destPath - The destination path to move to
542
- */
543
- move: (srcPath: string, destPath: string) => Promise<void>;
544
- /**
545
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
546
- *
547
- * @param srcPath - The source path to move
548
- * @param destPath - The destination path to move to
549
- */
550
- moveSync: (srcPath: string, destPath: string) => void;
551
- /**
552
- * Copies a file from one path to another in the virtual file system (VFS).
553
- *
554
- * @param srcPath - The source path to copy
555
- * @param destPath - The destination path to copy to
556
- */
557
- copy: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => Promise<void>;
558
- /**
559
- * Synchronously copies a file from one path to another in the virtual file system (VFS).
560
- *
561
- * @param srcPath - The source path to copy
562
- * @param destPath - The destination path to copy to
563
- */
564
- copySync: (srcPath: string | URL | Omit<AssetGlob, "output">, destPath: string | URL) => void;
565
- /**
566
- * Glob files in the virtual file system (VFS) based on the provided pattern(s).
567
- *
568
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
569
- * @returns An array of file paths matching the provided pattern(s)
570
- */
571
- glob: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => Promise<string[]>;
572
- /**
573
- * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
574
- *
575
- * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
576
- * @returns An array of file paths matching the provided pattern(s)
577
- */
578
- globSync: (patterns: string | Omit<AssetGlob, "output"> | (string | Omit<AssetGlob, "output">)[]) => string[];
579
- /**
580
- * A helper function to resolve modules using the Jiti resolver
581
- *
582
- * @remarks
583
- * This function can be used to resolve modules relative to the project root directory.
584
- *
585
- * @example
586
- * ```ts
587
- * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
588
- * ```
589
- *
590
- * @param id - The module to resolve.
591
- * @param importer - An optional path to the importer module.
592
- * @param options - Additional resolution options.
593
- * @returns A promise that resolves to the resolved module path.
594
- */
595
- resolve: (id: string, importer?: string, options?: ResolveOptions$1) => Promise<string | undefined>;
596
- /**
597
- * A synchronous helper function to resolve modules using the Jiti resolver
598
- *
599
- * @remarks
600
- * This function can be used to resolve modules relative to the project root directory.
601
- *
602
- * @example
603
- * ```ts
604
- * const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
605
- * ```
606
- *
607
- * @param id - The module to resolve.
608
- * @param importer - An optional path to the importer module.
609
- * @param options - Additional resolution options.
610
- * @returns The resolved module path.
611
- */
612
- resolveSync: (id: string, importer?: string, options?: ResolveOptions$1) => string | undefined;
613
- /**
614
- * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
615
- */
616
- dispose: () => Promise<void>;
617
- }
618
- //#endregion
619
- //#region ../powerlines/src/types/tsconfig.d.ts
620
- type ReflectionMode = "default" | "explicit" | "never";
621
- type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
622
- /**
623
- * Defines the level of reflection to be used during the transpilation process.
624
- *
625
- * @remarks
626
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
627
- * - `minimal` - Only the essential type information is captured.
628
- * - `normal` - Additional type information is captured, including some contextual data.
629
- * - `verbose` - All available type information is captured, including detailed contextual data.
630
- */
631
- type ReflectionLevel = "minimal" | "normal" | "verbose";
632
- interface DeepkitOptions {
633
- /**
634
- * Either true to activate reflection for all files compiled using this tsconfig,
635
- * or a list of globs/file paths relative to this tsconfig.json.
636
- * Globs/file paths can be prefixed with a ! to exclude them.
637
- */
638
- reflection?: RawReflectionMode;
639
- /**
640
- * Defines the level of reflection to be used during the transpilation process.
641
- *
642
- * @remarks
643
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
644
- * - `minimal` - Only the essential type information is captured.
645
- * - `normal` - Additional type information is captured, including some contextual data.
646
- * - `verbose` - All available type information is captured, including detailed contextual data.
647
- */
648
- reflectionLevel?: ReflectionLevel;
649
- }
650
- type TSCompilerOptions = CompilerOptions & DeepkitOptions;
651
- /**
652
- * The TypeScript compiler configuration.
653
- *
654
- * @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
655
- */
656
- interface TSConfig extends Omit<TsConfigJson, "reflection"> {
657
- /**
658
- * Either true to activate reflection for all files compiled using this tsconfig,
659
- * or a list of globs/file paths relative to this tsconfig.json.
660
- * Globs/file paths can be prefixed with a ! to exclude them.
661
- */
662
- reflection?: RawReflectionMode;
663
- /**
664
- * Defines the level of reflection to be used during the transpilation process.
665
- *
666
- * @remarks
667
- * The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
668
- * - `minimal` - Only the essential type information is captured.
669
- * - `normal` - Additional type information is captured, including some contextual data.
670
- * - `verbose` - All available type information is captured, including detailed contextual data.
671
- */
672
- reflectionLevel?: ReflectionLevel;
673
- /**
674
- * Instructs the TypeScript compiler how to compile `.ts` files.
675
- */
676
- compilerOptions?: TSCompilerOptions;
677
- }
678
- type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
679
- originalTsconfigJson: TsConfigJson;
680
- tsconfigJson: TSConfig;
681
- tsconfigFilePath: string;
682
- };
683
- //#endregion
684
- //#region ../powerlines/src/types/config.d.ts
685
- type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
686
- /**
687
- * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
688
- */
689
- type WorkspaceConfig = Partial<StormWorkspaceConfig> & Required<Pick<StormWorkspaceConfig, "workspaceRoot">>;
690
- type PluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<Plugin<TContext>>;
691
- /**
692
- * A configuration tuple for a Powerlines plugin.
693
- */
694
- type PluginConfigTuple<TContext extends PluginContext = PluginContext, TOptions = any> = [string | PluginFactory<TContext, TOptions>, TOptions] | [Plugin<TContext>];
695
- /**
696
- * A configuration object for a Powerlines plugin.
697
- */
698
- type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions = any> = {
699
- plugin: string | PluginFactory<TContext, TOptions>;
700
- options: TOptions;
701
- } | {
702
- plugin: Plugin<TContext>;
703
- options?: never;
704
- };
705
- /**
706
- * A configuration tuple for a Powerlines plugin.
707
- */
708
- type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Promise<Plugin<TContext>> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
709
- type ProjectType = "application" | "library";
710
- interface DeployConfig {
711
- /**
712
- * The deployment variant being used by the Powerlines engine.
713
- *
714
- * @example
715
- * ```ts
716
- * export default defineConfig({
717
- * deploy: {
718
- * variant: "cloudflare"
719
- * }
720
- * });
721
- *
722
- * ```
723
- */
724
- variant?: string;
725
- }
726
- interface OutputConfig {
727
- /**
728
- * The path to output the final compiled files to
729
- *
730
- * @remarks
731
- * If a value is not provided, Powerlines will attempt to:
732
- * 1. Use the `outDir` value in the `tsconfig.json` file.
733
- * 2. Use the `dist` directory in the project root directory.
734
- *
735
- * @defaultValue "dist/\{projectRoot\}"
736
- */
737
- outputPath?: string;
738
- /**
739
- * The output directory path for the project build.
740
- *
741
- * @remarks
742
- * This path is used to determine where the built files will be placed after the build process completes. This will be used in scenarios where the monorepo uses TSConfig paths to link packages together.
743
- *
744
- * @defaultValue "\{projectRoot\}/dist"
745
- */
746
- buildPath?: string;
747
- /**
748
- * The folder where the generated runtime artifacts will be located
749
- *
750
- * @remarks
751
- * This folder will contain all runtime artifacts and builtins generated during the "prepare" phase.
752
- *
753
- * @defaultValue "\{projectRoot\}/.powerlines"
754
- */
755
- artifactsPath?: string;
756
- /**
757
- * The path of the generated runtime declaration file relative to the workspace root.
758
- *
759
- * @defaultValue "\{projectRoot\}/powerlines.d.ts"
760
- */
761
- dts?: string | false;
762
- /**
763
- * A prefix to use for identifying builtin modules
764
- *
765
- * @remarks
766
- * This prefix will be used to identify all builtin modules generated during the "prepare" phase. An example builtin ID for a module called `"utils"` would be `"{builtinPrefix}:utils"`.
767
- *
768
- * @defaultValue "powerlines"
769
- */
770
- builtinPrefix?: string;
771
- /**
772
- * The module format of the output files
773
- *
774
- * @remarks
775
- * This option can be a single format or an array of formats. If an array is provided, multiple builds will be generated for each format.
776
- *
777
- * @defaultValue "esm"
778
- */
779
- format?: Format | Format[];
780
- /**
781
- * A list of assets to copy to the output directory
782
- *
783
- * @remarks
784
- * The assets can be specified as a string (path to the asset) or as an object with a `glob` property (to match multiple files). The paths are relative to the project root directory.
785
- */
786
- assets?: Array<string | AssetGlob>;
787
- /**
788
- * A string preset or a custom {@link StoragePort} to provide fine-grained control over generated/output file storage.
789
- *
790
- * @remarks
791
- * If a string preset is provided, it must be one of the following values:
792
- * - `"virtual"`: Uses the local file system for storage.
793
- * - `"fs"`: Uses an in-memory virtual file system for storage.
794
- *
795
- * If a custom {@link StoragePort} is provided, it will be used for all file storage operations during the build process.
796
- *
797
- * @defaultValue "virtual"
798
- */
799
- storage?: StoragePort | StoragePreset;
800
- }
801
- interface BaseConfig {
802
- /**
803
- * The entry point(s) for the application
804
- */
805
- entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
806
- /**
807
- * Configuration for the output of the build process
808
- */
809
- output?: OutputConfig;
810
- /**
811
- * Configuration for cleaning the build artifacts
812
- *
813
- * @remarks
814
- * If set to `false`, the cleaning process will be disabled.
815
- */
816
- clean?: Record<string, any> | false;
817
- /**
818
- * Configuration for linting the source code
819
- *
820
- * @remarks
821
- * If set to `false`, linting will be disabled.
822
- */
823
- lint?: Record<string, any> | false;
824
- /**
825
- * Configuration for testing the source code
826
- *
827
- * @remarks
828
- * If set to `false`, testing will be disabled.
829
- */
830
- test?: Record<string, any> | false;
831
- /**
832
- * Configuration for the transformation of the source code
833
- */
834
- transform?: Record<string, any>;
835
- /**
836
- * Configuration provided to build processes
837
- *
838
- * @remarks
839
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
840
- */
841
- build?: BuildConfig;
842
- /**
843
- * Configuration for documentation generation
844
- *
845
- * @remarks
846
- * This configuration will be used by the documentation generation plugins during the `docs` command.
847
- */
848
- docs?: Record<string, any>;
849
- /**
850
- * Configuration for deploying the source code
851
- *
852
- * @remarks
853
- * If set to `false`, the deployment will be disabled.
854
- */
855
- deploy?: DeployConfig | false;
856
- /**
857
- * The path to the tsconfig file to be used by the compiler
858
- *
859
- * @remarks
860
- * If a value is not provided, the plugin will attempt to find the `tsconfig.json` file in the project root directory. The parsed tsconfig compiler options will be merged with the {@link Options.tsconfigRaw} value (if provided).
861
- *
862
- * @defaultValue "\{projectRoot\}/tsconfig.json"
863
- */
864
- tsconfig?: string;
865
- /**
866
- * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
867
- *
868
- * @see https://www.typescriptlang.org/tsconfig
869
- *
870
- * @remarks
871
- * If populated, this option takes higher priority than `tsconfig`
872
- */
873
- tsconfigRaw?: TSConfig;
874
- }
875
- interface EnvironmentConfig extends BaseConfig {
876
- /**
877
- * Configuration options for the preview server
878
- */
879
- preview?: PreviewOptions;
880
- /**
881
- * A flag indicating whether the build is for a Server-Side Rendering environment.
882
- */
883
- ssr?: boolean;
884
- /**
885
- * Define if this environment is used for Server-Side Rendering
886
- *
887
- * @defaultValue "server" (if it isn't the client environment)
888
- */
889
- consumer?: "client" | "server";
890
- }
891
- interface CommonUserConfig extends BaseConfig {
892
- /**
893
- * The name of the project
894
- */
895
- name?: string;
896
- /**
897
- * The project display title
898
- *
899
- * @remarks
900
- * This option is used in documentation generation and other places where a human-readable title is needed.
901
- */
902
- title?: string;
903
- /**
904
- * A description of the project
905
- *
906
- * @remarks
907
- * If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
908
- */
909
- description?: string;
910
- /**
911
- * The log level to use for the Powerlines processes.
912
- *
913
- * @defaultValue "info"
914
- */
915
- logLevel?: LogLevelLabel | null;
916
- /**
917
- * A custom logger function to use for logging messages
918
- */
919
- customLogger?: LogFn;
920
- /**
921
- * Explicitly set a mode to run in. This mode will be used at various points throughout the Powerlines processes, such as when compiling the source code.
922
- *
923
- * @defaultValue "production"
924
- */
925
- mode?: "development" | "test" | "production";
926
- /**
927
- * The type of project being built
928
- *
929
- * @defaultValue "application"
930
- */
931
- type?: ProjectType;
932
- /**
933
- * The root directory of the project
934
- */
935
- root: string;
936
- /**
937
- * The root directory of the project's source code
938
- *
939
- * @defaultValue "\{root\}/src"
940
- */
941
- sourceRoot?: string;
942
- /**
943
- * A path to a custom configuration file to be used instead of the default `storm.json`, `powerlines.config.js`, or `powerlines.config.ts` files.
944
- *
945
- * @remarks
946
- * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
947
- */
948
- configFile?: string;
949
- /**
950
- * Should the Powerlines CLI processes skip installing missing packages?
951
- *
952
- * @remarks
953
- * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
954
- *
955
- * @defaultValue false
956
- */
957
- skipInstalls?: boolean;
958
- /**
959
- * Should the compiler processes skip any improvements that make use of cache?
960
- *
961
- * @defaultValue false
962
- */
963
- skipCache?: boolean;
964
- /**
965
- * A list of resolvable paths to plugins used during the build process
966
- */
967
- plugins?: PluginConfig<PluginContext<any>>[];
968
- /**
969
- * Environment-specific configurations
970
- */
971
- environments?: Record<string, EnvironmentConfig>;
972
- /**
973
- * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
974
- *
975
- * @remarks
976
- * If no values are provided for {@link OutputConfig.dts | output.dts}, {@link OutputConfig.builtinPrefix | output.builtinPrefix}, or {@link OutputConfig.artifactsPath | output.artifactsFolder}, this value will be used as the default.
977
- *
978
- * @defaultValue "powerlines"
979
- */
980
- framework?: string;
981
- }
982
- interface UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant$1 extends string = any> extends Omit<CommonUserConfig, "build"> {
983
- /**
984
- * Configuration provided to build processes
985
- *
986
- * @remarks
987
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
988
- */
989
- build: Omit<TBuildConfig, "override"> & {
990
- /**
991
- * The build variant being used by the Powerlines engine.
992
- */
993
- variant?: TBuildVariant$1;
994
- /**
995
- * An optional set of override options to apply to the selected build variant.
996
- *
997
- * @remarks
998
- * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
999
- */
1000
- override?: Partial<TBuildResolvedConfig>;
1001
- };
1002
- }
1003
- type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
1004
- type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
1005
- /**
1006
- * The configuration provided while executing Powerlines commands.
1007
- */
1008
- type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
1009
- /**
1010
- * A string identifier for the Powerlines command being executed
1011
- */
1012
- command: PowerlinesCommand;
1013
- };
1014
- //#endregion
1015
- //#region ../powerlines/src/types/resolved.d.ts
1016
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
1017
- /**
1018
- * The user provided entry point in the source code
1019
- */
1020
- input: TypeDefinition;
1021
- /**
1022
- * An optional name to use in the package export during the build process
1023
- */
1024
- output?: string;
1025
- }
1026
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "ssr">> & {
1027
- /**
1028
- * The name of the environment
1029
- */
1030
- name: string;
1031
- /**
1032
- * Configuration options for the preview server
1033
- */
1034
- preview?: ResolvedPreviewOptions;
1035
- };
1036
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
1037
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> & {
1038
- assets: ResolvedAssetGlob[];
1039
- }> & Pick<OutputConfig, "storage">;
1040
- /**
1041
- * The resolved options for the Powerlines project configuration.
1042
- */
1043
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
1044
- /**
1045
- * The configuration options that were provided inline to the Powerlines CLI.
1046
- */
1047
- inlineConfig: InlineConfig<TUserConfig>;
1048
- /**
1049
- * The original configuration options that were provided by the user to the Powerlines process.
1050
- */
1051
- userConfig: TUserConfig;
1052
- /**
1053
- * A string identifier for the Powerlines command being executed.
1054
- */
1055
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
1056
- /**
1057
- * The root directory of the project's source code
1058
- *
1059
- * @defaultValue "\{projectRoot\}/src"
1060
- */
1061
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
1062
- /**
1063
- * The root directory of the project.
1064
- */
1065
- projectRoot: NonUndefined<TUserConfig["root"]>;
1066
- /**
1067
- * The type of project being built.
1068
- */
1069
- projectType: NonUndefined<TUserConfig["type"]>;
1070
- /**
1071
- * The output configuration options to use for the build process
1072
- */
1073
- output: OutputResolvedConfig;
1074
- /**
1075
- * Configuration provided to build processes
1076
- *
1077
- * @remarks
1078
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1079
- */
1080
- build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
1081
- /**
1082
- * The log level to use for the Powerlines processes.
1083
- *
1084
- * @defaultValue "info"
1085
- */
1086
- logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
1087
- };
1088
- type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
1089
- //#endregion
1090
- //#region ../powerlines/src/types/context.d.ts
1091
- interface MetaInfo {
1092
- /**
1093
- * The checksum generated from the resolved options
1094
- */
1095
- checksum: string;
1096
- /**
1097
- * The build id
1098
- */
1099
- buildId: string;
1100
- /**
1101
- * The release id
1102
- */
1103
- releaseId: string;
1104
- /**
1105
- * The build timestamp
1106
- */
1107
- timestamp: number;
1108
- /**
1109
- * A hash that represents the path to the project root directory
1110
- */
1111
- projectRootHash: string;
1112
- /**
1113
- * A hash that represents the path to the project root directory
1114
- */
1115
- configHash: string;
1116
- }
1117
- interface Resolver extends Jiti {
1118
- plugin: Jiti;
1119
- }
1120
- interface TransformResult$1 {
1121
- code: string;
1122
- map: SourceMap | null;
1123
- }
1124
- interface InitContextOptions {
1125
- /**
1126
- * If false, the plugin will be loaded after all other plugins.
1127
- *
1128
- * @defaultValue true
1129
- */
1130
- isHighPriority: boolean;
1131
- }
1132
- interface FetchOptions extends FetchRequestOptions {
1133
- /**
1134
- * An indicator specifying that the request should bypass any caching
1135
- */
1136
- skipCache?: boolean;
1137
- }
1138
- interface ParseOptions extends ParserOptions {
1139
- /**
1140
- * When true this allows return statements to be outside functions to e.g. support parsing CommonJS code.
1141
- */
1142
- allowReturnOutsideFunction?: boolean;
1143
- }
1144
- /**
1145
- * The unresolved Powerlines context.
1146
- *
1147
- * @remarks
1148
- * This context is used before the user configuration has been fully resolved after the `config`.
1149
- */
1150
- interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1151
- /**
1152
- * The Storm workspace configuration
1153
- */
1154
- workspaceConfig: WorkspaceConfig;
1155
- /**
1156
- * An object containing the options provided to Powerlines
1157
- */
1158
- config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
1159
- projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
1160
- sourceRoot: NonUndefined<TResolvedConfig["userConfig"]["sourceRoot"]>;
1161
- output: TResolvedConfig["output"];
1162
- };
1163
- /**
1164
- * A logging function for the Powerlines engine
1165
- */
1166
- log: LogFn;
1167
- /**
1168
- * A logging function for fatal messages
1169
- */
1170
- fatal: (message: string | UnpluginMessage) => void;
1171
- /**
1172
- * A logging function for error messages
1173
- */
1174
- error: (message: string | UnpluginMessage) => void;
1175
- /**
1176
- * A logging function for warning messages
1177
- */
1178
- warn: (message: string | UnpluginMessage) => void;
1179
- /**
1180
- * A logging function for informational messages
1181
- */
1182
- info: (message: string | UnpluginMessage) => void;
1183
- /**
1184
- * A logging function for debug messages
1185
- */
1186
- debug: (message: string | UnpluginMessage) => void;
1187
- /**
1188
- * A logging function for trace messages
1189
- */
1190
- trace: (message: string | UnpluginMessage) => void;
1191
- /**
1192
- * The metadata information
1193
- */
1194
- meta: MetaInfo;
1195
- /**
1196
- * The metadata information currently written to disk
1197
- */
1198
- persistedMeta?: MetaInfo;
1199
- /**
1200
- * The Powerlines artifacts directory
1201
- */
1202
- artifactsPath: string;
1203
- /**
1204
- * The path to the Powerlines builtin runtime modules directory
1205
- */
1206
- builtinsPath: string;
1207
- /**
1208
- * The path to the Powerlines entry modules directory
1209
- */
1210
- entryPath: string;
1211
- /**
1212
- * The path to the Powerlines TypeScript declaration files directory
1213
- */
1214
- dtsPath: string;
1215
- /**
1216
- * The path to a directory where the reflection data buffers (used by the build processes) are stored
1217
- */
1218
- dataPath: string;
1219
- /**
1220
- * The path to a directory where the project cache (used by the build processes) is stored
1221
- */
1222
- cachePath: string;
1223
- /**
1224
- * The Powerlines environment paths
1225
- */
1226
- envPaths: EnvPaths;
1227
- /**
1228
- * The file system path to the Powerlines package installation
1229
- */
1230
- powerlinesPath: string;
1231
- /**
1232
- * The relative path to the Powerlines workspace root directory
1233
- */
1234
- relativeToWorkspaceRoot: string;
1235
- /**
1236
- * The project's `package.json` file content
1237
- */
1238
- packageJson: PackageJson & Record<string, any>;
1239
- /**
1240
- * The project's `project.json` file content
1241
- */
1242
- projectJson?: Record<string, any>;
1243
- /**
1244
- * The dependency installations required by the project
1245
- */
1246
- dependencies: Record<string, string | Range>;
1247
- /**
1248
- * The development dependency installations required by the project
1249
- */
1250
- devDependencies: Record<string, string | Range>;
1251
- /**
1252
- * The parsed TypeScript configuration from the `tsconfig.json` file
1253
- */
1254
- tsconfig: ParsedTypeScriptConfig;
1255
- /**
1256
- * The entry points of the source code
1257
- */
1258
- entry: ResolvedEntryTypeDefinition[];
1259
- /**
1260
- * The virtual file system manager used during the build process to reference generated runtime files
1261
- */
1262
- fs: VirtualFileSystemInterface;
1263
- /**
1264
- * The Jiti module resolver
1265
- */
1266
- resolver: Resolver;
1267
- /**
1268
- * The builtin module id that exist in the Powerlines virtual file system
1269
- */
1270
- builtins: string[];
1271
- /**
1272
- * The {@link Project} instance used for type reflection and module manipulation
1273
- *
1274
- * @see https://ts-morph.com/
1275
- *
1276
- * @remarks
1277
- * This instance is created lazily on first access.
1278
- */
1279
- program: Project;
1280
- /**
1281
- * A function to perform HTTP fetch requests
1282
- *
1283
- * @remarks
1284
- * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
1285
- *
1286
- * @example
1287
- * ```ts
1288
- * const response = await context.fetch("https://api.example.com/data");
1289
- * const data = await response.json();
1290
- * ```
1291
- *
1292
- * @see https://github.com/nodejs/undici
1293
- *
1294
- * @param input - The URL to fetch.
1295
- * @param options - The fetch request options.
1296
- * @returns A promise that resolves to a response returned by the fetch.
1297
- */
1298
- fetch: (input: RequestInfo, options?: FetchOptions) => Promise<Response>;
1299
- /**
1300
- * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
1301
- *
1302
- * @remarks
1303
- * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
1304
- *
1305
- * @example
1306
- * ```ts
1307
- * const ast = context.parse("const x: number = 42;");
1308
- * ```
1309
- *
1310
- * @see https://rollupjs.org/plugin-development/#this-parse
1311
- * @see https://github.com/oxc/oxc
1312
- *
1313
- * @param code - The source code to parse.
1314
- * @param options - The options to pass to the parser.
1315
- * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
1316
- */
1317
- parse: (code: string, options?: ParseOptions) => Promise<ParseResult>;
1318
- /**
1319
- * A helper function to resolve modules using the Jiti resolver
1320
- *
1321
- * @remarks
1322
- * This function can be used to resolve modules relative to the project root directory.
1323
- *
1324
- * @example
1325
- * ```ts
1326
- * const resolvedPath = await context.resolve("some-module", "/path/to/importer");
1327
- * ```
1328
- *
1329
- * @param id - The module to resolve.
1330
- * @param importer - An optional path to the importer module.
1331
- * @param options - Additional resolution options.
1332
- * @returns A promise that resolves to the resolved module path.
1333
- */
1334
- resolve: (id: string, importer?: string, options?: ResolveOptions$1) => Promise<ExternalIdResult | undefined>;
1335
- /**
1336
- * A helper function to load modules using the Jiti resolver
1337
- *
1338
- * @remarks
1339
- * This function can be used to load modules relative to the project root directory.
1340
- *
1341
- * @example
1342
- * ```ts
1343
- * const module = await context.load("some-module", "/path/to/importer");
1344
- * ```
1345
- *
1346
- * @param id - The module to load.
1347
- * @returns A promise that resolves to the loaded module.
1348
- */
1349
- load: (id: string) => Promise<TransformResult$1 | undefined>;
1350
- /**
1351
- * The Powerlines builtin virtual files
1352
- */
1353
- getBuiltins: () => Promise<VirtualFile[]>;
1354
- /**
1355
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1356
- *
1357
- * @param code - The source code of the builtin file
1358
- * @param id - The unique identifier of the builtin file
1359
- * @param path - An optional path to write the builtin file to
1360
- */
1361
- emitBuiltin: (code: string, id: string, path?: string) => Promise<void>;
1362
- /**
1363
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1364
- *
1365
- * @param code - The source code of the entry file
1366
- * @param path - An optional path to write the entry file to
1367
- */
1368
- emitEntry: (code: string, path: string) => Promise<void>;
1369
- /**
1370
- * A function to update the context fields using a new user configuration options
1371
- */
1372
- withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
1373
- /**
1374
- * A function to update the context fields using inline configuration options
1375
- */
1376
- withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
1377
- /**
1378
- * Create a new logger instance
1379
- *
1380
- * @param name - The name to use for the logger instance
1381
- * @returns A logger function
1382
- */
1383
- createLog: (name: string | null) => LogFn;
1384
- /**
1385
- * Extend the current logger instance with a new name
1386
- *
1387
- * @param name - The name to use for the extended logger instance
1388
- * @returns A logger function
1389
- */
1390
- extendLog: (name: string) => LogFn;
1391
- /**
1392
- * Generates a checksum representing the current context state
1393
- *
1394
- * @returns A promise that resolves to a string representing the checksum
1395
- */
1396
- generateChecksum: () => Promise<string>;
1397
- }
1398
- type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
1399
- /**
1400
- * The fully resolved Powerlines configuration
1401
- */
1402
- config: TResolvedConfig;
1403
- };
1404
- interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1405
- /**
1406
- * The environment specific resolved configuration
1407
- */
1408
- environment: EnvironmentResolvedConfig;
1409
- /**
1410
- * An alternative property name for the {@link log} property
1411
- *
1412
- * @remarks
1413
- * This is provided for compatibility with other logging libraries that expect a `logger` property.
1414
- */
1415
- logger: LogFn;
1416
- }
1417
- type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
1418
- //#endregion
1419
- //#region ../powerlines/src/types/commands.d.ts
1420
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
1421
- type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
1422
- //#endregion
1423
- //#region ../powerlines/src/types/plugin.d.ts
1424
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
1425
- /**
1426
- * The order in which the plugin should be applied.
1427
- */
1428
- order?: "pre" | "post" | null | undefined;
1429
- /**
1430
- * A filter to determine when the hook should be called.
1431
- */
1432
- filter?: Pick<HookFilter, TFilter>;
1433
- /**
1434
- * The hook function to be called.
1435
- */
1436
- handler: THookFunction;
1437
- }
1438
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
1439
- /**
1440
- * A result returned by the plugin from the `types` hook that describes the declaration types output file.
1441
- */
1442
- interface TypesResult {
1443
- directives?: string[];
1444
- code: string;
1445
- }
1446
- type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
1447
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
1448
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
1449
- /**
1450
- * A function that returns configuration options to be merged with the build context's options.
1451
- *
1452
- * @remarks
1453
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
1454
- *
1455
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
1456
- *
1457
- * @see https://vitejs.dev/guide/api-plugin#config
1458
- *
1459
- * @param this - The build context.
1460
- * @param config - The partial configuration object to be modified.
1461
- * @returns A promise that resolves to a partial configuration object.
1462
- */
1463
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
1464
- /**
1465
- * Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config.
1466
- *
1467
- * @remarks
1468
- * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
1469
- *
1470
- * @see https://vitejs.dev/guide/api-plugin#configenvironment
1471
- *
1472
- * @param this - The build context.
1473
- * @param name - The name of the environment being configured.
1474
- * @param environment - The Vite-like environment object containing information about the current build environment.
1475
- * @returns A promise that resolves when the hook is complete.
1476
- */
1477
- configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
1478
- /**
1479
- * A hook that is called when the plugin is resolved.
1480
- *
1481
- * @see https://vitejs.dev/guide/api-plugin#configresolved
1482
- *
1483
- * @param this - The build context.
1484
- * @returns A promise that resolves when the hook is complete.
1485
- */
1486
- configResolved: (this: TContext) => MaybePromise<void>;
1487
- /**
1488
- * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
1489
- *
1490
- * @param this - The build context.
1491
- * @param code - The source code to generate types for.
1492
- * @returns A promise that resolves when the hook is complete.
1493
- */
1494
- types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
1495
- /**
1496
- * A hook that is called at the start of the build process.
1497
- *
1498
- * @param this - The build context and unplugin build context.
1499
- * @returns A promise that resolves when the hook is complete.
1500
- */
1501
- buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
1502
- /**
1503
- * A hook that is called at the end of the build process.
1504
- *
1505
- * @param this - The build context and unplugin build context.
1506
- * @returns A promise that resolves when the hook is complete.
1507
- */
1508
- buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
1509
- /**
1510
- * A hook that is called to transform the source code.
1511
- *
1512
- * @param this - The build context, unplugin build context, and unplugin context.
1513
- * @param code - The source code to transform.
1514
- * @param id - The identifier of the source code.
1515
- * @returns A promise that resolves when the hook is complete.
1516
- */
1517
- transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
1518
- /**
1519
- * A hook that is called to load the source code.
1520
- *
1521
- * @param this - The build context, unplugin build context, and unplugin context.
1522
- * @param id - The identifier of the source code.
1523
- * @returns A promise that resolves when the hook is complete.
1524
- */
1525
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
1526
- /**
1527
- * A hook that is called to resolve the identifier of the source code.
1528
- *
1529
- * @param this - The build context, unplugin build context, and unplugin context.
1530
- * @param id - The identifier of the source code.
1531
- * @param importer - The importer of the source code.
1532
- * @param options - The options for resolving the identifier.
1533
- * @returns A promise that resolves when the hook is complete.
1534
- */
1535
- resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
1536
- isEntry: boolean;
1537
- }) => MaybePromise<string | ExternalIdResult | null | undefined>;
1538
- /**
1539
- * A hook that is called to write the bundle to disk.
1540
- *
1541
- * @param this - The build context.
1542
- * @returns A promise that resolves when the hook is complete.
1543
- */
1544
- writeBundle: (this: TContext) => MaybePromise<void>;
1545
- }
1546
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant$1] = Required<UnpluginOptions>[TBuildVariant$1]> = { [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey] };
1547
- type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
1548
- /**
1549
- * A function that returns configuration options to be merged with the build context's options.
1550
- *
1551
- * @remarks
1552
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
1553
- *
1554
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
1555
- *
1556
- * @see https://vitejs.dev/guide/api-plugin#config
1557
- *
1558
- * @param this - The build context.
1559
- * @param config - The partial configuration object to be modified.
1560
- * @returns A promise that resolves to a partial configuration object.
1561
- */
1562
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
1563
- /**
1564
- * A hook that is called to transform the source code.
1565
- *
1566
- * @param this - The build context, unplugin build context, and unplugin context.
1567
- * @param code - The source code to transform.
1568
- * @param id - The identifier of the source code.
1569
- * @returns A promise that resolves when the hook is complete.
1570
- */
1571
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
1572
- /**
1573
- * A hook that is called to load the source code.
1574
- *
1575
- * @param this - The build context, unplugin build context, and unplugin context.
1576
- * @param id - The identifier of the source code.
1577
- * @returns A promise that resolves when the hook is complete.
1578
- */
1579
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
1580
- /**
1581
- * A hook that is called to resolve the identifier of the source code.
1582
- *
1583
- * @param this - The build context, unplugin build context, and unplugin context.
1584
- * @param id - The identifier of the source code.
1585
- * @param importer - The importer of the source code.
1586
- * @param options - The options for resolving the identifier.
1587
- * @returns A promise that resolves when the hook is complete.
1588
- */
1589
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
1590
- isEntry: boolean;
1591
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
1592
- };
1593
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
1594
- interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
1595
- /**
1596
- * The name of the plugin, for use in deduplication, error messages and logs.
1597
- */
1598
- name: string;
1599
- /**
1600
- * An API object that can be used for inter-plugin communication.
1601
- *
1602
- * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
1603
- */
1604
- api?: Record<string, any>;
1605
- /**
1606
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
1607
- *
1608
- * @remarks
1609
- * The Plugin invocation order is as follows:
1610
- * - `enforce: 'pre'` plugins
1611
- * - `order: 'pre'` plugin hooks
1612
- * - any other plugins (normal)
1613
- * - `order: 'post'` plugin hooks
1614
- * - `enforce: 'post'` plugins
1615
- *
1616
- * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
1617
- * @see https://rollupjs.org/plugin-development/#build-hooks
1618
- * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
1619
- * @see https://esbuild.github.io/plugins/#concepts
1620
- */
1621
- enforce?: "pre" | "post";
1622
- /**
1623
- * A function to determine if two plugins are the same and can be de-duplicated.
1624
- *
1625
- * @remarks
1626
- * If this is not provided, plugins are de-duplicated by comparing their names.
1627
- *
1628
- * @param other - The other plugin to compare against.
1629
- * @returns `true` if the two plugins are the same, `false` otherwise.
1630
- */
1631
- dedupe?: false | ((other: Plugin<any>) => boolean);
1632
- /**
1633
- * A list of pre-requisite plugins that must be loaded before this plugin can be used.
1634
- */
1635
- dependsOn?: PluginConfig<any>[];
1636
- /**
1637
- * Define environments where this plugin should be active. By default, the plugin is active in all environments.
1638
- *
1639
- * @param environment - The environment to check.
1640
- * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
1641
- */
1642
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<any>;
1643
- }
1644
- //#endregion
1645
- //#region src/types/plugin.d.ts
1646
- type UnbuildPluginOptions = Partial<UnbuildBuildConfig>;
1647
- type UnbuildPluginResolvedConfig = UnbuildResolvedConfig;
1648
- type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
1649
- declare type __ΩUnbuildPluginOptions = any[];
1650
- declare type __ΩUnbuildPluginResolvedConfig = any[];
1651
- declare type __ΩUnbuildPluginContext = any[];
1652
- //#endregion
1653
- export { __ΩUnbuildPluginOptions as a, __ΩUnbuildPluginContext as i, UnbuildPluginOptions as n, __ΩUnbuildPluginResolvedConfig as o, UnbuildPluginResolvedConfig as r, Plugin as s, UnbuildPluginContext as t };