@powerlines/plugin-rollup 0.7.55 → 0.7.57

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