@powerlines/plugin-vite 0.14.126 → 0.14.127
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.
- package/dist/powerlines/src/internal/helpers/hooks.cjs +15 -12
- package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -1
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -1
- package/dist/powerlines/src/internal/helpers/hooks.mjs +15 -12
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +108 -73
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +109 -74
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +13 -1
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +12 -1
- package/dist/powerlines/src/lib/unplugin/index.cjs +1 -1
- package/dist/powerlines/src/lib/unplugin/index.mjs +1 -1
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +3 -3
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +3 -3
- package/dist/powerlines/src/plugin-utils/helpers.cjs +34 -15
- package/dist/powerlines/src/plugin-utils/helpers.mjs +33 -15
- package/dist/powerlines/src/types/api.d.cts +4 -4
- package/dist/powerlines/src/types/api.d.mts +4 -4
- package/dist/powerlines/src/types/babel.d.mts +1 -1
- package/dist/powerlines/src/types/build.cjs +11 -3
- package/dist/powerlines/src/types/build.d.cts +34 -3
- package/dist/powerlines/src/types/build.d.mts +34 -3
- package/dist/powerlines/src/types/build.mjs +10 -3
- package/dist/powerlines/src/types/config.d.cts +14 -4
- package/dist/powerlines/src/types/config.d.mts +15 -5
- package/dist/powerlines/src/types/context.d.cts +9 -8
- package/dist/powerlines/src/types/context.d.mts +8 -7
- package/dist/powerlines/src/types/hooks.d.cts +25 -23
- package/dist/powerlines/src/types/hooks.d.mts +25 -23
- package/dist/powerlines/src/types/internal.d.cts +6 -4
- package/dist/powerlines/src/types/internal.d.mts +6 -4
- package/dist/powerlines/src/types/plugin.cjs +5 -4
- package/dist/powerlines/src/types/plugin.d.cts +36 -65
- package/dist/powerlines/src/types/plugin.d.mts +36 -65
- package/dist/powerlines/src/types/plugin.mjs +6 -5
- package/dist/powerlines/src/types/resolved.d.cts +16 -5
- package/dist/powerlines/src/types/resolved.d.mts +16 -6
- package/dist/powerlines/src/types/unplugin.d.cts +22 -0
- package/dist/powerlines/src/types/unplugin.d.mts +23 -0
- package/dist/types/plugin.d.cts +5 -1
- package/dist/types/plugin.d.mts +5 -1
- package/package.json +5 -5
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { UnpluginBuilderVariant } from "./build.cjs";
|
|
2
|
+
import { Plugin, PluginHookFields, PluginHookFunctions } from "./plugin.cjs";
|
|
3
|
+
import { PluginContext, WithUnpluginBuildContext } from "./context.cjs";
|
|
4
|
+
import { UnpluginOptions } from "unplugin";
|
|
3
5
|
|
|
4
6
|
//#region ../powerlines/src/types/hooks.d.ts
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
interface
|
|
7
|
+
type HookListOrders = "preOrdered" | "preEnforced" | "normal" | "postEnforced" | "postOrdered";
|
|
8
|
+
type UnpluginHookFunctions<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> = Required<UnpluginOptions>[TUnpluginBuilderVariant$1][TField$1] extends infer THandler | {
|
|
9
|
+
handler: infer THandler;
|
|
10
|
+
} ? THandler extends ((this: infer THandlerOriginalContext, ...args: infer THandlerArgs) => infer THandlerReturn) ? (this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerArgs) => THandlerReturn : THandler extends {
|
|
11
|
+
handler: infer THandlerFunction;
|
|
12
|
+
} ? THandlerFunction extends ((this: infer THandlerFunctionOriginalContext, ...args: infer THandlerFunctionArgs) => infer THandlerFunctionReturn) ? (this: THandlerFunctionOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerFunctionArgs) => THandlerFunctionReturn : never : never : never;
|
|
13
|
+
interface PluginHooksListItem<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> {
|
|
12
14
|
plugin: Plugin<TContext>;
|
|
15
|
+
handler: PluginHookFunctions<TContext>[TFields];
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
preEnforced?: BaseHooksListItem<TContext, TKey$1>[];
|
|
17
|
-
normal?: BaseHooksListItem<TContext, TKey$1>[];
|
|
18
|
-
postEnforced?: BaseHooksListItem<TContext, TKey$1>[];
|
|
19
|
-
postOrdered?: BaseHooksListItem<TContext, TKey$1>[];
|
|
20
|
-
}
|
|
21
|
-
interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey$1 extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
|
|
17
|
+
type PluginHooksList<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> = { [TKey in HookListOrders]?: PluginHooksListItem<TContext, TFields>[] | undefined };
|
|
18
|
+
interface UnpluginHooksListItem<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> {
|
|
22
19
|
plugin: Plugin<TContext>;
|
|
23
|
-
handler:
|
|
20
|
+
handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant$1, TField$1>;
|
|
24
21
|
}
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
22
|
+
type UnpluginHookList<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof UnpluginOptions[TUnpluginBuilderVariant$1] = keyof UnpluginOptions[TUnpluginBuilderVariant$1]> = { [TKey in HookListOrders]?: UnpluginHooksListItem<TContext, TUnpluginBuilderVariant$1, TField$1>[] | undefined };
|
|
23
|
+
type UnpluginHookVariantField<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant> = { [TKey in keyof UnpluginOptions[TUnpluginBuilderVariant$1]]?: UnpluginHookList<TContext, TUnpluginBuilderVariant$1, TKey> };
|
|
24
|
+
type UnpluginHookVariant<TContext extends PluginContext = PluginContext> = { [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey> };
|
|
25
|
+
type HookFields<TContext extends PluginContext = PluginContext> = PluginHookFields<TContext> | UnpluginBuilderVariant;
|
|
26
|
+
type HooksList<TContext extends PluginContext = PluginContext> = { [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext> ? PluginHooksList<TContext, TField> : TField extends UnpluginBuilderVariant ? UnpluginHookVariant<TContext>[TField] : never };
|
|
27
|
+
type InferHooksListItem<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHooksListItem<TContext, TKey$1> : never;
|
|
28
|
+
type InferHookFunction<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHookFunctions<TContext>[TKey$1] : never;
|
|
29
|
+
type InferHookReturnType<TContext extends PluginContext, TKey$1 extends string> = ReturnType<InferHookFunction<TContext, TKey$1>>;
|
|
30
|
+
type InferHookParameters<TContext extends PluginContext, TKey$1 extends string> = Parameters<InferHookFunction<TContext, TKey$1>>;
|
|
29
31
|
//#endregion
|
|
30
|
-
export {
|
|
32
|
+
export { HooksList, InferHookParameters, InferHookReturnType, InferHooksListItem };
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { UnpluginBuilderVariant } from "./build.mjs";
|
|
2
|
+
import { Plugin, PluginHookFields, PluginHookFunctions } from "./plugin.mjs";
|
|
3
|
+
import { PluginContext, WithUnpluginBuildContext } from "./context.mjs";
|
|
4
|
+
import { UnpluginOptions } from "unplugin";
|
|
3
5
|
|
|
4
6
|
//#region ../powerlines/src/types/hooks.d.ts
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
interface
|
|
7
|
+
type HookListOrders = "preOrdered" | "preEnforced" | "normal" | "postEnforced" | "postOrdered";
|
|
8
|
+
type UnpluginHookFunctions<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> = Required<UnpluginOptions>[TUnpluginBuilderVariant$1][TField$1] extends infer THandler | {
|
|
9
|
+
handler: infer THandler;
|
|
10
|
+
} ? THandler extends ((this: infer THandlerOriginalContext, ...args: infer THandlerArgs) => infer THandlerReturn) ? (this: THandlerOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerArgs) => THandlerReturn : THandler extends {
|
|
11
|
+
handler: infer THandlerFunction;
|
|
12
|
+
} ? THandlerFunction extends ((this: infer THandlerFunctionOriginalContext, ...args: infer THandlerFunctionArgs) => infer THandlerFunctionReturn) ? (this: THandlerFunctionOriginalContext & WithUnpluginBuildContext<TContext>, ...args: THandlerFunctionArgs) => THandlerFunctionReturn : never : never : never;
|
|
13
|
+
interface PluginHooksListItem<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> {
|
|
12
14
|
plugin: Plugin<TContext>;
|
|
15
|
+
handler: PluginHookFunctions<TContext>[TFields];
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
preEnforced?: BaseHooksListItem<TContext, TKey$1>[];
|
|
17
|
-
normal?: BaseHooksListItem<TContext, TKey$1>[];
|
|
18
|
-
postEnforced?: BaseHooksListItem<TContext, TKey$1>[];
|
|
19
|
-
postOrdered?: BaseHooksListItem<TContext, TKey$1>[];
|
|
20
|
-
}
|
|
21
|
-
interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey$1 extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
|
|
17
|
+
type PluginHooksList<TContext extends PluginContext = PluginContext, TFields extends PluginHookFields<TContext> = PluginHookFields<TContext>> = { [TKey in HookListOrders]?: PluginHooksListItem<TContext, TFields>[] | undefined };
|
|
18
|
+
interface UnpluginHooksListItem<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1] = keyof Required<UnpluginOptions>[TUnpluginBuilderVariant$1]> {
|
|
22
19
|
plugin: Plugin<TContext>;
|
|
23
|
-
handler:
|
|
20
|
+
handler: UnpluginHookFunctions<TContext, TUnpluginBuilderVariant$1, TField$1>;
|
|
24
21
|
}
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
22
|
+
type UnpluginHookList<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant, TField$1 extends keyof UnpluginOptions[TUnpluginBuilderVariant$1] = keyof UnpluginOptions[TUnpluginBuilderVariant$1]> = { [TKey in HookListOrders]?: UnpluginHooksListItem<TContext, TUnpluginBuilderVariant$1, TField$1>[] | undefined };
|
|
23
|
+
type UnpluginHookVariantField<TContext extends PluginContext = PluginContext, TUnpluginBuilderVariant$1 extends UnpluginBuilderVariant = UnpluginBuilderVariant> = { [TKey in keyof UnpluginOptions[TUnpluginBuilderVariant$1]]?: UnpluginHookList<TContext, TUnpluginBuilderVariant$1, TKey> };
|
|
24
|
+
type UnpluginHookVariant<TContext extends PluginContext = PluginContext> = { [TKey in UnpluginBuilderVariant]?: UnpluginHookVariantField<TContext, TKey> };
|
|
25
|
+
type HookFields<TContext extends PluginContext = PluginContext> = PluginHookFields<TContext> | UnpluginBuilderVariant;
|
|
26
|
+
type HooksList<TContext extends PluginContext = PluginContext> = { [TField in HookFields<TContext>]?: TField extends PluginHookFields<TContext> ? PluginHooksList<TContext, TField> : TField extends UnpluginBuilderVariant ? UnpluginHookVariant<TContext>[TField] : never };
|
|
27
|
+
type InferHooksListItem<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHooksListItem<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHooksListItem<TContext, TKey$1> : never;
|
|
28
|
+
type InferHookFunction<TContext extends PluginContext, TKey$1 extends string> = TKey$1 extends `${infer TUnpluginBuilderVariant}:${infer TUnpluginField}` ? TUnpluginBuilderVariant extends UnpluginBuilderVariant ? TUnpluginField extends keyof Required<UnpluginOptions>[TUnpluginBuilderVariant] ? UnpluginHookFunctions<TContext, TUnpluginBuilderVariant, TUnpluginField> : never : never : TKey$1 extends keyof PluginHookFunctions<TContext> ? PluginHookFunctions<TContext>[TKey$1] : never;
|
|
29
|
+
type InferHookReturnType<TContext extends PluginContext, TKey$1 extends string> = ReturnType<InferHookFunction<TContext, TKey$1>>;
|
|
30
|
+
type InferHookParameters<TContext extends PluginContext, TKey$1 extends string> = Parameters<InferHookFunction<TContext, TKey$1>>;
|
|
29
31
|
//#endregion
|
|
30
|
-
export {
|
|
32
|
+
export { HooksList, InferHookParameters, InferHookReturnType, InferHooksListItem };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ResolvedConfig } from "./resolved.cjs";
|
|
2
|
-
import { PluginConfig } from "./config.cjs";
|
|
3
|
-
import { HookKeys, InferHookParameters, InferHookReturnType } from "./hooks.cjs";
|
|
4
|
-
import { EnvironmentContext, PluginContext } from "./context.cjs";
|
|
5
2
|
import { CallHookOptions } from "../internal/helpers/hooks.cjs";
|
|
6
3
|
import { API } from "./api.cjs";
|
|
4
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.cjs";
|
|
5
|
+
import { EnvironmentContext, PluginContext } from "./context.cjs";
|
|
6
|
+
import { PluginConfig } from "./config.cjs";
|
|
7
7
|
|
|
8
8
|
//#region ../powerlines/src/types/internal.d.ts
|
|
9
9
|
|
|
@@ -44,7 +44,9 @@ interface UNSAFE_EnvironmentContext<TResolvedConfig extends ResolvedConfig = Res
|
|
|
44
44
|
interface UNSAFE_PluginContextInternal<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends UNSAFE_ContextInternal<TResolvedConfig> {
|
|
45
45
|
api: API<TResolvedConfig>;
|
|
46
46
|
environment: UNSAFE_EnvironmentContext<TResolvedConfig>;
|
|
47
|
-
callHook: <TKey extends
|
|
47
|
+
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
48
|
+
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
49
|
+
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* An internal representation of the plugin context, used for managing hooks and environment data.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ResolvedConfig } from "./resolved.mjs";
|
|
2
|
-
import { PluginConfig } from "./config.mjs";
|
|
3
|
-
import { HookKeys, InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
4
|
-
import { EnvironmentContext, PluginContext } from "./context.mjs";
|
|
5
2
|
import { CallHookOptions } from "../internal/helpers/hooks.mjs";
|
|
6
3
|
import { API } from "./api.mjs";
|
|
4
|
+
import { InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
5
|
+
import { EnvironmentContext, PluginContext } from "./context.mjs";
|
|
6
|
+
import { PluginConfig } from "./config.mjs";
|
|
7
7
|
|
|
8
8
|
//#region ../powerlines/src/types/internal.d.ts
|
|
9
9
|
|
|
@@ -44,7 +44,9 @@ interface UNSAFE_EnvironmentContext<TResolvedConfig extends ResolvedConfig = Res
|
|
|
44
44
|
interface UNSAFE_PluginContextInternal<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends UNSAFE_ContextInternal<TResolvedConfig> {
|
|
45
45
|
api: API<TResolvedConfig>;
|
|
46
46
|
environment: UNSAFE_EnvironmentContext<TResolvedConfig>;
|
|
47
|
-
callHook: <TKey extends
|
|
47
|
+
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
48
|
+
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
49
|
+
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* An internal representation of the plugin context, used for managing hooks and environment data.
|
|
@@ -9,11 +9,12 @@ const PLUGIN_NON_HOOK_FIELDS = [
|
|
|
9
9
|
"dedupe",
|
|
10
10
|
"applyToEnvironment"
|
|
11
11
|
];
|
|
12
|
-
const
|
|
12
|
+
const PLUGIN_HOOKS_FIELDS = [
|
|
13
13
|
...require_commands.SUPPORTED_COMMANDS,
|
|
14
14
|
"config",
|
|
15
15
|
"configEnvironment",
|
|
16
16
|
"configResolved",
|
|
17
|
+
"types",
|
|
17
18
|
"buildStart",
|
|
18
19
|
"buildEnd",
|
|
19
20
|
"transform",
|
|
@@ -23,10 +24,10 @@ const KNOWN_HOOKS = [
|
|
|
23
24
|
];
|
|
24
25
|
const KNOWN_PLUGIN_FIELDS = [
|
|
25
26
|
...PLUGIN_NON_HOOK_FIELDS,
|
|
26
|
-
...
|
|
27
|
-
...require_build.
|
|
27
|
+
...PLUGIN_HOOKS_FIELDS,
|
|
28
|
+
...require_build.BUILDER_VARIANTS
|
|
28
29
|
];
|
|
29
30
|
|
|
30
31
|
//#endregion
|
|
31
|
-
exports.
|
|
32
|
+
exports.PLUGIN_HOOKS_FIELDS = PLUGIN_HOOKS_FIELDS;
|
|
32
33
|
exports.PLUGIN_NON_HOOK_FIELDS = PLUGIN_NON_HOOK_FIELDS;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuilderVariant } from "./build.cjs";
|
|
2
2
|
import { CommandType } from "./commands.cjs";
|
|
3
3
|
import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.cjs";
|
|
4
|
-
import {
|
|
4
|
+
import { InferUnpluginOptions } from "./unplugin.cjs";
|
|
5
5
|
import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { EnvironmentConfig, PluginConfig } from "./config.cjs";
|
|
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
|
|
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
|
|
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
|
|
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<
|
|
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<
|
|
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,59 +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 ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant> = { [TKey in keyof BuildPlugin<TContext, TBuildVariant$1> & string as `${TBuildVariant$1}:${TKey}`]: BuildPlugin<TContext, TBuildVariant$1>[TKey] };
|
|
135
|
-
type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
|
|
136
|
-
type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
|
|
137
|
-
type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
|
|
138
|
-
/**
|
|
139
|
-
* A function that returns configuration options to be merged with the build context's options.
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* 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.
|
|
143
|
-
*
|
|
144
|
-
* @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.
|
|
145
|
-
*
|
|
146
|
-
* @see https://vitejs.dev/guide/api-plugin#config
|
|
147
|
-
*
|
|
148
|
-
* @param this - The build context.
|
|
149
|
-
* @param config - The partial configuration object to be modified.
|
|
150
|
-
* @returns A promise that resolves to a partial configuration object.
|
|
151
|
-
*/
|
|
152
|
-
config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
|
|
153
|
-
/**
|
|
154
|
-
* A hook that is called to transform the source code.
|
|
155
|
-
*
|
|
156
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
157
|
-
* @param code - The source code to transform.
|
|
158
|
-
* @param id - The identifier of the source code.
|
|
159
|
-
* @returns A promise that resolves when the hook is complete.
|
|
160
|
-
*/
|
|
161
|
-
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
|
|
162
|
-
/**
|
|
163
|
-
* A hook that is called to load the source code.
|
|
164
|
-
*
|
|
165
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
166
|
-
* @param id - The identifier of the source code.
|
|
167
|
-
* @returns A promise that resolves when the hook is complete.
|
|
168
|
-
*/
|
|
169
|
-
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
|
|
170
|
-
/**
|
|
171
|
-
* A hook that is called to resolve the identifier of the source code.
|
|
172
|
-
*
|
|
173
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
174
|
-
* @param id - The identifier of the source code.
|
|
175
|
-
* @param importer - The importer of the source code.
|
|
176
|
-
* @param options - The options for resolving the identifier.
|
|
177
|
-
* @returns A promise that resolves when the hook is complete.
|
|
178
|
-
*/
|
|
179
|
-
resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
|
|
180
|
-
isEntry: boolean;
|
|
181
|
-
}) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
|
|
182
132
|
};
|
|
183
|
-
type
|
|
184
|
-
|
|
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>> & {
|
|
185
140
|
/**
|
|
186
141
|
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
187
142
|
*/
|
|
@@ -229,6 +184,22 @@ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<
|
|
|
229
184
|
* @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
|
|
230
185
|
*/
|
|
231
186
|
applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
|
|
232
|
-
|
|
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>;
|
|
233
204
|
//#endregion
|
|
234
|
-
export {
|
|
205
|
+
export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuilderVariant } from "./build.mjs";
|
|
2
2
|
import { CommandType } from "./commands.mjs";
|
|
3
3
|
import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { InferUnpluginOptions } from "./unplugin.mjs";
|
|
5
5
|
import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { EnvironmentConfig, PluginConfig } from "./config.mjs";
|
|
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
|
|
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
|
|
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
|
|
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<
|
|
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<
|
|
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,59 +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 ExternalPluginHookFunctionsVariant<TContext extends PluginContext = PluginContext, TBuildVariant$1 extends UnpluginBuildVariant = UnpluginBuildVariant> = { [TKey in keyof BuildPlugin<TContext, TBuildVariant$1> & string as `${TBuildVariant$1}:${TKey}`]: BuildPlugin<TContext, TBuildVariant$1>[TKey] };
|
|
135
|
-
type ExternalPluginHookFunctions<TContext extends PluginContext> = ExternalPluginHookFunctionsVariant<TContext, "vite"> & ExternalPluginHookFunctionsVariant<TContext, "esbuild"> & ExternalPluginHookFunctionsVariant<TContext, "rolldown"> & ExternalPluginHookFunctionsVariant<TContext, "rollup"> & ExternalPluginHookFunctionsVariant<TContext, "webpack"> & ExternalPluginHookFunctionsVariant<TContext, "rspack"> & ExternalPluginHookFunctionsVariant<TContext, "farm">;
|
|
136
|
-
type PluginHookFunctions<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext> & ExternalPluginHookFunctions<TContext>;
|
|
137
|
-
type PluginHooks<TContext extends PluginContext = PluginContext> = { [TKey in keyof BasePluginHookFunctions<TContext>]: PluginHook<BasePluginHookFunctions<TContext>[TKey]> } & {
|
|
138
|
-
/**
|
|
139
|
-
* A function that returns configuration options to be merged with the build context's options.
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* 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.
|
|
143
|
-
*
|
|
144
|
-
* @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.
|
|
145
|
-
*
|
|
146
|
-
* @see https://vitejs.dev/guide/api-plugin#config
|
|
147
|
-
*
|
|
148
|
-
* @param this - The build context.
|
|
149
|
-
* @param config - The partial configuration object to be modified.
|
|
150
|
-
* @returns A promise that resolves to a partial configuration object.
|
|
151
|
-
*/
|
|
152
|
-
config: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>> | ConfigResult<TContext>;
|
|
153
|
-
/**
|
|
154
|
-
* A hook that is called to transform the source code.
|
|
155
|
-
*
|
|
156
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
157
|
-
* @param code - The source code to transform.
|
|
158
|
-
* @param id - The identifier of the source code.
|
|
159
|
-
* @returns A promise that resolves when the hook is complete.
|
|
160
|
-
*/
|
|
161
|
-
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
|
|
162
|
-
/**
|
|
163
|
-
* A hook that is called to load the source code.
|
|
164
|
-
*
|
|
165
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
166
|
-
* @param id - The identifier of the source code.
|
|
167
|
-
* @returns A promise that resolves when the hook is complete.
|
|
168
|
-
*/
|
|
169
|
-
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
|
|
170
|
-
/**
|
|
171
|
-
* A hook that is called to resolve the identifier of the source code.
|
|
172
|
-
*
|
|
173
|
-
* @param this - The build context, unplugin build context, and unplugin context.
|
|
174
|
-
* @param id - The identifier of the source code.
|
|
175
|
-
* @param importer - The importer of the source code.
|
|
176
|
-
* @param options - The options for resolving the identifier.
|
|
177
|
-
* @returns A promise that resolves when the hook is complete.
|
|
178
|
-
*/
|
|
179
|
-
resolveId: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
|
|
180
|
-
isEntry: boolean;
|
|
181
|
-
}) => MaybePromise<string | ExternalIdResult | null | undefined>, "id">;
|
|
182
132
|
};
|
|
183
|
-
type
|
|
184
|
-
|
|
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>> & {
|
|
185
140
|
/**
|
|
186
141
|
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
187
142
|
*/
|
|
@@ -229,6 +184,22 @@ interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<
|
|
|
229
184
|
* @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
|
|
230
185
|
*/
|
|
231
186
|
applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
|
|
232
|
-
|
|
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>;
|
|
233
204
|
//#endregion
|
|
234
|
-
export {
|
|
205
|
+
export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
-
...
|
|
27
|
-
...
|
|
27
|
+
...PLUGIN_HOOKS_FIELDS,
|
|
28
|
+
...BUILDER_VARIANTS
|
|
28
29
|
];
|
|
29
30
|
|
|
30
31
|
//#endregion
|
|
31
|
-
export {
|
|
32
|
+
export { PLUGIN_HOOKS_FIELDS, PLUGIN_NON_HOOK_FIELDS };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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$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
|
+
type ResolvedConfig$1<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$1 = UserConfig$1> = Omit<TUse
|
|
|
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
|
|
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$1 = UserConfig$1> = Omit<TUse
|
|
|
77
78
|
*/
|
|
78
79
|
logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
|
|
79
80
|
};
|
|
80
|
-
type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
|
|
81
|
+
type ViteResolvedConfig = ResolvedConfig$1<ViteUserConfig>;
|
|
82
|
+
type WebpackResolvedConfig = ResolvedConfig$1<WebpackUserConfig>;
|
|
83
|
+
type RspackResolvedConfig = ResolvedConfig$1<RspackUserConfig>;
|
|
84
|
+
type ESBuildResolvedConfig = ResolvedConfig$1<ESBuildUserConfig>;
|
|
85
|
+
type RollupResolvedConfig = ResolvedConfig$1<RollupUserConfig>;
|
|
86
|
+
type RolldownResolvedConfig = ResolvedConfig$1<RolldownUserConfig>;
|
|
87
|
+
type TsupResolvedConfig = ResolvedConfig$1<TsupUserConfig>;
|
|
88
|
+
type TsdownResolvedConfig = ResolvedConfig$1<TsdownUserConfig>;
|
|
89
|
+
type UnbuildResolvedConfig = ResolvedConfig$1<UnbuildUserConfig>;
|
|
90
|
+
type FarmResolvedConfig = ResolvedConfig$1<FarmUserConfig>;
|
|
91
|
+
type InferResolvedConfig<TBuildVariant extends BuilderVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig$1 : 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$1;
|
|
81
92
|
//#endregion
|
|
82
|
-
export { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, ViteResolvedConfig };
|
|
93
|
+
export { EnvironmentResolvedConfig, InferResolvedConfig, ResolvedConfig$1 as ResolvedConfig, ResolvedEntryTypeDefinition, ViteResolvedConfig };
|