@powerlines/plugin-webpack 0.5.131 → 0.5.133

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