@powerlines/plugin-webpack 0.5.134 → 0.5.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/powerlines/src/internal/helpers/hooks.cjs +15 -12
  2. package/dist/powerlines/src/internal/helpers/hooks.d.cts +47 -0
  3. package/dist/powerlines/src/internal/helpers/hooks.d.mts +49 -0
  4. package/dist/powerlines/src/internal/helpers/hooks.mjs +15 -12
  5. package/dist/powerlines/src/lib/contexts/environment-context.cjs +108 -73
  6. package/dist/powerlines/src/lib/contexts/environment-context.mjs +109 -74
  7. package/dist/powerlines/src/lib/unplugin/helpers.cjs +13 -1
  8. package/dist/powerlines/src/lib/unplugin/helpers.mjs +12 -1
  9. package/dist/powerlines/src/lib/unplugin/index.cjs +1 -1
  10. package/dist/powerlines/src/lib/unplugin/index.mjs +1 -1
  11. package/dist/powerlines/src/lib/unplugin/plugin.cjs +3 -3
  12. package/dist/powerlines/src/lib/unplugin/plugin.mjs +3 -3
  13. package/dist/powerlines/src/plugin-utils/helpers.cjs +34 -15
  14. package/dist/powerlines/src/plugin-utils/helpers.mjs +33 -15
  15. package/dist/powerlines/src/types/api.d.cts +104 -0
  16. package/dist/powerlines/src/types/api.d.mts +104 -0
  17. package/dist/powerlines/src/types/build.cjs +11 -3
  18. package/dist/powerlines/src/types/build.d.cts +39 -3
  19. package/dist/powerlines/src/types/build.d.mts +39 -3
  20. package/dist/powerlines/src/types/build.mjs +10 -3
  21. package/dist/powerlines/src/types/config.d.cts +60 -5
  22. package/dist/powerlines/src/types/config.d.mts +60 -6
  23. package/dist/powerlines/src/types/context.d.cts +113 -1
  24. package/dist/powerlines/src/types/context.d.mts +113 -3
  25. package/dist/powerlines/src/types/hooks.d.cts +32 -0
  26. package/dist/powerlines/src/types/hooks.d.mts +32 -2
  27. package/dist/powerlines/src/types/plugin.cjs +5 -4
  28. package/dist/powerlines/src/types/plugin.d.cts +35 -61
  29. package/dist/powerlines/src/types/plugin.d.mts +35 -61
  30. package/dist/powerlines/src/types/plugin.mjs +6 -5
  31. package/dist/powerlines/src/types/resolved.d.cts +15 -4
  32. package/dist/powerlines/src/types/resolved.d.mts +15 -5
  33. package/dist/powerlines/src/types/unplugin.d.cts +22 -0
  34. package/dist/powerlines/src/types/unplugin.d.mts +23 -0
  35. package/package.json +5 -5
@@ -1,14 +1,16 @@
1
- import { UnpluginBuildVariant } from "./build.cjs";
1
+ import { BuilderVariant } from "./build.cjs";
2
2
  import { CommandType } from "./commands.cjs";
3
3
  import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.cjs";
4
+ import { InferUnpluginOptions } from "./unplugin.cjs";
4
5
  import { EnvironmentConfig, PluginConfig } from "./config.cjs";
5
6
  import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
6
- import { FunctionLike, MaybePromise } from "@stryke/types/base";
7
- import { ExternalIdResult, HookFilter, TransformResult, UnpluginOptions } from "unplugin";
7
+ import { LoadResult } from "rollup";
8
+ import { AnyFunction, MaybePromise } from "@stryke/types/base";
9
+ import { ExternalIdResult, HookFilter, TransformResult } from "unplugin";
8
10
  import { ArrayValues } from "@stryke/types/array";
9
11
 
10
12
  //#region ../powerlines/src/types/plugin.d.ts
11
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
13
+ interface PluginHookObject<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> {
12
14
  /**
13
15
  * The order in which the plugin should be applied.
14
16
  */
@@ -22,7 +24,7 @@ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends k
22
24
  */
23
25
  handler: THookFunction;
24
26
  }
25
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
27
+ type PluginHook<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
26
28
  /**
27
29
  * A result returned by the plugin from the `types` hook that describes the declaration types output file.
28
30
  */
@@ -30,9 +32,7 @@ interface TypesResult {
30
32
  directives?: string[];
31
33
  code: string;
32
34
  }
33
- type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
34
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
35
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
35
+ type PluginHookFunctions<TContext extends PluginContext> = { [TCommandType in CommandType]: (this: TContext) => MaybePromise<void> } & {
36
36
  /**
37
37
  * A function that returns configuration options to be merged with the build context's options.
38
38
  *
@@ -47,7 +47,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
47
47
  * @param config - The partial configuration object to be modified.
48
48
  * @returns A promise that resolves to a partial configuration object.
49
49
  */
50
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
50
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>;
51
51
  /**
52
52
  * 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.
53
53
  *
@@ -109,7 +109,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
109
109
  * @param id - The identifier of the source code.
110
110
  * @returns A promise that resolves when the hook is complete.
111
111
  */
112
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
112
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<LoadResult>;
113
113
  /**
114
114
  * A hook that is called to resolve the identifier of the source code.
115
115
  *
@@ -129,56 +129,14 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
129
129
  * @returns A promise that resolves when the hook is complete.
130
130
  */
131
131
  writeBundle: (this: TContext) => MaybePromise<void>;
132
- }
133
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant$1] = Required<UnpluginOptions>[TBuildVariant$1]> = { [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey] };
134
- type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
135
- /**
136
- * A function that returns configuration options to be merged with the build context's options.
137
- *
138
- * @remarks
139
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
140
- *
141
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
142
- *
143
- * @see https://vitejs.dev/guide/api-plugin#config
144
- *
145
- * @param this - The build context.
146
- * @param config - The partial configuration object to be modified.
147
- * @returns A promise that resolves to a partial configuration object.
148
- */
149
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
150
- /**
151
- * A hook that is called to transform the source code.
152
- *
153
- * @param this - The build context, unplugin build context, and unplugin context.
154
- * @param code - The source code to transform.
155
- * @param id - The identifier of the source code.
156
- * @returns A promise that resolves when the hook is complete.
157
- */
158
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
159
- /**
160
- * A hook that is called to load the source code.
161
- *
162
- * @param this - The build context, unplugin build context, and unplugin context.
163
- * @param id - The identifier of the source code.
164
- * @returns A promise that resolves when the hook is complete.
165
- */
166
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
167
- /**
168
- * A hook that is called to resolve the identifier of the source code.
169
- *
170
- * @param this - The build context, unplugin build context, and unplugin context.
171
- * @param id - The identifier of the source code.
172
- * @param importer - The importer of the source code.
173
- * @param options - The options for resolving the identifier.
174
- * @returns A promise that resolves when the hook is complete.
175
- */
176
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
177
- isEntry: boolean;
178
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
179
132
  };
180
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
181
- interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
133
+ type PluginHooks<TContext extends PluginContext> = { [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<PluginHookFunctions<TContext>[TPluginHook]> } & {
134
+ transform: PluginHook<PluginHookFunctions<TContext>["transform"], "code" | "id">;
135
+ load: PluginHook<PluginHookFunctions<TContext>["load"], "id">;
136
+ resolveId: PluginHook<PluginHookFunctions<TContext>["resolveId"], "id">;
137
+ };
138
+ type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
139
+ type Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> = Partial<PluginHooks<TContext>> & {
182
140
  /**
183
141
  * The name of the plugin, for use in deduplication, error messages and logs.
184
142
  */
@@ -226,6 +184,22 @@ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<
226
184
  * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
227
185
  */
228
186
  applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
229
- }
187
+ /**
188
+ * A function that returns configuration options to be merged with the build context's options.
189
+ *
190
+ * @remarks
191
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
192
+ *
193
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
194
+ *
195
+ * @see https://vitejs.dev/guide/api-plugin#config
196
+ *
197
+ * @param this - The build context.
198
+ * @param config - The partial configuration object to be modified.
199
+ * @returns A promise that resolves to a partial configuration object.
200
+ */
201
+ config?: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>> | (DeepPartial<TContext["config"]> & Record<string, any>);
202
+ } & { [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<TContext, TBuilderVariant> };
203
+ type PluginHookFields<TContext extends PluginContext = PluginContext> = keyof PluginHookFunctions<TContext>;
230
204
  //#endregion
231
- export { Plugin };
205
+ export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions };
@@ -1,14 +1,16 @@
1
- import { UnpluginBuildVariant } from "./build.mjs";
1
+ import { BuilderVariant } from "./build.mjs";
2
2
  import { CommandType } from "./commands.mjs";
3
3
  import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.mjs";
4
+ import { InferUnpluginOptions } from "./unplugin.mjs";
4
5
  import { EnvironmentConfig, PluginConfig } from "./config.mjs";
5
6
  import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.mjs";
6
- import { ExternalIdResult, HookFilter, TransformResult, UnpluginOptions } from "unplugin";
7
- import { FunctionLike, MaybePromise } from "@stryke/types/base";
7
+ import { ExternalIdResult, HookFilter, TransformResult } from "unplugin";
8
+ import { LoadResult } from "rollup";
9
+ import { AnyFunction, MaybePromise } from "@stryke/types/base";
8
10
  import { ArrayValues } from "@stryke/types/array";
9
11
 
10
12
  //#region ../powerlines/src/types/plugin.d.ts
11
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
13
+ interface PluginHookObject<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> {
12
14
  /**
13
15
  * The order in which the plugin should be applied.
14
16
  */
@@ -22,7 +24,7 @@ interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends k
22
24
  */
23
25
  handler: THookFunction;
24
26
  }
25
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
27
+ type PluginHook<THookFunction extends AnyFunction, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
26
28
  /**
27
29
  * A result returned by the plugin from the `types` hook that describes the declaration types output file.
28
30
  */
@@ -30,9 +32,7 @@ interface TypesResult {
30
32
  directives?: string[];
31
33
  code: string;
32
34
  }
33
- type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
34
- type ConfigResult<TContext extends PluginContext = PluginContext> = DeepPartial<TContext["config"]> & Record<string, any>;
35
- interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext> extends Record<CommandType, (this: TContext) => MaybePromise<void>> {
35
+ type PluginHookFunctions<TContext extends PluginContext> = { [TCommandType in CommandType]: (this: TContext) => MaybePromise<void> } & {
36
36
  /**
37
37
  * A function that returns configuration options to be merged with the build context's options.
38
38
  *
@@ -47,7 +47,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
47
47
  * @param config - The partial configuration object to be modified.
48
48
  * @returns A promise that resolves to a partial configuration object.
49
49
  */
50
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
50
+ config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>;
51
51
  /**
52
52
  * 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.
53
53
  *
@@ -109,7 +109,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
109
109
  * @param id - The identifier of the source code.
110
110
  * @returns A promise that resolves when the hook is complete.
111
111
  */
112
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
112
+ load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<LoadResult>;
113
113
  /**
114
114
  * A hook that is called to resolve the identifier of the source code.
115
115
  *
@@ -129,56 +129,14 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
129
129
  * @returns A promise that resolves when the hook is complete.
130
130
  */
131
131
  writeBundle: (this: TContext) => MaybePromise<void>;
132
- }
133
- type BuildPlugin<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant, TOptions extends Required<UnpluginOptions>[TBuildVariant$1] = Required<UnpluginOptions>[TBuildVariant$1]> = { [TKey in keyof TOptions]: TOptions[TKey] extends FunctionLike ? (this: ThisParameterType<TOptions[TKey]> & TContext, ...args: Parameters<TOptions[TKey]>) => ReturnType<TOptions[TKey]> | MaybePromise<ReturnType<TOptions[TKey]>> : TOptions[TKey] };
134
- type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
135
- /**
136
- * A function that returns configuration options to be merged with the build context's options.
137
- *
138
- * @remarks
139
- * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
140
- *
141
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
142
- *
143
- * @see https://vitejs.dev/guide/api-plugin#config
144
- *
145
- * @param this - The build context.
146
- * @param config - The partial configuration object to be modified.
147
- * @returns A promise that resolves to a partial configuration object.
148
- */
149
- config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
150
- /**
151
- * A hook that is called to transform the source code.
152
- *
153
- * @param this - The build context, unplugin build context, and unplugin context.
154
- * @param code - The source code to transform.
155
- * @param id - The identifier of the source code.
156
- * @returns A promise that resolves when the hook is complete.
157
- */
158
- transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
159
- /**
160
- * A hook that is called to load the source code.
161
- *
162
- * @param this - The build context, unplugin build context, and unplugin context.
163
- * @param id - The identifier of the source code.
164
- * @returns A promise that resolves when the hook is complete.
165
- */
166
- load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
167
- /**
168
- * A hook that is called to resolve the identifier of the source code.
169
- *
170
- * @param this - The build context, unplugin build context, and unplugin context.
171
- * @param id - The identifier of the source code.
172
- * @param importer - The importer of the source code.
173
- * @param options - The options for resolving the identifier.
174
- * @returns A promise that resolves when the hook is complete.
175
- */
176
- resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
177
- isEntry: boolean;
178
- }) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
179
132
  };
180
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
181
- interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
133
+ type PluginHooks<TContext extends PluginContext> = { [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<PluginHookFunctions<TContext>[TPluginHook]> } & {
134
+ transform: PluginHook<PluginHookFunctions<TContext>["transform"], "code" | "id">;
135
+ load: PluginHook<PluginHookFunctions<TContext>["load"], "id">;
136
+ resolveId: PluginHook<PluginHookFunctions<TContext>["resolveId"], "id">;
137
+ };
138
+ type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
139
+ type Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> = Partial<PluginHooks<TContext>> & {
182
140
  /**
183
141
  * The name of the plugin, for use in deduplication, error messages and logs.
184
142
  */
@@ -226,6 +184,22 @@ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<
226
184
  * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
227
185
  */
228
186
  applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
229
- }
187
+ /**
188
+ * A function that returns configuration options to be merged with the build context's options.
189
+ *
190
+ * @remarks
191
+ * Modify config before it's resolved. The hook can either mutate {@link Context.config} on the passed-in context directly, or return a partial config object that will be deeply merged into existing config.
192
+ *
193
+ * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect. If you want to add plugins, consider doing so in the {@link Plugin.dependsOn} property instead.
194
+ *
195
+ * @see https://vitejs.dev/guide/api-plugin#config
196
+ *
197
+ * @param this - The build context.
198
+ * @param config - The partial configuration object to be modified.
199
+ * @returns A promise that resolves to a partial configuration object.
200
+ */
201
+ config?: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>> | (DeepPartial<TContext["config"]> & Record<string, any>);
202
+ } & { [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<TContext, TBuilderVariant> };
203
+ type PluginHookFields<TContext extends PluginContext = PluginContext> = keyof PluginHookFunctions<TContext>;
230
204
  //#endregion
231
- export { Plugin };
205
+ export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions };
@@ -1,4 +1,4 @@
1
- import { UNPLUGIN_BUILD_VARIANTS } from "./build.mjs";
1
+ import { BUILDER_VARIANTS } from "./build.mjs";
2
2
  import { SUPPORTED_COMMANDS } from "./commands.mjs";
3
3
 
4
4
  //#region ../powerlines/src/types/plugin.ts
@@ -9,11 +9,12 @@ const PLUGIN_NON_HOOK_FIELDS = [
9
9
  "dedupe",
10
10
  "applyToEnvironment"
11
11
  ];
12
- const KNOWN_HOOKS = [
12
+ const PLUGIN_HOOKS_FIELDS = [
13
13
  ...SUPPORTED_COMMANDS,
14
14
  "config",
15
15
  "configEnvironment",
16
16
  "configResolved",
17
+ "types",
17
18
  "buildStart",
18
19
  "buildEnd",
19
20
  "transform",
@@ -23,9 +24,9 @@ const KNOWN_HOOKS = [
23
24
  ];
24
25
  const KNOWN_PLUGIN_FIELDS = [
25
26
  ...PLUGIN_NON_HOOK_FIELDS,
26
- ...KNOWN_HOOKS,
27
- ...UNPLUGIN_BUILD_VARIANTS
27
+ ...PLUGIN_HOOKS_FIELDS,
28
+ ...BUILDER_VARIANTS
28
29
  ];
29
30
 
30
31
  //#endregion
31
- export { KNOWN_HOOKS, PLUGIN_NON_HOOK_FIELDS };
32
+ export { PLUGIN_HOOKS_FIELDS, PLUGIN_NON_HOOK_FIELDS };
@@ -1,4 +1,5 @@
1
- import { EnvironmentConfig, InlineConfig, OutputConfig, UserConfig, WebpackUserConfig } from "./config.cjs";
1
+ import { BuilderVariant } from "./build.cjs";
2
+ import { ESBuildUserConfig, EnvironmentConfig, FarmUserConfig, InlineConfig, OutputConfig, RolldownUserConfig, RollupUserConfig, RspackUserConfig, TsdownUserConfig, TsupUserConfig, UnbuildUserConfig, UserConfig as UserConfig$1, ViteUserConfig, WebpackUserConfig } from "./config.cjs";
2
3
  import { ResolvedPreviewOptions } from "vite";
3
4
  import { NonUndefined } from "@stryke/types/base";
4
5
  import { TypeDefinition } from "@stryke/types/configuration";
@@ -32,7 +33,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> &
32
33
  /**
33
34
  * The resolved options for the Powerlines project configuration.
34
35
  */
35
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
36
+ type ResolvedConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Omit<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
36
37
  /**
37
38
  * The configuration options that were provided inline to the Powerlines CLI.
38
39
  */
@@ -67,7 +68,7 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
67
68
  * Configuration provided to build processes
68
69
  *
69
70
  * @remarks
70
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
71
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuilderVariant | build variant}.
71
72
  */
72
73
  build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
73
74
  /**
@@ -77,6 +78,16 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
77
78
  */
78
79
  logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
79
80
  };
81
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
80
82
  type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
83
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
84
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
85
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
86
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
87
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
88
+ type TsdownResolvedConfig = ResolvedConfig<TsdownUserConfig>;
89
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
90
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
91
+ type InferResolvedConfig<TBuildVariant extends BuilderVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "tsdown" ? TsdownResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
81
92
  //#endregion
82
- export { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, WebpackResolvedConfig };
93
+ export { EnvironmentResolvedConfig, InferResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, WebpackResolvedConfig };
@@ -1,5 +1,5 @@
1
- import "./build.mjs";
2
- import { EnvironmentConfig, InlineConfig, OutputConfig, UserConfig, WebpackUserConfig } from "./config.mjs";
1
+ import { BuilderVariant } from "./build.mjs";
2
+ import { ESBuildUserConfig, EnvironmentConfig, FarmUserConfig, InlineConfig, OutputConfig, RolldownUserConfig, RollupUserConfig, RspackUserConfig, TsdownUserConfig, TsupUserConfig, UnbuildUserConfig, UserConfig as UserConfig$1, ViteUserConfig, WebpackUserConfig } from "./config.mjs";
3
3
  import { ResolvedPreviewOptions } from "vite";
4
4
  import { NonUndefined } from "@stryke/types/base";
5
5
  import { TypeDefinition } from "@stryke/types/configuration";
@@ -33,7 +33,7 @@ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> &
33
33
  /**
34
34
  * The resolved options for the Powerlines project configuration.
35
35
  */
36
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
36
+ type ResolvedConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Omit<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "organization" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
37
37
  /**
38
38
  * The configuration options that were provided inline to the Powerlines CLI.
39
39
  */
@@ -68,7 +68,7 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
68
68
  * Configuration provided to build processes
69
69
  *
70
70
  * @remarks
71
- * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuildVariant | build variant}.
71
+ * This configuration can be used by plugins during the `build` command. It will generally contain options specific to the selected {@link BuilderVariant | build variant}.
72
72
  */
73
73
  build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
74
74
  /**
@@ -78,6 +78,16 @@ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserCon
78
78
  */
79
79
  logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
80
80
  };
81
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
81
82
  type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
83
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
84
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
85
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
86
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
87
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
88
+ type TsdownResolvedConfig = ResolvedConfig<TsdownUserConfig>;
89
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
90
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
91
+ type InferResolvedConfig<TBuildVariant extends BuilderVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "tsdown" ? TsdownResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
82
92
  //#endregion
83
- export { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, WebpackResolvedConfig };
93
+ export { EnvironmentResolvedConfig, InferResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, WebpackResolvedConfig };
@@ -0,0 +1,22 @@
1
+ import { BuilderVariant, InferUnpluginVariant, UnpluginBuilderVariant } from "./build.cjs";
2
+ import { InferResolvedConfig } from "./resolved.cjs";
3
+ import { API } from "./api.cjs";
4
+ import { PluginHook } from "./plugin.cjs";
5
+ import { Context } from "./context.cjs";
6
+ import { MaybePromise } from "@stryke/types/base";
7
+ import { HookFilter, UnpluginOptions } from "unplugin";
8
+
9
+ //#region ../powerlines/src/types/unplugin.d.ts
10
+ interface UnpluginOptions$1<TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant> extends UnpluginOptions {
11
+ /**
12
+ * An API object that can be used for inter-plugin communication.
13
+ *
14
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
15
+ */
16
+ api: API<InferResolvedConfig<TUnpluginBuilderVariant>>;
17
+ }
18
+ type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] extends infer THandler | {
19
+ handler: infer THandler;
20
+ } ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] };
21
+ //#endregion
22
+ export { InferUnpluginOptions };
@@ -0,0 +1,23 @@
1
+ import { BuilderVariant, InferUnpluginVariant, UnpluginBuilderVariant } from "./build.mjs";
2
+ import { InferResolvedConfig } from "./resolved.mjs";
3
+ import { API } from "./api.mjs";
4
+ import { PluginHook } from "./plugin.mjs";
5
+ import "./config.mjs";
6
+ import { Context } from "./context.mjs";
7
+ import { HookFilter, UnpluginOptions } from "unplugin";
8
+ import { MaybePromise } from "@stryke/types/base";
9
+
10
+ //#region ../powerlines/src/types/unplugin.d.ts
11
+ interface UnpluginOptions$1<TUnpluginBuilderVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant> extends UnpluginOptions {
12
+ /**
13
+ * An API object that can be used for inter-plugin communication.
14
+ *
15
+ * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
16
+ */
17
+ api: API<InferResolvedConfig<TUnpluginBuilderVariant>>;
18
+ }
19
+ type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] extends infer THandler | {
20
+ handler: infer THandler;
21
+ } ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TUnpluginVariant>>[TUnpluginVariant][TKey] };
22
+ //#endregion
23
+ export { InferUnpluginOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-webpack",
3
- "version": "0.5.134",
3
+ "version": "0.5.135",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to build projects using Webpack.",
6
6
  "repository": {
@@ -151,14 +151,14 @@
151
151
  "@stryke/types": "^0.10.29",
152
152
  "defu": "^6.1.4",
153
153
  "jiti": "^2.6.1",
154
- "powerlines": "^0.36.29",
154
+ "powerlines": "^0.37.0",
155
155
  "webpack": "^5.104.1"
156
156
  },
157
157
  "devDependencies": {
158
- "@powerlines/nx": "^0.11.55",
159
- "@powerlines/plugin-plugin": "^0.12.77",
158
+ "@powerlines/nx": "^0.11.56",
159
+ "@powerlines/plugin-plugin": "^0.12.78",
160
160
  "@types/node": "^24.10.4"
161
161
  },
162
162
  "publishConfig": { "access": "public" },
163
- "gitHead": "bfbde2cda62a5307013bf11d1ef6a8500bcbc4b1"
163
+ "gitHead": "00141b82214ec2772cec7ec7873aba06f593289b"
164
164
  }