@powerlines/plugin-babel 0.12.17 → 0.12.19

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,4 +1,4 @@
1
- import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-BJKg0KaC.cjs';
1
+ import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-DNQSUN-t.cjs';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-BJKg0KaC.js';
1
+ import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-DNQSUN-t.js';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-BJKg0KaC.cjs';
1
+ import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-DNQSUN-t.cjs';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -1,4 +1,4 @@
1
- import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-BJKg0KaC.js';
1
+ import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-DNQSUN-t.js';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -6,7 +6,7 @@ export { resolveBabelPlugin, resolvePluginFunction } from './options.cjs';
6
6
  export { GeneratorResult } from '@babel/generator';
7
7
  import '@babel/parser';
8
8
  import '@babel/types';
9
- import '../plugin-BJKg0KaC.cjs';
9
+ import '../plugin-DNQSUN-t.cjs';
10
10
  import '@stryke/types/base';
11
11
  import 'unplugin';
12
12
  import '@stryke/types/array';
@@ -6,7 +6,7 @@ export { resolveBabelPlugin, resolvePluginFunction } from './options.js';
6
6
  export { GeneratorResult } from '@babel/generator';
7
7
  import '@babel/parser';
8
8
  import '@babel/types';
9
- import '../plugin-BJKg0KaC.js';
9
+ import '../plugin-DNQSUN-t.js';
10
10
  import '@stryke/types/base';
11
11
  import 'unplugin';
12
12
  import '@stryke/types/array';
@@ -1,7 +1,7 @@
1
1
  import { NodePath } from '@babel/core';
2
2
  import { ParseResult } from '@babel/parser';
3
3
  import * as t from '@babel/types';
4
- import { I as ImportSpecifier } from '../plugin-BJKg0KaC.cjs';
4
+ import { I as ImportSpecifier } from '../plugin-DNQSUN-t.cjs';
5
5
  import '@stryke/types/base';
6
6
  import 'unplugin';
7
7
  import '@stryke/types/array';
@@ -1,7 +1,7 @@
1
1
  import { NodePath } from '@babel/core';
2
2
  import { ParseResult } from '@babel/parser';
3
3
  import * as t from '@babel/types';
4
- import { I as ImportSpecifier } from '../plugin-BJKg0KaC.js';
4
+ import { I as ImportSpecifier } from '../plugin-DNQSUN-t.js';
5
5
  import '@stryke/types/base';
6
6
  import 'unplugin';
7
7
  import '@stryke/types/array';
@@ -1,5 +1,5 @@
1
1
  import { PluginTarget, PluginOptions } from '@babel/core';
2
- import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-BJKg0KaC.cjs';
2
+ import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-DNQSUN-t.cjs';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
@@ -1,5 +1,5 @@
1
1
  import { PluginTarget, PluginOptions } from '@babel/core';
2
- import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-BJKg0KaC.js';
2
+ import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-DNQSUN-t.js';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Plugin } from './plugin-BJKg0KaC.cjs';
1
+ import { P as Plugin } from './plugin-DNQSUN-t.cjs';
2
2
  import { BabelPluginOptions, BabelPluginContext } from './types/plugin.cjs';
3
3
  export { BabelPluginResolvedConfig, BabelPluginUserConfig } from './types/plugin.cjs';
4
4
  export { GenerateFromAstOptions, generateFromAst, parseAst } from './helpers/ast-utils.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Plugin } from './plugin-BJKg0KaC.js';
1
+ import { P as Plugin } from './plugin-DNQSUN-t.js';
2
2
  import { BabelPluginOptions, BabelPluginContext } from './types/plugin.js';
3
3
  export { BabelPluginResolvedConfig, BabelPluginUserConfig } from './types/plugin.js';
4
4
  export { GenerateFromAstOptions, generateFromAst, parseAst } from './helpers/ast-utils.js';
@@ -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';
@@ -29,6 +29,73 @@ interface BuildConfig {
29
29
  * @defaultValue "neutral"
30
30
  */
31
31
  platform?: "node" | "browser" | "neutral";
32
+ /**
33
+ * 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.
34
+ *
35
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
36
+ */
37
+ mainFields?: string[];
38
+ /**
39
+ * Array of strings indicating what conditions should be used for module resolution.
40
+ */
41
+ conditions?: string[];
42
+ /**
43
+ * Array of strings indicating what file extensions should be used for module resolution.
44
+ *
45
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
46
+ */
47
+ extensions?: string[];
48
+ /**
49
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
50
+ *
51
+ * @remarks
52
+ * 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.
53
+ */
54
+ dedupe?: string[];
55
+ /**
56
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
57
+ */
58
+ builtins?: (string | RegExp)[];
59
+ /**
60
+ * Define global variable replacements.
61
+ *
62
+ * @remarks
63
+ * 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.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * {
68
+ * define: {
69
+ * __VERSION__: '"1.0.0"',
70
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
71
+ * }
72
+ * }
73
+ * ```
74
+ *
75
+ * @see https://esbuild.github.io/api/#define
76
+ * @see https://vitejs.dev/config/build-options.html#define
77
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
78
+ */
79
+ define?: Record<string, any>;
80
+ /**
81
+ * Global variables that will have import statements injected where necessary
82
+ *
83
+ * @remarks
84
+ * 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.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * {
89
+ * inject: {
90
+ * process: 'process/browser',
91
+ * Buffer: ['buffer', 'Buffer'],
92
+ * }
93
+ * }
94
+ * ```
95
+ *
96
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
97
+ */
98
+ inject?: Record<string, string | string[]>;
32
99
  /**
33
100
  * The alias mappings to use for module resolution during the build process.
34
101
  *
@@ -44,6 +111,8 @@ interface BuildConfig {
44
111
  * }
45
112
  * }
46
113
  * ```
114
+ *
115
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
47
116
  */
48
117
  alias?: Record<string, string>;
49
118
  /**
@@ -62,13 +131,14 @@ interface BuildConfig {
62
131
  */
63
132
  skipNodeModulesBundle?: boolean;
64
133
  /**
65
- * Should the Powerlines processes skip the `"prepare"` task prior to building?
134
+ * An optional set of override options to apply to the selected build variant.
66
135
  *
67
- * @defaultValue false
136
+ * @remarks
137
+ * 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
138
  */
69
- skipPrepare?: boolean;
139
+ override?: Record<string, any>;
70
140
  }
71
- type BuildResolvedConfig = BuildConfig;
141
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
72
142
 
73
143
  type BabelPluginPass<TState = unknown> = PluginPass & TState;
74
144
  type BabelTransformPluginFilter = (code: string, id: string) => boolean;
@@ -704,24 +774,33 @@ interface BaseConfig {
704
774
  * The entry point(s) for the application
705
775
  */
706
776
  entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
777
+ /**
778
+ * Configuration for the output of the build process
779
+ */
780
+ output?: OutputConfig;
707
781
  /**
708
782
  * Configuration for linting the source code
783
+ *
784
+ * @remarks
785
+ * If set to `false`, linting will be disabled.
709
786
  */
710
787
  lint?: Record<string, any> | false;
711
788
  /**
712
789
  * Configuration for testing the source code
790
+ *
791
+ * @remarks
792
+ * If set to `false`, testing will be disabled.
713
793
  */
714
794
  test?: Record<string, any> | false;
715
- /**
716
- * Configuration for the output of the build process
717
- */
718
- output?: OutputConfig;
719
795
  /**
720
796
  * Configuration for the transformation of the source code
721
797
  */
722
798
  transform?: Record<string, any>;
723
799
  /**
724
- * Options to to provide to the build process
800
+ * Configuration provided to build processes
801
+ *
802
+ * @remarks
803
+ * 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
804
  */
726
805
  build?: BuildConfig;
727
806
  /**
@@ -751,37 +830,6 @@ interface BaseConfig {
751
830
  tsconfigRaw?: TSConfig;
752
831
  }
753
832
  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
833
  /**
786
834
  * Configuration options for the preview server
787
835
  */
@@ -854,14 +902,26 @@ interface CommonUserConfig extends BaseConfig {
854
902
  */
855
903
  framework?: string;
856
904
  }
857
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
858
- build?: TBuildConfig & {
905
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = Omit<CommonUserConfig, "build"> & {
906
+ /**
907
+ * Configuration provided to build processes
908
+ *
909
+ * @remarks
910
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
911
+ */
912
+ build: Omit<TBuildConfig, "override"> & {
859
913
  /**
860
914
  * The build variant being used by the Powerlines engine.
861
915
  */
862
916
  variant?: TBuildVariant;
917
+ /**
918
+ * An optional set of override options to apply to the selected build variant.
919
+ *
920
+ * @remarks
921
+ * 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.
922
+ */
923
+ override?: Partial<TBuildResolvedConfig>;
863
924
  };
864
- override?: Partial<TBuildResolvedConfig>;
865
925
  };
866
926
  type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
867
927
  /**
@@ -885,7 +945,7 @@ interface ResolvedEntryTypeDefinition extends TypeDefinition {
885
945
  output?: string;
886
946
  }
887
947
  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">> & {
948
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
889
949
  /**
890
950
  * The name of the environment
891
951
  */
@@ -902,7 +962,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
902
962
  /**
903
963
  * The resolved options for the Powerlines project configuration.
904
964
  */
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">> & {
965
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "framework">> & {
906
966
  /**
907
967
  * The configuration options that were provided inline to the Powerlines CLI.
908
968
  */
@@ -933,6 +993,13 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
933
993
  * The output configuration options to use for the build process
934
994
  */
935
995
  output: OutputResolvedConfig;
996
+ /**
997
+ * Configuration provided to build processes
998
+ *
999
+ * @remarks
1000
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1001
+ */
1002
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
936
1003
  /**
937
1004
  * The log level to use for the Powerlines processes.
938
1005
  *
@@ -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
@@ -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
  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';
@@ -29,6 +29,73 @@ interface BuildConfig {
29
29
  * @defaultValue "neutral"
30
30
  */
31
31
  platform?: "node" | "browser" | "neutral";
32
+ /**
33
+ * 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.
34
+ *
35
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
36
+ */
37
+ mainFields?: string[];
38
+ /**
39
+ * Array of strings indicating what conditions should be used for module resolution.
40
+ */
41
+ conditions?: string[];
42
+ /**
43
+ * Array of strings indicating what file extensions should be used for module resolution.
44
+ *
45
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
46
+ */
47
+ extensions?: string[];
48
+ /**
49
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
50
+ *
51
+ * @remarks
52
+ * 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.
53
+ */
54
+ dedupe?: string[];
55
+ /**
56
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
57
+ */
58
+ builtins?: (string | RegExp)[];
59
+ /**
60
+ * Define global variable replacements.
61
+ *
62
+ * @remarks
63
+ * 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.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * {
68
+ * define: {
69
+ * __VERSION__: '"1.0.0"',
70
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
71
+ * }
72
+ * }
73
+ * ```
74
+ *
75
+ * @see https://esbuild.github.io/api/#define
76
+ * @see https://vitejs.dev/config/build-options.html#define
77
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
78
+ */
79
+ define?: Record<string, any>;
80
+ /**
81
+ * Global variables that will have import statements injected where necessary
82
+ *
83
+ * @remarks
84
+ * 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.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * {
89
+ * inject: {
90
+ * process: 'process/browser',
91
+ * Buffer: ['buffer', 'Buffer'],
92
+ * }
93
+ * }
94
+ * ```
95
+ *
96
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
97
+ */
98
+ inject?: Record<string, string | string[]>;
32
99
  /**
33
100
  * The alias mappings to use for module resolution during the build process.
34
101
  *
@@ -44,6 +111,8 @@ interface BuildConfig {
44
111
  * }
45
112
  * }
46
113
  * ```
114
+ *
115
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
47
116
  */
48
117
  alias?: Record<string, string>;
49
118
  /**
@@ -62,13 +131,14 @@ interface BuildConfig {
62
131
  */
63
132
  skipNodeModulesBundle?: boolean;
64
133
  /**
65
- * Should the Powerlines processes skip the `"prepare"` task prior to building?
134
+ * An optional set of override options to apply to the selected build variant.
66
135
  *
67
- * @defaultValue false
136
+ * @remarks
137
+ * 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
138
  */
69
- skipPrepare?: boolean;
139
+ override?: Record<string, any>;
70
140
  }
71
- type BuildResolvedConfig = BuildConfig;
141
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
72
142
 
73
143
  type BabelPluginPass<TState = unknown> = PluginPass & TState;
74
144
  type BabelTransformPluginFilter = (code: string, id: string) => boolean;
@@ -704,24 +774,33 @@ interface BaseConfig {
704
774
  * The entry point(s) for the application
705
775
  */
706
776
  entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
777
+ /**
778
+ * Configuration for the output of the build process
779
+ */
780
+ output?: OutputConfig;
707
781
  /**
708
782
  * Configuration for linting the source code
783
+ *
784
+ * @remarks
785
+ * If set to `false`, linting will be disabled.
709
786
  */
710
787
  lint?: Record<string, any> | false;
711
788
  /**
712
789
  * Configuration for testing the source code
790
+ *
791
+ * @remarks
792
+ * If set to `false`, testing will be disabled.
713
793
  */
714
794
  test?: Record<string, any> | false;
715
- /**
716
- * Configuration for the output of the build process
717
- */
718
- output?: OutputConfig;
719
795
  /**
720
796
  * Configuration for the transformation of the source code
721
797
  */
722
798
  transform?: Record<string, any>;
723
799
  /**
724
- * Options to to provide to the build process
800
+ * Configuration provided to build processes
801
+ *
802
+ * @remarks
803
+ * 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
804
  */
726
805
  build?: BuildConfig;
727
806
  /**
@@ -751,37 +830,6 @@ interface BaseConfig {
751
830
  tsconfigRaw?: TSConfig;
752
831
  }
753
832
  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
833
  /**
786
834
  * Configuration options for the preview server
787
835
  */
@@ -854,14 +902,26 @@ interface CommonUserConfig extends BaseConfig {
854
902
  */
855
903
  framework?: string;
856
904
  }
857
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
858
- build?: TBuildConfig & {
905
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = Omit<CommonUserConfig, "build"> & {
906
+ /**
907
+ * Configuration provided to build processes
908
+ *
909
+ * @remarks
910
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
911
+ */
912
+ build: Omit<TBuildConfig, "override"> & {
859
913
  /**
860
914
  * The build variant being used by the Powerlines engine.
861
915
  */
862
916
  variant?: TBuildVariant;
917
+ /**
918
+ * An optional set of override options to apply to the selected build variant.
919
+ *
920
+ * @remarks
921
+ * 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.
922
+ */
923
+ override?: Partial<TBuildResolvedConfig>;
863
924
  };
864
- override?: Partial<TBuildResolvedConfig>;
865
925
  };
866
926
  type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
867
927
  /**
@@ -885,7 +945,7 @@ interface ResolvedEntryTypeDefinition extends TypeDefinition {
885
945
  output?: string;
886
946
  }
887
947
  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">> & {
948
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr">> & {
889
949
  /**
890
950
  * The name of the environment
891
951
  */
@@ -902,7 +962,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
902
962
  /**
903
963
  * The resolved options for the Powerlines project configuration.
904
964
  */
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">> & {
965
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "framework">> & {
906
966
  /**
907
967
  * The configuration options that were provided inline to the Powerlines CLI.
908
968
  */
@@ -933,6 +993,13 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
933
993
  * The output configuration options to use for the build process
934
994
  */
935
995
  output: OutputResolvedConfig;
996
+ /**
997
+ * Configuration provided to build processes
998
+ *
999
+ * @remarks
1000
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
1001
+ */
1002
+ build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
936
1003
  /**
937
1004
  * The log level to use for the Powerlines processes.
938
1005
  *
@@ -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
@@ -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-DNQSUN-t.cjs';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
@@ -1,5 +1,5 @@
1
1
  export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from './plugin.js';
2
- import '../plugin-BJKg0KaC.js';
2
+ import '../plugin-DNQSUN-t.js';
3
3
  import '@stryke/types/base';
4
4
  import 'unplugin';
5
5
  import '@stryke/types/array';
@@ -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-DNQSUN-t.cjs';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
@@ -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-DNQSUN-t.js';
2
2
  import '@stryke/types/base';
3
3
  import 'unplugin';
4
4
  import '@stryke/types/array';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-babel",
3
- "version": "0.12.17",
3
+ "version": "0.12.19",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
6
6
  "repository": {
@@ -136,7 +136,7 @@
136
136
  "@babel/helper-plugin-utils": "^7.27.1",
137
137
  "@babel/parser": "^7.28.5",
138
138
  "@babel/types": "^7.28.5",
139
- "@storm-software/config-tools": "^1.188.38",
139
+ "@storm-software/config-tools": "^1.188.40",
140
140
  "@stryke/fs": "^0.32.13",
141
141
  "@stryke/path": "^0.19.2",
142
142
  "@stryke/type-checks": "^0.3.12",
@@ -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.4",
147
+ "powerlines": "^0.20.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.8",
153
- "@powerlines/plugin-plugin": "^0.11.16",
152
+ "@powerlines/nx": "^0.10.10",
153
+ "@powerlines/plugin-plugin": "^0.11.18",
154
154
  "@types/node": "^22.19.1"
155
155
  },
156
156
  "publishConfig": { "access": "public" },
157
- "gitHead": "ab4911e45335c3ac4d162831f770181585c0d26f"
157
+ "gitHead": "e33924ab31dbf508b8983523edbaecffeebbee4f"
158
158
  }