@powerlines/plugin-babel 0.12.18 → 0.12.20

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,5 +1,5 @@
1
1
  import { MaybePromise, NonUndefined, FunctionLike } from '@stryke/types/base';
2
- import { UnpluginContext, UnpluginBuildContext, UnpluginMessage, TransformResult, ExternalIdResult, HookFilter, UnpluginOptions } from 'unplugin';
2
+ import { UnpluginContext, UnpluginMessage, UnpluginBuildContext, TransformResult, ExternalIdResult, HookFilter, UnpluginOptions } from 'unplugin';
3
3
  import { ArrayValues } from '@stryke/types/array';
4
4
  import { PluginItem, PluginObj, PluginPass, transformAsync } from '@babel/core';
5
5
  import { Format } from '@storm-software/build-tools/types';
@@ -17,9 +17,7 @@ import { Range } from 'semver';
17
17
  import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
18
18
  import ts from 'typescript';
19
19
  import { PrimitiveJsonValue } from '@stryke/json/types';
20
- import { Volume } from 'memfs';
21
20
  import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
22
- import { IUnionFs } from 'unionfs';
23
21
 
24
22
  type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
25
23
  interface BuildConfig {
@@ -29,6 +27,87 @@ interface BuildConfig {
29
27
  * @defaultValue "neutral"
30
28
  */
31
29
  platform?: "node" | "browser" | "neutral";
30
+ /**
31
+ * Array of strings indicating the polyfills to include for the build.
32
+ *
33
+ * @remarks
34
+ * 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).
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * {
39
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
40
+ * }
41
+ * ```
42
+ */
43
+ polyfill?: string[];
44
+ /**
45
+ * 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.
46
+ *
47
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
48
+ */
49
+ mainFields?: string[];
50
+ /**
51
+ * Array of strings indicating what conditions should be used for module resolution.
52
+ */
53
+ conditions?: string[];
54
+ /**
55
+ * Array of strings indicating what file extensions should be used for module resolution.
56
+ *
57
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
58
+ */
59
+ extensions?: string[];
60
+ /**
61
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
62
+ *
63
+ * @remarks
64
+ * 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.
65
+ */
66
+ dedupe?: string[];
67
+ /**
68
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
69
+ */
70
+ builtins?: (string | RegExp)[];
71
+ /**
72
+ * Define global variable replacements.
73
+ *
74
+ * @remarks
75
+ * 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.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * {
80
+ * define: {
81
+ * __VERSION__: '"1.0.0"',
82
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
83
+ * }
84
+ * }
85
+ * ```
86
+ *
87
+ * @see https://esbuild.github.io/api/#define
88
+ * @see https://vitejs.dev/config/build-options.html#define
89
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
90
+ */
91
+ define?: Record<string, any>;
92
+ /**
93
+ * Global variables that will have import statements injected where necessary
94
+ *
95
+ * @remarks
96
+ * 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.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * {
101
+ * inject: {
102
+ * process: 'process/browser',
103
+ * Buffer: ['buffer', 'Buffer'],
104
+ * }
105
+ * }
106
+ * ```
107
+ *
108
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
109
+ */
110
+ inject?: Record<string, string | string[]>;
32
111
  /**
33
112
  * The alias mappings to use for module resolution during the build process.
34
113
  *
@@ -44,8 +123,13 @@ interface BuildConfig {
44
123
  * }
45
124
  * }
46
125
  * ```
126
+ *
127
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
47
128
  */
48
- alias?: Record<string, string>;
129
+ alias?: Record<string, string> | Array<{
130
+ find: string | RegExp;
131
+ replacement: string;
132
+ }>;
49
133
  /**
50
134
  * A list of modules that should not be bundled, even if they are external dependencies.
51
135
  *
@@ -62,13 +146,14 @@ interface BuildConfig {
62
146
  */
63
147
  skipNodeModulesBundle?: boolean;
64
148
  /**
65
- * Should the Powerlines processes skip the `"prepare"` task prior to building?
149
+ * An optional set of override options to apply to the selected build variant.
66
150
  *
67
- * @defaultValue false
151
+ * @remarks
152
+ * 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.
68
153
  */
69
- skipPrepare?: boolean;
154
+ override?: Record<string, any>;
70
155
  }
71
- type BuildResolvedConfig = BuildConfig;
156
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
72
157
 
73
158
  type BabelPluginPass<TState = unknown> = PluginPass & TState;
74
159
  type BabelTransformPluginFilter = (code: string, id: string) => boolean;
@@ -184,11 +269,8 @@ type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
184
269
  tsconfigFilePath: string;
185
270
  };
186
271
 
187
- declare const __VFS_INIT__ = "__VFS_INIT__";
188
- declare const __VFS_REVERT__ = "__VFS_REVERT__";
189
- declare const __VFS_CACHE__ = "__VFS_CACHE__";
190
- declare const __VFS_VIRTUAL__ = "__VFS_VIRTUAL__";
191
- declare const __VFS_UNIFIED__ = "__VFS_UNIFIED__";
272
+ declare const __VFS_PATCH__: unique symbol;
273
+ declare const __VFS_REVERT__: unique symbol;
192
274
  type OutputModeType = "fs" | "virtual";
193
275
  interface VirtualFile {
194
276
  /**
@@ -228,7 +310,24 @@ interface VirtualFile {
228
310
  */
229
311
  code: string | NodeJS.ArrayBufferView;
230
312
  }
231
- type VirtualFileSystemMetadata = Pick<VirtualFile, "id" | "details" | "variant" | "mode">;
313
+ interface VirtualFileMetadata {
314
+ /**
315
+ * The identifier for the file data.
316
+ */
317
+ id: string;
318
+ /**
319
+ * The variant of the file.
320
+ */
321
+ variant: string;
322
+ /**
323
+ * The output mode of the file.
324
+ */
325
+ mode: string;
326
+ /**
327
+ * Additional metadata associated with the file.
328
+ */
329
+ properties: Record<string, string>;
330
+ }
232
331
  interface ResolveFSOptions {
233
332
  mode?: OutputModeType;
234
333
  }
@@ -257,12 +356,18 @@ interface ResolvePathOptions extends ResolveFSOptions {
257
356
  type?: "file" | "directory";
258
357
  }
259
358
  interface VirtualFileSystemInterface {
260
- [__VFS_INIT__]: () => void;
359
+ /**
360
+ * Patches the File System to include the virtual file system (VFS) contents.
361
+ */
362
+ [__VFS_PATCH__]: () => void;
363
+ /**
364
+ * Reverts the virtual file system (VFS) to its previous state.
365
+ */
261
366
  [__VFS_REVERT__]: () => void;
262
367
  /**
263
368
  * The underlying file metadata.
264
369
  */
265
- meta: Record<string, VirtualFileSystemMetadata | undefined>;
370
+ metadata: Record<string, VirtualFileMetadata | undefined>;
266
371
  /**
267
372
  * A map of module ids to their file paths.
268
373
  */
@@ -282,7 +387,7 @@ interface VirtualFileSystemInterface {
282
387
  * @param options - Optional parameters for resolving the path.
283
388
  * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
284
389
  */
285
- isFs: (pathOrId: string, options?: ResolvePathOptions) => boolean;
390
+ isPhysical: (pathOrId: string, options?: ResolvePathOptions) => boolean;
286
391
  /**
287
392
  * Checks if a file exists in the virtual file system (VFS).
288
393
  *
@@ -297,15 +402,6 @@ interface VirtualFileSystemInterface {
297
402
  * @returns `true` if the directory exists, otherwise `false`.
298
403
  */
299
404
  isDirectory: (path: string) => boolean;
300
- /**
301
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
302
- *
303
- * @see https://www.typescriptlang.org/tsconfig#paths
304
- *
305
- * @param pathOrId - The path or id to check.
306
- * @returns Whether the path or id corresponds to a virtual file.
307
- */
308
- isTsconfigPath: (pathOrId: string) => boolean;
309
405
  /**
310
406
  * Checks if a file exists in the virtual file system (VFS).
311
407
  *
@@ -319,7 +415,7 @@ interface VirtualFileSystemInterface {
319
415
  * @param pathOrId - The path or id of the file.
320
416
  * @returns The metadata of the file if it exists, otherwise undefined.
321
417
  */
322
- getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;
418
+ getMetadata: (pathOrId: PathLike) => VirtualFileMetadata | undefined;
323
419
  /**
324
420
  * Gets the stats of a file in the virtual file system (VFS).
325
421
  *
@@ -527,23 +623,12 @@ interface VirtualFileSystemInterface {
527
623
  */
528
624
  resolve: (pathOrId: string, options?: ResolvePathOptions) => string | false;
529
625
  /**
530
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
531
- *
532
- * @see https://www.typescriptlang.org/tsconfig#paths
533
- *
534
- * @param path - The path to check.
535
- * @returns The resolved file path if it exists, otherwise undefined.
536
- */
537
- resolveTsconfigPath: (path: string) => string | false;
538
- /**
539
- * Resolves a package name based on TypeScript's `tsconfig.json` paths.
540
- *
541
- * @see https://www.typescriptlang.org/tsconfig#paths
626
+ * Formats a path to match the virtual file system (VFS) structure.
542
627
  *
543
- * @param path - The path to check.
544
- * @returns The resolved package name if it exists, otherwise undefined.
628
+ * @param path - The path to format.
629
+ * @returns The formatted path.
545
630
  */
546
- resolveTsconfigPathPackage: (path: string) => string | false;
631
+ formatPath: (path: string) => string;
547
632
  /**
548
633
  * Resolves a path or id to a file path in the virtual file system.
549
634
  *
@@ -552,23 +637,9 @@ interface VirtualFileSystemInterface {
552
637
  */
553
638
  realpathSync: (pathOrId: string) => string;
554
639
  /**
555
- * Retrieves a partial metadata mapping of all files in the virtual file system (VFS).
556
- *
557
- * @returns A record mapping file paths to their partial metadata.
558
- */
559
- getPartialMeta: () => Record<string, Partial<VirtualFileSystemMetadata>>;
560
- /**
561
- * A map of cached file paths to their underlying file content.
562
- */
563
- [__VFS_CACHE__]: Map<string, string>;
564
- /**
565
- * A reference to the underlying virtual file system.
640
+ * Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
566
641
  */
567
- [__VFS_VIRTUAL__]: Volume;
568
- /**
569
- * A reference to the underlying unified file system.
570
- */
571
- [__VFS_UNIFIED__]: IUnionFs;
642
+ dispose: () => Promise<void>;
572
643
  }
573
644
 
574
645
  type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
@@ -704,24 +775,33 @@ interface BaseConfig {
704
775
  * The entry point(s) for the application
705
776
  */
706
777
  entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
778
+ /**
779
+ * Configuration for the output of the build process
780
+ */
781
+ output?: OutputConfig;
707
782
  /**
708
783
  * Configuration for linting the source code
784
+ *
785
+ * @remarks
786
+ * If set to `false`, linting will be disabled.
709
787
  */
710
788
  lint?: Record<string, any> | false;
711
789
  /**
712
790
  * Configuration for testing the source code
791
+ *
792
+ * @remarks
793
+ * If set to `false`, testing will be disabled.
713
794
  */
714
795
  test?: Record<string, any> | false;
715
- /**
716
- * Configuration for the output of the build process
717
- */
718
- output?: OutputConfig;
719
796
  /**
720
797
  * Configuration for the transformation of the source code
721
798
  */
722
799
  transform?: Record<string, any>;
723
800
  /**
724
- * Options to to provide to the build process
801
+ * Configuration provided to build processes
802
+ *
803
+ * @remarks
804
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
725
805
  */
726
806
  build?: BuildConfig;
727
807
  /**
@@ -731,6 +811,13 @@ interface BaseConfig {
731
811
  * This configuration will be used by the documentation generation plugins during the `docs` command.
732
812
  */
733
813
  docs?: Record<string, any>;
814
+ /**
815
+ * Configuration for deploying the source code
816
+ *
817
+ * @remarks
818
+ * If set to `false`, the deployment will be disabled.
819
+ */
820
+ deploy?: Record<string, any> | false;
734
821
  /**
735
822
  * The path to the tsconfig file to be used by the compiler
736
823
  *
@@ -751,37 +838,6 @@ interface BaseConfig {
751
838
  tsconfigRaw?: TSConfig;
752
839
  }
753
840
  interface EnvironmentConfig extends BaseConfig {
754
- /**
755
- * 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.
756
- *
757
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
758
- */
759
- mainFields?: string[];
760
- /**
761
- * Array of strings indicating what conditions should be used for module resolution.
762
- */
763
- conditions?: string[];
764
- /**
765
- * Array of strings indicating what conditions should be used for external modules.
766
- */
767
- externalConditions?: string[];
768
- /**
769
- * Array of strings indicating what file extensions should be used for module resolution.
770
- *
771
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
772
- */
773
- extensions?: string[];
774
- /**
775
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
776
- *
777
- * @remarks
778
- * 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.
779
- */
780
- dedupe?: string[];
781
- /**
782
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
783
- */
784
- builtins?: (string | RegExp)[];
785
841
  /**
786
842
  * Configuration options for the preview server
787
843
  */
@@ -854,16 +910,28 @@ interface CommonUserConfig extends BaseConfig {
854
910
  */
855
911
  framework?: string;
856
912
  }
857
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
858
- build?: TBuildConfig & {
913
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = Omit<CommonUserConfig, "build"> & {
914
+ /**
915
+ * Configuration provided to build processes
916
+ *
917
+ * @remarks
918
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
919
+ */
920
+ build: Omit<TBuildConfig, "override"> & {
859
921
  /**
860
922
  * The build variant being used by the Powerlines engine.
861
923
  */
862
924
  variant?: TBuildVariant;
925
+ /**
926
+ * An optional set of override options to apply to the selected build variant.
927
+ *
928
+ * @remarks
929
+ * 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.
930
+ */
931
+ override?: Partial<TBuildResolvedConfig>;
863
932
  };
864
- override?: Partial<TBuildResolvedConfig>;
865
933
  };
866
- type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
934
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "deploy" | "clean";
867
935
  /**
868
936
  * The configuration provided while executing Powerlines commands.
869
937
  */
@@ -885,7 +953,7 @@ interface ResolvedEntryTypeDefinition extends TypeDefinition {
885
953
  output?: string;
886
954
  }
887
955
  type BabelResolvedConfig = Omit<BabelUserConfig, "plugins" | "presets"> & Required<Pick<BabelUserConfig, "plugins" | "presets">>;
888
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
956
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
889
957
  /**
890
958
  * The name of the environment
891
959
  */
@@ -902,7 +970,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
902
970
  /**
903
971
  * The resolved options for the Powerlines project configuration.
904
972
  */
905
- 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">> & {
973
+ 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">> & {
906
974
  /**
907
975
  * The configuration options that were provided inline to the Powerlines CLI.
908
976
  */
@@ -933,6 +1001,13 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
933
1001
  * The output configuration options to use for the build process
934
1002
  */
935
1003
  output: OutputResolvedConfig;
1004
+ /**
1005
+ * Configuration provided to build processes
1006
+ *
1007
+ * @remarks
1008
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1009
+ */
1010
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
936
1011
  /**
937
1012
  * The log level to use for the Powerlines processes.
938
1013
  *
@@ -966,14 +1041,6 @@ interface MetaInfo {
966
1041
  * A hash that represents the path to the project root directory
967
1042
  */
968
1043
  configHash: string;
969
- /**
970
- * A mapping of runtime ids to their corresponding file paths
971
- */
972
- builtinIdMap: Record<string, string>;
973
- /**
974
- * A mapping of virtual file paths to their corresponding file contents
975
- */
976
- virtualFiles: Record<string, string | null>;
977
1044
  }
978
1045
  interface Resolver extends Jiti {
979
1046
  plugin: Jiti;
@@ -986,7 +1053,13 @@ interface InitContextOptions {
986
1053
  */
987
1054
  isHighPriority: boolean;
988
1055
  }
989
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1056
+ /**
1057
+ * The unresolved Powerlines context.
1058
+ *
1059
+ * @remarks
1060
+ * This context is used before the user configuration has been fully resolved after the `config`.
1061
+ */
1062
+ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
990
1063
  /**
991
1064
  * The Storm workspace configuration
992
1065
  */
@@ -994,7 +1067,10 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
994
1067
  /**
995
1068
  * An object containing the options provided to Powerlines
996
1069
  */
997
- config: TResolvedConfig;
1070
+ config: Omit<TResolvedConfig["userConfig"], "build" | "output"> & Required<Pick<TResolvedConfig["userConfig"], "build" | "output">> & {
1071
+ projectRoot: NonUndefined<TResolvedConfig["userConfig"]["root"]>;
1072
+ output: TResolvedConfig["output"];
1073
+ };
998
1074
  /**
999
1075
  * A logging function for the Powerlines engine
1000
1076
  */
@@ -1151,6 +1227,12 @@ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1151
1227
  */
1152
1228
  extendLog: (name: string) => LogFn;
1153
1229
  }
1230
+ type Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = Omit<UnresolvedContext<TResolvedConfig>, "config"> & {
1231
+ /**
1232
+ * The fully resolved Powerlines configuration
1233
+ */
1234
+ config: TResolvedConfig;
1235
+ };
1154
1236
  interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1155
1237
  /**
1156
1238
  * The environment specific resolved configuration
@@ -1166,7 +1248,7 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
1166
1248
  }
1167
1249
  type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1168
1250
 
1169
- declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "release", "finalize"];
1251
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
1170
1252
  type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
1171
1253
 
1172
1254
  interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
@@ -1191,6 +1273,10 @@ interface GenerateTypesResult {
1191
1273
  directives?: string[];
1192
1274
  code: string;
1193
1275
  }
1276
+ type DeepPartial<T> = {
1277
+ [K in keyof T]?: DeepPartial<T[K]>;
1278
+ };
1279
+ type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
1194
1280
  interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
1195
1281
  /**
1196
1282
  * A function that returns configuration options to be merged with the build context's options.
@@ -1206,7 +1292,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
1206
1292
  * @param config - The partial configuration object to be modified.
1207
1293
  * @returns A promise that resolves to a partial configuration object.
1208
1294
  */
1209
- config: (this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>;
1295
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
1210
1296
  /**
1211
1297
  * 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.
1212
1298
  *
@@ -1309,7 +1395,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
1309
1395
  * @param config - The partial configuration object to be modified.
1310
1396
  * @returns A promise that resolves to a partial configuration object.
1311
1397
  */
1312
- config: PluginHook<(this: Context<TContext["config"]>) => MaybePromise<Partial<TContext["config"]["userConfig"]>>> | Partial<TContext["config"]["userConfig"]>;
1398
+ config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
1313
1399
  /**
1314
1400
  * A hook that is called to transform the source code.
1315
1401
  *
@@ -1,5 +1,5 @@
1
1
  export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from './plugin.cjs';
2
- import '../plugin-BJKg0KaC.cjs';
2
+ import '../plugin-CwYWLG3U.cjs';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
@@ -19,6 +19,4 @@ import 'semver';
19
19
  import '@stryke/types/tsconfig';
20
20
  import 'typescript';
21
21
  import '@stryke/json/types';
22
- import 'memfs';
23
22
  import 'node:fs';
24
- import 'unionfs';
@@ -1,5 +1,5 @@
1
1
  export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from './plugin.js';
2
- import '../plugin-BJKg0KaC.js';
2
+ import '../plugin-CwYWLG3U.js';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
@@ -19,6 +19,4 @@ import 'semver';
19
19
  import '@stryke/types/tsconfig';
20
20
  import 'typescript';
21
21
  import '@stryke/json/types';
22
- import 'memfs';
23
22
  import 'node:fs';
24
- import 'unionfs';
@@ -1,4 +1,4 @@
1
- import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-BJKg0KaC.cjs';
1
+ import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-CwYWLG3U.cjs';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -18,9 +18,7 @@ import 'semver';
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
 
25
23
  type BabelPluginOptions = Partial<BabelUserConfig>;
26
24
  type BabelPluginUserConfig = UserConfig;
@@ -1,4 +1,4 @@
1
- import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-BJKg0KaC.js';
1
+ import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-CwYWLG3U.js';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -18,9 +18,7 @@ import 'semver';
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
 
25
23
  type BabelPluginOptions = Partial<BabelUserConfig>;
26
24
  type BabelPluginUserConfig = UserConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-babel",
3
- "version": "0.12.18",
3
+ "version": "0.12.20",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
6
6
  "repository": {
@@ -144,15 +144,15 @@
144
144
  "chalk": "5.6.2",
145
145
  "defu": "^6.1.4",
146
146
  "jiti": "^2.6.1",
147
- "powerlines": "^0.19.5",
147
+ "powerlines": "^0.21.0",
148
148
  "unplugin": "^2.3.10"
149
149
  },
150
150
  "devDependencies": {
151
151
  "@babel/plugin-syntax-typescript": "^7.27.1",
152
- "@powerlines/nx": "^0.10.9",
153
- "@powerlines/plugin-plugin": "^0.11.17",
152
+ "@powerlines/nx": "^0.10.11",
153
+ "@powerlines/plugin-plugin": "^0.11.19",
154
154
  "@types/node": "^22.19.1"
155
155
  },
156
156
  "publishConfig": { "access": "public" },
157
- "gitHead": "041609f2ea8770273cff82b402e3abdc3fcd9133"
157
+ "gitHead": "c6ed2ca745c8f340a55758b3102933dc41e83428"
158
158
  }