@powerlines/plugin-tsup 0.12.18 → 0.12.21

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.
@@ -1,6 +1,6 @@
1
1
  export { createTsupPlugin } from './unplugin.cjs';
2
2
  import 'esbuild';
3
- import '../index-C_qoO2U3.cjs';
3
+ import '../index-xv9Aw-0p.cjs';
4
4
  import '@storm-software/tsup/types';
5
5
  import '@storm-software/build-tools/types';
6
6
  import '@storm-software/config-tools/types';
@@ -18,7 +18,5 @@ import 'unplugin';
18
18
  import '@stryke/types/tsconfig';
19
19
  import 'typescript';
20
20
  import '@stryke/json/types';
21
- import 'memfs';
22
21
  import 'node:fs';
23
- import 'unionfs';
24
22
  import '@stryke/types/array';
@@ -1,6 +1,6 @@
1
1
  export { createTsupPlugin } from './unplugin.js';
2
2
  import 'esbuild';
3
- import '../index-C_qoO2U3.js';
3
+ import '../index-xv9Aw-0p.js';
4
4
  import '@storm-software/tsup/types';
5
5
  import '@storm-software/build-tools/types';
6
6
  import '@storm-software/config-tools/types';
@@ -18,7 +18,5 @@ import 'unplugin';
18
18
  import '@stryke/types/tsconfig';
19
19
  import 'typescript';
20
20
  import '@stryke/json/types';
21
- import 'memfs';
22
21
  import 'node:fs';
23
- import 'unionfs';
24
22
  import '@stryke/types/array';
@@ -1,5 +1,5 @@
1
1
  import * as esbuild from 'esbuild';
2
- import { T as TsupPluginContext } from '../index-C_qoO2U3.cjs';
2
+ import { T as TsupPluginContext } from '../index-xv9Aw-0p.cjs';
3
3
  import '@storm-software/tsup/types';
4
4
  import '@storm-software/build-tools/types';
5
5
  import '@storm-software/config-tools/types';
@@ -17,9 +17,7 @@ import 'unplugin';
17
17
  import '@stryke/types/tsconfig';
18
18
  import 'typescript';
19
19
  import '@stryke/json/types';
20
- import 'memfs';
21
20
  import 'node:fs';
22
- import 'unionfs';
23
21
  import '@stryke/types/array';
24
22
 
25
23
  declare function createTsupPlugin(context: TsupPluginContext): esbuild.Plugin;
@@ -1,5 +1,5 @@
1
1
  import * as esbuild from 'esbuild';
2
- import { T as TsupPluginContext } from '../index-C_qoO2U3.js';
2
+ import { T as TsupPluginContext } from '../index-xv9Aw-0p.js';
3
3
  import '@storm-software/tsup/types';
4
4
  import '@storm-software/build-tools/types';
5
5
  import '@storm-software/config-tools/types';
@@ -17,9 +17,7 @@ import 'unplugin';
17
17
  import '@stryke/types/tsconfig';
18
18
  import 'typescript';
19
19
  import '@stryke/json/types';
20
- import 'memfs';
21
20
  import 'node:fs';
22
- import 'unionfs';
23
21
  import '@stryke/types/array';
24
22
 
25
23
  declare function createTsupPlugin(context: TsupPluginContext): esbuild.Plugin;
@@ -15,9 +15,7 @@ import { UnpluginMessage, UnpluginContext, UnpluginBuildContext, TransformResult
15
15
  import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
16
16
  import ts from 'typescript';
17
17
  import { PrimitiveJsonValue } from '@stryke/json/types';
18
- import { Volume } from 'memfs';
19
18
  import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
20
- import { IUnionFs } from 'unionfs';
21
19
  import { ArrayValues } from '@stryke/types/array';
22
20
 
23
21
  type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
@@ -28,6 +26,87 @@ interface BuildConfig {
28
26
  * @defaultValue "neutral"
29
27
  */
30
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[]>;
31
110
  /**
32
111
  * The alias mappings to use for module resolution during the build process.
33
112
  *
@@ -43,8 +122,13 @@ interface BuildConfig {
43
122
  * }
44
123
  * }
45
124
  * ```
125
+ *
126
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
46
127
  */
47
- alias?: Record<string, string>;
128
+ alias?: Record<string, string> | Array<{
129
+ find: string | RegExp;
130
+ replacement: string;
131
+ }>;
48
132
  /**
49
133
  * A list of modules that should not be bundled, even if they are external dependencies.
50
134
  *
@@ -61,13 +145,14 @@ interface BuildConfig {
61
145
  */
62
146
  skipNodeModulesBundle?: boolean;
63
147
  /**
64
- * Should the Powerlines processes skip the `"prepare"` task prior to building?
148
+ * An optional set of override options to apply to the selected build variant.
65
149
  *
66
- * @defaultValue false
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.
67
152
  */
68
- skipPrepare?: boolean;
153
+ override?: Record<string, any>;
69
154
  }
70
- type BuildResolvedConfig = BuildConfig;
155
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
71
156
  type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
72
157
  type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
73
158
 
@@ -135,11 +220,8 @@ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
135
220
  tsconfigFilePath: string;
136
221
  };
137
222
 
138
- declare const __VFS_INIT__ = "__VFS_INIT__";
139
- declare const __VFS_REVERT__ = "__VFS_REVERT__";
140
- declare const __VFS_CACHE__ = "__VFS_CACHE__";
141
- declare const __VFS_VIRTUAL__ = "__VFS_VIRTUAL__";
142
- declare const __VFS_UNIFIED__ = "__VFS_UNIFIED__";
223
+ declare const __VFS_PATCH__: unique symbol;
224
+ declare const __VFS_REVERT__: unique symbol;
143
225
  type OutputModeType = "fs" | "virtual";
144
226
  interface VirtualFile {
145
227
  /**
@@ -179,7 +261,24 @@ interface VirtualFile {
179
261
  */
180
262
  code: string | NodeJS.ArrayBufferView;
181
263
  }
182
- type VirtualFileSystemMetadata = Pick<VirtualFile, "id" | "details" | "variant" | "mode">;
264
+ interface VirtualFileMetadata {
265
+ /**
266
+ * The identifier for the file data.
267
+ */
268
+ id: string;
269
+ /**
270
+ * The variant of the file.
271
+ */
272
+ variant: string;
273
+ /**
274
+ * The output mode of the file.
275
+ */
276
+ mode: string;
277
+ /**
278
+ * Additional metadata associated with the file.
279
+ */
280
+ properties: Record<string, string>;
281
+ }
183
282
  interface ResolveFSOptions {
184
283
  mode?: OutputModeType;
185
284
  }
@@ -208,12 +307,18 @@ interface ResolvePathOptions extends ResolveFSOptions {
208
307
  type?: "file" | "directory";
209
308
  }
210
309
  interface VirtualFileSystemInterface {
211
- [__VFS_INIT__]: () => void;
310
+ /**
311
+ * Patches the File System to include the virtual file system (VFS) contents.
312
+ */
313
+ [__VFS_PATCH__]: () => void;
314
+ /**
315
+ * Reverts the virtual file system (VFS) to its previous state.
316
+ */
212
317
  [__VFS_REVERT__]: () => void;
213
318
  /**
214
319
  * The underlying file metadata.
215
320
  */
216
- meta: Record<string, VirtualFileSystemMetadata | undefined>;
321
+ metadata: Record<string, VirtualFileMetadata | undefined>;
217
322
  /**
218
323
  * A map of module ids to their file paths.
219
324
  */
@@ -233,7 +338,7 @@ interface VirtualFileSystemInterface {
233
338
  * @param options - Optional parameters for resolving the path.
234
339
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
235
340
  */
236
- isFs: (pathOrId: string, options?: ResolvePathOptions) => boolean;
341
+ isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
237
342
  /**
238
343
  * Checks if a file exists in the virtual file system (VFS).
239
344
  *
@@ -248,15 +353,6 @@ interface VirtualFileSystemInterface {
248
353
  * @returns `true` if the directory exists, otherwise `false`.
249
354
  */
250
355
  isDirectory: (path: string) => boolean;
251
- /**
252
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
253
- *
254
- * @see https://www.typescriptlang.org/tsconfig#paths
255
- *
256
- * @param pathOrId - The path or id to check.
257
- * @returns Whether the path or id corresponds to a virtual file.
258
- */
259
- isTsconfigPath: (pathOrId: string) => boolean;
260
356
  /**
261
357
  * Checks if a file exists in the virtual file system (VFS).
262
358
  *
@@ -270,7 +366,7 @@ interface VirtualFileSystemInterface {
270
366
  * @param pathOrId - The path or id of the file.
271
367
  * @returns The metadata of the file if it exists, otherwise undefined.
272
368
  */
273
- getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;
369
+ getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
274
370
  /**
275
371
  * Gets the stats of a file in the virtual file system (VFS).
276
372
  *
@@ -478,23 +574,12 @@ interface VirtualFileSystemInterface {
478
574
  */
479
575
  resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
480
576
  /**
481
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
482
- *
483
- * @see https://www.typescriptlang.org/tsconfig#paths
484
- *
485
- * @param path - The path to check.
486
- * @returns The resolved file path if it exists, otherwise undefined.
487
- */
488
- resolveTsconfigPath: (path: string) => string | false;
489
- /**
490
- * Resolves a package name based on TypeScript's `tsconfig.json` paths.
491
- *
492
- * @see https://www.typescriptlang.org/tsconfig#paths
577
+ * Formats a path to match the virtual file system (VFS) structure.
493
578
  *
494
- * @param path - The path to check.
495
- * @returns The resolved package name if it exists, otherwise undefined.
579
+ * @param path - The path to format.
580
+ * @returns The formatted path.
496
581
  */
497
- resolveTsconfigPathPackage: (path: string) => string | false;
582
+ formatPath: (path: string) => string;
498
583
  /**
499
584
  * Resolves a path or id to a file path in the virtual file system.
500
585
  *
@@ -503,23 +588,9 @@ interface VirtualFileSystemInterface {
503
588
  */
504
589
  realpathSync: (pathOrId: string) => string;
505
590
  /**
506
- * Retrieves a partial metadata mapping of all files in the virtual file system (VFS).
507
- *
508
- * @returns A record mapping file paths to their partial metadata.
509
- */
510
- getPartialMeta: () => Record<string, Partial<VirtualFileSystemMetadata>>;
511
- /**
512
- * A map of cached file paths to their underlying file content.
513
- */
514
- [__VFS_CACHE__]: Map<string, string>;
515
- /**
516
- * A reference to the underlying virtual file system.
591
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
517
592
  */
518
- [__VFS_VIRTUAL__]: Volume;
519
- /**
520
- * A reference to the underlying unified file system.
521
- */
522
- [__VFS_UNIFIED__]: IUnionFs;
593
+ dispose: () => Promise<void>;
523
594
  }
524
595
 
525
596
  type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
@@ -645,24 +716,33 @@ interface BaseConfig {
645
716
  * The entry point(s) for the application
646
717
  */
647
718
  entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
719
+ /**
720
+ * Configuration for the output of the build process
721
+ */
722
+ output?: OutputConfig;
648
723
  /**
649
724
  * Configuration for linting the source code
725
+ *
726
+ * @remarks
727
+ * If set to `false`, linting will be disabled.
650
728
  */
651
729
  lint?: Record<string, any> | false;
652
730
  /**
653
731
  * Configuration for testing the source code
732
+ *
733
+ * @remarks
734
+ * If set to `false`, testing will be disabled.
654
735
  */
655
736
  test?: Record<string, any> | false;
656
- /**
657
- * Configuration for the output of the build process
658
- */
659
- output?: OutputConfig;
660
737
  /**
661
738
  * Configuration for the transformation of the source code
662
739
  */
663
740
  transform?: Record<string, any>;
664
741
  /**
665
- * Options to to provide to the build process
742
+ * Configuration provided to build processes
743
+ *
744
+ * @remarks
745
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
666
746
  */
667
747
  build?: BuildConfig;
668
748
  /**
@@ -672,6 +752,13 @@ interface BaseConfig {
672
752
  * This configuration will be used by the documentation generation plugins during the `docs` command.
673
753
  */
674
754
  docs?: Record<string, any>;
755
+ /**
756
+ * Configuration for deploying the source code
757
+ *
758
+ * @remarks
759
+ * If set to `false`, the deployment will be disabled.
760
+ */
761
+ deploy?: Record<string, any> | false;
675
762
  /**
676
763
  * The path to the tsconfig file to be used by the compiler
677
764
  *
@@ -692,37 +779,6 @@ interface BaseConfig {
692
779
  tsconfigRaw?: TSConfig;
693
780
  }
694
781
  interface EnvironmentConfig extends BaseConfig {
695
- /**
696
- * 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.
697
- *
698
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
699
- */
700
- mainFields?: string[];
701
- /**
702
- * Array of strings indicating what conditions should be used for module resolution.
703
- */
704
- conditions?: string[];
705
- /**
706
- * Array of strings indicating what conditions should be used for external modules.
707
- */
708
- externalConditions?: string[];
709
- /**
710
- * Array of strings indicating what file extensions should be used for module resolution.
711
- *
712
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
713
- */
714
- extensions?: string[];
715
- /**
716
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
717
- *
718
- * @remarks
719
- * 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.
720
- */
721
- dedupe?: string[];
722
- /**
723
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
724
- */
725
- builtins?: (string | RegExp)[];
726
782
  /**
727
783
  * Configuration options for the preview server
728
784
  */
@@ -795,17 +851,29 @@ interface CommonUserConfig extends BaseConfig {
795
851
  */
796
852
  framework?: string;
797
853
  }
798
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
799
- build?: TBuildConfig & {
854
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = Omit<CommonUserConfig, "build"> & {
855
+ /**
856
+ * Configuration provided to build processes
857
+ *
858
+ * @remarks
859
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
860
+ */
861
+ build: Omit<TBuildConfig, "override"> & {
800
862
  /**
801
863
  * The build variant being used by the Powerlines engine.
802
864
  */
803
865
  variant?: TBuildVariant;
866
+ /**
867
+ * An optional set of override options to apply to the selected build variant.
868
+ *
869
+ * @remarks
870
+ * 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.
871
+ */
872
+ override?: Partial<TBuildResolvedConfig>;
804
873
  };
805
- override?: Partial<TBuildResolvedConfig>;
806
874
  };
807
875
  type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
808
- type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
876
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
809
877
  /**
810
878
  * The configuration provided while executing Powerlines commands.
811
879
  */
@@ -826,7 +894,7 @@ interface ResolvedEntryTypeDefinition extends TypeDefinition {
826
894
  */
827
895
  output?: string;
828
896
  }
829
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
897
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
830
898
  /**
831
899
  * The name of the environment
832
900
  */
@@ -843,7 +911,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
843
911
  /**
844
912
  * The resolved options for the Powerlines project configuration.
845
913
  */
846
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "root" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "framework">> & {
914
+ 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">> & {
847
915
  /**
848
916
  * The configuration options that were provided inline to the Powerlines CLI.
849
917
  */
@@ -874,6 +942,13 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
874
942
  * The output configuration options to use for the build process
875
943
  */
876
944
  output: OutputResolvedConfig;
945
+ /**
946
+ * Configuration provided to build processes
947
+ *
948
+ * @remarks
949
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
950
+ */
951
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
877
952
  /**
878
953
  * The log level to use for the Powerlines processes.
879
954
  *
@@ -908,14 +983,6 @@ interface MetaInfo {
908
983
  * A hash that represents the path to the project root directory
909
984
  */
910
985
  configHash: string;
911
- /**
912
- * A mapping of runtime ids to their corresponding file paths
913
- */
914
- builtinIdMap: Record<string, string>;
915
- /**
916
- * A mapping of virtual file paths to their corresponding file contents
917
- */
918
- virtualFiles: Record<string, string | null>;
919
986
  }
920
987
  interface Resolver extends Jiti {
921
988
  plugin: Jiti;
@@ -928,7 +995,13 @@ interface InitContextOptions {
928
995
  */
929
996
  isHighPriority: boolean;
930
997
  }
931
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
998
+ /**
999
+ * The unresolved Powerlines context.
1000
+ *
1001
+ * @remarks
1002
+ * This context is used before the user configuration has been fully resolved after the `config`.
1003
+ */
1004
+ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
932
1005
  /**
933
1006
  * The Storm workspace configuration
934
1007
  */
@@ -936,7 +1009,10 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
936
1009
  /**
937
1010
  * An object containing the options provided to Powerlines
938
1011
  */
939
- config: TResolvedConfig;
1012
+ config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
1013
+ projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
1014
+ output: TResolvedConfig["output"];
1015
+ };
940
1016
  /**
941
1017
  * A logging function for the Powerlines engine
942
1018
  */
@@ -1093,6 +1169,12 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1093
1169
  */
1094
1170
  extendLog: (name: string) => LogFn;
1095
1171
  }
1172
+ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
1173
+ /**
1174
+ * The fully resolved Powerlines configuration
1175
+ */
1176
+ config: TResolvedConfig;
1177
+ };
1096
1178
  interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1097
1179
  /**
1098
1180
  * The environment specific resolved configuration
@@ -1108,7 +1190,7 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
1108
1190
  }
1109
1191
  type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1110
1192
 
1111
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "release", "finalize"];
1193
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
1112
1194
  type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
1113
1195
 
1114
1196
  interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
@@ -1133,6 +1215,10 @@ interface GenerateTypesResult {
1133
1215
  directives?: string[];
1134
1216
  code: string;
1135
1217
  }
1218
+ type DeepPartial<T> = {
1219
+ [K in keyof T]?: DeepPartial<T[K]>;
1220
+ };
1221
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
1136
1222
  interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
1137
1223
  /**
1138
1224
  * A function that returns configuration options to be merged with the build context's options.
@@ -1148,7 +1234,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
1148
1234
  * @param config - The partial configuration object to be modified.
1149
1235
  * @returns A promise that resolves to a partial configuration object.
1150
1236
  */
1151
- config: (this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>;
1237
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
1152
1238
  /**
1153
1239
  * 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.
1154
1240
  *
@@ -1251,7 +1337,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
1251
1337
  * @param config - The partial configuration object to be modified.
1252
1338
  * @returns A promise that resolves to a partial configuration object.
1253
1339
  */
1254
- config: PluginHook<(this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>> | Partial<TContext["config"]["userConfig"]>;
1340
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
1255
1341
  /**
1256
1342
  * A hook that is called to transform the source code.
1257
1343
  *
@@ -15,9 +15,7 @@ import { UnpluginMessage, UnpluginContext, UnpluginBuildContext, TransformResult
15
15
  import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
16
16
  import ts from 'typescript';
17
17
  import { PrimitiveJsonValue } from '@stryke/json/types';
18
- import { Volume } from 'memfs';
19
18
  import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
20
- import { IUnionFs } from 'unionfs';
21
19
  import { ArrayValues } from '@stryke/types/array';
22
20
 
23
21
  type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
@@ -28,6 +26,87 @@ interface BuildConfig {
28
26
  * @defaultValue "neutral"
29
27
  */
30
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[]>;
31
110
  /**
32
111
  * The alias mappings to use for module resolution during the build process.
33
112
  *
@@ -43,8 +122,13 @@ interface BuildConfig {
43
122
  * }
44
123
  * }
45
124
  * ```
125
+ *
126
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
46
127
  */
47
- alias?: Record<string, string>;
128
+ alias?: Record<string, string> | Array<{
129
+ find: string | RegExp;
130
+ replacement: string;
131
+ }>;
48
132
  /**
49
133
  * A list of modules that should not be bundled, even if they are external dependencies.
50
134
  *
@@ -61,13 +145,14 @@ interface BuildConfig {
61
145
  */
62
146
  skipNodeModulesBundle?: boolean;
63
147
  /**
64
- * Should the Powerlines processes skip the `"prepare"` task prior to building?
148
+ * An optional set of override options to apply to the selected build variant.
65
149
  *
66
- * @defaultValue false
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.
67
152
  */
68
- skipPrepare?: boolean;
153
+ override?: Record<string, any>;
69
154
  }
70
- type BuildResolvedConfig = BuildConfig;
155
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
71
156
  type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
72
157
  type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
73
158
 
@@ -135,11 +220,8 @@ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
135
220
  tsconfigFilePath: string;
136
221
  };
137
222
 
138
- declare const __VFS_INIT__ = "__VFS_INIT__";
139
- declare const __VFS_REVERT__ = "__VFS_REVERT__";
140
- declare const __VFS_CACHE__ = "__VFS_CACHE__";
141
- declare const __VFS_VIRTUAL__ = "__VFS_VIRTUAL__";
142
- declare const __VFS_UNIFIED__ = "__VFS_UNIFIED__";
223
+ declare const __VFS_PATCH__: unique symbol;
224
+ declare const __VFS_REVERT__: unique symbol;
143
225
  type OutputModeType = "fs" | "virtual";
144
226
  interface VirtualFile {
145
227
  /**
@@ -179,7 +261,24 @@ interface VirtualFile {
179
261
  */
180
262
  code: string | NodeJS.ArrayBufferView;
181
263
  }
182
- type VirtualFileSystemMetadata = Pick<VirtualFile, "id" | "details" | "variant" | "mode">;
264
+ interface VirtualFileMetadata {
265
+ /**
266
+ * The identifier for the file data.
267
+ */
268
+ id: string;
269
+ /**
270
+ * The variant of the file.
271
+ */
272
+ variant: string;
273
+ /**
274
+ * The output mode of the file.
275
+ */
276
+ mode: string;
277
+ /**
278
+ * Additional metadata associated with the file.
279
+ */
280
+ properties: Record<string, string>;
281
+ }
183
282
  interface ResolveFSOptions {
184
283
  mode?: OutputModeType;
185
284
  }
@@ -208,12 +307,18 @@ interface ResolvePathOptions extends ResolveFSOptions {
208
307
  type?: "file" | "directory";
209
308
  }
210
309
  interface VirtualFileSystemInterface {
211
- [__VFS_INIT__]: () => void;
310
+ /**
311
+ * Patches the File System to include the virtual file system (VFS) contents.
312
+ */
313
+ [__VFS_PATCH__]: () => void;
314
+ /**
315
+ * Reverts the virtual file system (VFS) to its previous state.
316
+ */
212
317
  [__VFS_REVERT__]: () => void;
213
318
  /**
214
319
  * The underlying file metadata.
215
320
  */
216
- meta: Record<string, VirtualFileSystemMetadata | undefined>;
321
+ metadata: Record<string, VirtualFileMetadata | undefined>;
217
322
  /**
218
323
  * A map of module ids to their file paths.
219
324
  */
@@ -233,7 +338,7 @@ interface VirtualFileSystemInterface {
233
338
  * @param options - Optional parameters for resolving the path.
234
339
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
235
340
  */
236
- isFs: (pathOrId: string, options?: ResolvePathOptions) => boolean;
341
+ isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
237
342
  /**
238
343
  * Checks if a file exists in the virtual file system (VFS).
239
344
  *
@@ -248,15 +353,6 @@ interface VirtualFileSystemInterface {
248
353
  * @returns `true` if the directory exists, otherwise `false`.
249
354
  */
250
355
  isDirectory: (path: string) => boolean;
251
- /**
252
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
253
- *
254
- * @see https://www.typescriptlang.org/tsconfig#paths
255
- *
256
- * @param pathOrId - The path or id to check.
257
- * @returns Whether the path or id corresponds to a virtual file.
258
- */
259
- isTsconfigPath: (pathOrId: string) => boolean;
260
356
  /**
261
357
  * Checks if a file exists in the virtual file system (VFS).
262
358
  *
@@ -270,7 +366,7 @@ interface VirtualFileSystemInterface {
270
366
  * @param pathOrId - The path or id of the file.
271
367
  * @returns The metadata of the file if it exists, otherwise undefined.
272
368
  */
273
- getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;
369
+ getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
274
370
  /**
275
371
  * Gets the stats of a file in the virtual file system (VFS).
276
372
  *
@@ -478,23 +574,12 @@ interface VirtualFileSystemInterface {
478
574
  */
479
575
  resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
480
576
  /**
481
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
482
- *
483
- * @see https://www.typescriptlang.org/tsconfig#paths
484
- *
485
- * @param path - The path to check.
486
- * @returns The resolved file path if it exists, otherwise undefined.
487
- */
488
- resolveTsconfigPath: (path: string) => string | false;
489
- /**
490
- * Resolves a package name based on TypeScript's `tsconfig.json` paths.
491
- *
492
- * @see https://www.typescriptlang.org/tsconfig#paths
577
+ * Formats a path to match the virtual file system (VFS) structure.
493
578
  *
494
- * @param path - The path to check.
495
- * @returns The resolved package name if it exists, otherwise undefined.
579
+ * @param path - The path to format.
580
+ * @returns The formatted path.
496
581
  */
497
- resolveTsconfigPathPackage: (path: string) => string | false;
582
+ formatPath: (path: string) => string;
498
583
  /**
499
584
  * Resolves a path or id to a file path in the virtual file system.
500
585
  *
@@ -503,23 +588,9 @@ interface VirtualFileSystemInterface {
503
588
  */
504
589
  realpathSync: (pathOrId: string) => string;
505
590
  /**
506
- * Retrieves a partial metadata mapping of all files in the virtual file system (VFS).
507
- *
508
- * @returns A record mapping file paths to their partial metadata.
509
- */
510
- getPartialMeta: () => Record<string, Partial<VirtualFileSystemMetadata>>;
511
- /**
512
- * A map of cached file paths to their underlying file content.
513
- */
514
- [__VFS_CACHE__]: Map<string, string>;
515
- /**
516
- * A reference to the underlying virtual file system.
591
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
517
592
  */
518
- [__VFS_VIRTUAL__]: Volume;
519
- /**
520
- * A reference to the underlying unified file system.
521
- */
522
- [__VFS_UNIFIED__]: IUnionFs;
593
+ dispose: () => Promise<void>;
523
594
  }
524
595
 
525
596
  type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
@@ -645,24 +716,33 @@ interface BaseConfig {
645
716
  * The entry point(s) for the application
646
717
  */
647
718
  entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
719
+ /**
720
+ * Configuration for the output of the build process
721
+ */
722
+ output?: OutputConfig;
648
723
  /**
649
724
  * Configuration for linting the source code
725
+ *
726
+ * @remarks
727
+ * If set to `false`, linting will be disabled.
650
728
  */
651
729
  lint?: Record<string, any> | false;
652
730
  /**
653
731
  * Configuration for testing the source code
732
+ *
733
+ * @remarks
734
+ * If set to `false`, testing will be disabled.
654
735
  */
655
736
  test?: Record<string, any> | false;
656
- /**
657
- * Configuration for the output of the build process
658
- */
659
- output?: OutputConfig;
660
737
  /**
661
738
  * Configuration for the transformation of the source code
662
739
  */
663
740
  transform?: Record<string, any>;
664
741
  /**
665
- * Options to to provide to the build process
742
+ * Configuration provided to build processes
743
+ *
744
+ * @remarks
745
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
666
746
  */
667
747
  build?: BuildConfig;
668
748
  /**
@@ -672,6 +752,13 @@ interface BaseConfig {
672
752
  * This configuration will be used by the documentation generation plugins during the `docs` command.
673
753
  */
674
754
  docs?: Record<string, any>;
755
+ /**
756
+ * Configuration for deploying the source code
757
+ *
758
+ * @remarks
759
+ * If set to `false`, the deployment will be disabled.
760
+ */
761
+ deploy?: Record<string, any> | false;
675
762
  /**
676
763
  * The path to the tsconfig file to be used by the compiler
677
764
  *
@@ -692,37 +779,6 @@ interface BaseConfig {
692
779
  tsconfigRaw?: TSConfig;
693
780
  }
694
781
  interface EnvironmentConfig extends BaseConfig {
695
- /**
696
- * 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.
697
- *
698
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
699
- */
700
- mainFields?: string[];
701
- /**
702
- * Array of strings indicating what conditions should be used for module resolution.
703
- */
704
- conditions?: string[];
705
- /**
706
- * Array of strings indicating what conditions should be used for external modules.
707
- */
708
- externalConditions?: string[];
709
- /**
710
- * Array of strings indicating what file extensions should be used for module resolution.
711
- *
712
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
713
- */
714
- extensions?: string[];
715
- /**
716
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
717
- *
718
- * @remarks
719
- * 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.
720
- */
721
- dedupe?: string[];
722
- /**
723
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
724
- */
725
- builtins?: (string | RegExp)[];
726
782
  /**
727
783
  * Configuration options for the preview server
728
784
  */
@@ -795,17 +851,29 @@ interface CommonUserConfig extends BaseConfig {
795
851
  */
796
852
  framework?: string;
797
853
  }
798
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
799
- build?: TBuildConfig & {
854
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = Omit<CommonUserConfig, "build"> & {
855
+ /**
856
+ * Configuration provided to build processes
857
+ *
858
+ * @remarks
859
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
860
+ */
861
+ build: Omit<TBuildConfig, "override"> & {
800
862
  /**
801
863
  * The build variant being used by the Powerlines engine.
802
864
  */
803
865
  variant?: TBuildVariant;
866
+ /**
867
+ * An optional set of override options to apply to the selected build variant.
868
+ *
869
+ * @remarks
870
+ * 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.
871
+ */
872
+ override?: Partial<TBuildResolvedConfig>;
804
873
  };
805
- override?: Partial<TBuildResolvedConfig>;
806
874
  };
807
875
  type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
808
- type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
876
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
809
877
  /**
810
878
  * The configuration provided while executing Powerlines commands.
811
879
  */
@@ -826,7 +894,7 @@ interface ResolvedEntryTypeDefinition extends TypeDefinition {
826
894
  */
827
895
  output?: string;
828
896
  }
829
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
897
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
830
898
  /**
831
899
  * The name of the environment
832
900
  */
@@ -843,7 +911,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
843
911
  /**
844
912
  * The resolved options for the Powerlines project configuration.
845
913
  */
846
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "root" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "framework">> & {
914
+ 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">> & {
847
915
  /**
848
916
  * The configuration options that were provided inline to the Powerlines CLI.
849
917
  */
@@ -874,6 +942,13 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
874
942
  * The output configuration options to use for the build process
875
943
  */
876
944
  output: OutputResolvedConfig;
945
+ /**
946
+ * Configuration provided to build processes
947
+ *
948
+ * @remarks
949
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
950
+ */
951
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
877
952
  /**
878
953
  * The log level to use for the Powerlines processes.
879
954
  *
@@ -908,14 +983,6 @@ interface MetaInfo {
908
983
  * A hash that represents the path to the project root directory
909
984
  */
910
985
  configHash: string;
911
- /**
912
- * A mapping of runtime ids to their corresponding file paths
913
- */
914
- builtinIdMap: Record<string, string>;
915
- /**
916
- * A mapping of virtual file paths to their corresponding file contents
917
- */
918
- virtualFiles: Record<string, string | null>;
919
986
  }
920
987
  interface Resolver extends Jiti {
921
988
  plugin: Jiti;
@@ -928,7 +995,13 @@ interface InitContextOptions {
928
995
  */
929
996
  isHighPriority: boolean;
930
997
  }
931
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
998
+ /**
999
+ * The unresolved Powerlines context.
1000
+ *
1001
+ * @remarks
1002
+ * This context is used before the user configuration has been fully resolved after the `config`.
1003
+ */
1004
+ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
932
1005
  /**
933
1006
  * The Storm workspace configuration
934
1007
  */
@@ -936,7 +1009,10 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
936
1009
  /**
937
1010
  * An object containing the options provided to Powerlines
938
1011
  */
939
- config: TResolvedConfig;
1012
+ config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
1013
+ projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
1014
+ output: TResolvedConfig["output"];
1015
+ };
940
1016
  /**
941
1017
  * A logging function for the Powerlines engine
942
1018
  */
@@ -1093,6 +1169,12 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1093
1169
  */
1094
1170
  extendLog: (name: string) => LogFn;
1095
1171
  }
1172
+ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
1173
+ /**
1174
+ * The fully resolved Powerlines configuration
1175
+ */
1176
+ config: TResolvedConfig;
1177
+ };
1096
1178
  interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1097
1179
  /**
1098
1180
  * The environment specific resolved configuration
@@ -1108,7 +1190,7 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
1108
1190
  }
1109
1191
  type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1110
1192
 
1111
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "release", "finalize"];
1193
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
1112
1194
  type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
1113
1195
 
1114
1196
  interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
@@ -1133,6 +1215,10 @@ interface GenerateTypesResult {
1133
1215
  directives?: string[];
1134
1216
  code: string;
1135
1217
  }
1218
+ type DeepPartial<T> = {
1219
+ [K in keyof T]?: DeepPartial<T[K]>;
1220
+ };
1221
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
1136
1222
  interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
1137
1223
  /**
1138
1224
  * A function that returns configuration options to be merged with the build context's options.
@@ -1148,7 +1234,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
1148
1234
  * @param config - The partial configuration object to be modified.
1149
1235
  * @returns A promise that resolves to a partial configuration object.
1150
1236
  */
1151
- config: (this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>;
1237
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
1152
1238
  /**
1153
1239
  * 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.
1154
1240
  *
@@ -1251,7 +1337,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
1251
1337
  * @param config - The partial configuration object to be modified.
1252
1338
  * @returns A promise that resolves to a partial configuration object.
1253
1339
  */
1254
- config: PluginHook<(this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>> | Partial<TContext["config"]["userConfig"]>;
1340
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
1255
1341
  /**
1256
1342
  * A hook that is called to transform the source code.
1257
1343
  *
package/dist/index.cjs CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  *****************************************/
6
6
 
7
- const c=chunkFBBMZ4NC_cjs.a((n={})=>({name:"tsup",config(){return this.log(types$1.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:["cjs","esm"]},build:{...n,variant:"tsup"}}},async build(){return tsup.build(await tsup.resolveOptions(a__default.default({config:false,entry:Object.fromEntries(Object.entries(tsup$1.resolveTsupEntry(this,this.entry)).map(([i,t])=>[i,append.appendPath(t,this.config.projectRoot)])),esbuildOptions:chunkFBBMZ4NC_cjs.a((i,t)=>{this.config.build.variant==="tsup"&&(this.config.build.esbuildOptions?this.config.build.esbuildOptions?.(i,t):this.config.override.esbuildOptions&&this.config.override.esbuildOptions?.(i,t)),i.alias={...this.builtins.reduce((o,e)=>{const r=this.fs.ids[e];return r&&(o[e]=r),o},{}),...i.alias};},"esbuildOptions"),silent:false,verbose:true},tsup$1.extractTsupConfig(this),{esbuildPlugins:[unplugin.createTsupPlugin(this)]})))}}),"plugin");var A=c;exports.default=A;exports.plugin=c;Object.keys(helpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return helpers[k]}})});Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
7
+ const c=chunkFBBMZ4NC_cjs.a((r={})=>({name:"tsup",config(){return this.log(types$1.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:["cjs","esm"]},build:{...r,variant:"tsup"}}},async build(){return tsup.build(await tsup.resolveOptions(a__default.default({config:false,entry:Object.fromEntries(Object.entries(tsup$1.resolveTsupEntry(this,this.entry)).map(([i,t])=>[i,append.appendPath(t,this.config.projectRoot)])),esbuildOptions:chunkFBBMZ4NC_cjs.a((i,t)=>{this.config.build.variant==="tsup"&&this.config.build.esbuildOptions&&this.config.build.esbuildOptions?.(i,t),i.alias={...this.builtins.reduce((s,e)=>{const n=this.fs.ids[e];return n&&(s[e]=n),s},{}),...i.alias};},"esbuildOptions"),silent:false,verbose:true},tsup$1.extractTsupConfig(this),{esbuildPlugins:[unplugin.createTsupPlugin(this)]})))}}),"plugin");var A=c;exports.default=A;exports.plugin=c;Object.keys(helpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return helpers[k]}})});Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TsupPluginContext, a as TsupPluginOptions, P as Plugin } from './index-C_qoO2U3.cjs';
2
- export { c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from './index-C_qoO2U3.cjs';
1
+ import { T as TsupPluginContext, a as TsupPluginOptions, P as Plugin } from './index-xv9Aw-0p.cjs';
2
+ export { c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from './index-xv9Aw-0p.cjs';
3
3
  export { createTsupPlugin } from './helpers/unplugin.cjs';
4
4
  import '@storm-software/tsup/types';
5
5
  import '@storm-software/build-tools/types';
@@ -18,9 +18,7 @@ import 'unplugin';
18
18
  import '@stryke/types/tsconfig';
19
19
  import 'typescript';
20
20
  import '@stryke/json/types';
21
- import 'memfs';
22
21
  import 'node:fs';
23
- import 'unionfs';
24
22
  import '@stryke/types/array';
25
23
  import 'esbuild';
26
24
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TsupPluginContext, a as TsupPluginOptions, P as Plugin } from './index-C_qoO2U3.js';
2
- export { c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from './index-C_qoO2U3.js';
1
+ import { T as TsupPluginContext, a as TsupPluginOptions, P as Plugin } from './index-xv9Aw-0p.js';
2
+ export { c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from './index-xv9Aw-0p.js';
3
3
  export { createTsupPlugin } from './helpers/unplugin.js';
4
4
  import '@storm-software/tsup/types';
5
5
  import '@storm-software/build-tools/types';
@@ -18,9 +18,7 @@ import 'unplugin';
18
18
  import '@stryke/types/tsconfig';
19
19
  import 'typescript';
20
20
  import '@stryke/json/types';
21
- import 'memfs';
22
21
  import 'node:fs';
23
- import 'unionfs';
24
22
  import '@stryke/types/array';
25
23
  import 'esbuild';
26
24
 
package/dist/index.js CHANGED
@@ -4,4 +4,4 @@ import {a}from'./chunk-UCUR73HG.js';import {LogLevelLabel}from'@storm-software/c
4
4
  *
5
5
  *****************************************/
6
6
 
7
- const c=a((n={})=>({name:"tsup",config(){return this.log(LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:["cjs","esm"]},build:{...n,variant:"tsup"}}},async build(){return build(await resolveOptions(a$1({config:false,entry:Object.fromEntries(Object.entries(resolveTsupEntry(this,this.entry)).map(([i,t])=>[i,appendPath(t,this.config.projectRoot)])),esbuildOptions:a((i,t)=>{this.config.build.variant==="tsup"&&(this.config.build.esbuildOptions?this.config.build.esbuildOptions?.(i,t):this.config.override.esbuildOptions&&this.config.override.esbuildOptions?.(i,t)),i.alias={...this.builtins.reduce((o,e)=>{const r=this.fs.ids[e];return r&&(o[e]=r),o},{}),...i.alias};},"esbuildOptions"),silent:false,verbose:true},extractTsupConfig(this),{esbuildPlugins:[createTsupPlugin(this)]})))}}),"plugin");var k=c;export{k as default,c as plugin};
7
+ const c=a((r={})=>({name:"tsup",config(){return this.log(LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsup` build plugin."),{output:{format:["cjs","esm"]},build:{...r,variant:"tsup"}}},async build(){return build(await resolveOptions(a$1({config:false,entry:Object.fromEntries(Object.entries(resolveTsupEntry(this,this.entry)).map(([i,t])=>[i,appendPath(t,this.config.projectRoot)])),esbuildOptions:a((i,t)=>{this.config.build.variant==="tsup"&&this.config.build.esbuildOptions&&this.config.build.esbuildOptions?.(i,t),i.alias={...this.builtins.reduce((s,e)=>{const n=this.fs.ids[e];return n&&(s[e]=n),s},{}),...i.alias};},"esbuildOptions"),silent:false,verbose:true},extractTsupConfig(this),{esbuildPlugins:[createTsupPlugin(this)]})))}}),"plugin");var k=c;export{k as default,c as plugin};
@@ -1,4 +1,4 @@
1
- export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-C_qoO2U3.cjs';
1
+ export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-xv9Aw-0p.cjs';
2
2
  import '@storm-software/tsup/types';
3
3
  import '@storm-software/build-tools/types';
4
4
  import '@storm-software/config-tools/types';
@@ -16,7 +16,5 @@ import 'unplugin';
16
16
  import '@stryke/types/tsconfig';
17
17
  import 'typescript';
18
18
  import '@stryke/json/types';
19
- import 'memfs';
20
19
  import 'node:fs';
21
- import 'unionfs';
22
20
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-C_qoO2U3.js';
1
+ export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-xv9Aw-0p.js';
2
2
  import '@storm-software/tsup/types';
3
3
  import '@storm-software/build-tools/types';
4
4
  import '@storm-software/config-tools/types';
@@ -16,7 +16,5 @@ import 'unplugin';
16
16
  import '@stryke/types/tsconfig';
17
17
  import 'typescript';
18
18
  import '@stryke/json/types';
19
- import 'memfs';
20
19
  import 'node:fs';
21
- import 'unionfs';
22
20
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-C_qoO2U3.cjs';
1
+ export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-xv9Aw-0p.cjs';
2
2
  import '@storm-software/tsup/types';
3
3
  import '@storm-software/build-tools/types';
4
4
  import '@storm-software/config-tools/types';
@@ -16,7 +16,5 @@ import 'unplugin';
16
16
  import '@stryke/types/tsconfig';
17
17
  import 'typescript';
18
18
  import '@stryke/json/types';
19
- import 'memfs';
20
19
  import 'node:fs';
21
- import 'unionfs';
22
20
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-C_qoO2U3.js';
1
+ export { T as TsupPluginContext, a as TsupPluginOptions, c as TsupPluginResolvedConfig, b as TsupPluginUserConfig } from '../index-xv9Aw-0p.js';
2
2
  import '@storm-software/tsup/types';
3
3
  import '@storm-software/build-tools/types';
4
4
  import '@storm-software/config-tools/types';
@@ -16,7 +16,5 @@ import 'unplugin';
16
16
  import '@stryke/types/tsconfig';
17
17
  import 'typescript';
18
18
  import '@stryke/json/types';
19
- import 'memfs';
20
19
  import 'node:fs';
21
- import 'unionfs';
22
20
  import '@stryke/types/array';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-tsup",
3
- "version": "0.12.18",
3
+ "version": "0.12.21",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
6
6
  "repository": {
@@ -132,13 +132,13 @@
132
132
  "@stryke/type-checks": "^0.3.12",
133
133
  "@stryke/types": "^0.10.2",
134
134
  "defu": "^6.1.4",
135
- "powerlines": "^0.19.5"
135
+ "powerlines": "^0.22.0"
136
136
  },
137
137
  "devDependencies": {
138
- "@powerlines/nx": "^0.10.9",
139
- "@powerlines/plugin-plugin": "^0.11.17",
138
+ "@powerlines/nx": "^0.10.12",
139
+ "@powerlines/plugin-plugin": "^0.11.20",
140
140
  "@types/node": "^22.19.1"
141
141
  },
142
142
  "publishConfig": { "access": "public" },
143
- "gitHead": "041609f2ea8770273cff82b402e3abdc3fcd9133"
143
+ "gitHead": "30a4cf4f1c707fe159b55f65f1e87b14d679614d"
144
144
  }