@powerlines/plugin-vite 0.14.122 → 0.14.124

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 (141) hide show
  1. package/dist/helpers/index.cjs +3 -2
  2. package/dist/helpers/index.d.cts +3 -1
  3. package/dist/helpers/index.d.mts +3 -1
  4. package/dist/helpers/index.mjs +2 -1
  5. package/dist/helpers/unplugin.cjs +2 -11
  6. package/dist/helpers/unplugin.d.cts +2 -6
  7. package/dist/helpers/unplugin.d.mts +2 -6
  8. package/dist/helpers/unplugin.mjs +1 -9
  9. package/dist/helpers-CmEjzAn_.mjs +1 -0
  10. package/dist/helpers-LF26RHol.cjs +0 -0
  11. package/dist/index-BR1oNnaF.d.cts +1 -0
  12. package/dist/index-DEHBdV_z.d.mts +1 -0
  13. package/dist/index-_wQ5ClJU.d.cts +1 -0
  14. package/dist/index-vkGVyY9v.d.mts +1 -0
  15. package/dist/index.cjs +170 -9
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.mjs +165 -3
  19. package/dist/plugin-Dc12T6ZF.d.mts +1960 -0
  20. package/dist/plugin-jZ9N9Mz-.mjs +1 -0
  21. package/dist/plugin-pBKbb5K9.cjs +0 -0
  22. package/dist/plugin-vkCGh5de.d.cts +1957 -0
  23. package/dist/types/index.cjs +2 -0
  24. package/dist/types/index.d.cts +2 -1
  25. package/dist/types/index.d.mts +2 -1
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/types/internal.d.cts +191 -3
  28. package/dist/types/internal.d.mts +191 -3
  29. package/dist/types/plugin.cjs +1 -0
  30. package/dist/types/plugin.d.cts +1 -12
  31. package/dist/types/plugin.d.mts +1 -12
  32. package/dist/types/plugin.mjs +2 -0
  33. package/dist/types-BtDR9wb1.mjs +1 -0
  34. package/dist/types-o3zWarRp.cjs +0 -0
  35. package/dist/unplugin-B3TcDD6I.mjs +4617 -0
  36. package/dist/unplugin-Bv2agFkI.cjs +4661 -0
  37. package/dist/unplugin-D_zrAqRh.d.mts +7 -0
  38. package/dist/unplugin-F1UAxbOS.d.cts +7 -0
  39. package/package.json +5 -5
  40. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  41. package/dist/powerlines/schemas/fs.cjs +0 -226
  42. package/dist/powerlines/schemas/fs.mjs +0 -224
  43. package/dist/powerlines/src/api.cjs +0 -580
  44. package/dist/powerlines/src/api.mjs +0 -578
  45. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  46. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  47. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  48. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  49. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  50. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  51. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
  52. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -48
  53. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -50
  54. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
  55. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  56. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  57. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  58. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  59. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  60. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  61. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  62. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  63. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  64. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  65. package/dist/powerlines/src/lib/build/vite.cjs +0 -74
  66. package/dist/powerlines/src/lib/build/vite.mjs +0 -71
  67. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  68. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  69. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  70. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  71. package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
  72. package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
  73. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
  74. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
  75. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  76. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  77. package/dist/powerlines/src/lib/entry.cjs +0 -69
  78. package/dist/powerlines/src/lib/entry.mjs +0 -67
  79. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  80. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  81. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  82. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  83. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  84. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  85. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  86. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  87. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  88. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  89. package/dist/powerlines/src/lib/logger.cjs +0 -58
  90. package/dist/powerlines/src/lib/logger.mjs +0 -55
  91. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  92. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  93. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  94. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  95. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  96. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  97. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
  98. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
  99. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  100. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  101. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  102. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  103. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  104. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  105. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  106. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  107. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  108. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  109. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
  110. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
  111. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  112. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  113. package/dist/powerlines/src/types/api.d.cts +0 -104
  114. package/dist/powerlines/src/types/api.d.mts +0 -104
  115. package/dist/powerlines/src/types/babel.d.mts +0 -4
  116. package/dist/powerlines/src/types/build.cjs +0 -15
  117. package/dist/powerlines/src/types/build.d.cts +0 -154
  118. package/dist/powerlines/src/types/build.d.mts +0 -154
  119. package/dist/powerlines/src/types/build.mjs +0 -14
  120. package/dist/powerlines/src/types/commands.cjs +0 -16
  121. package/dist/powerlines/src/types/commands.d.cts +0 -8
  122. package/dist/powerlines/src/types/commands.d.mts +0 -9
  123. package/dist/powerlines/src/types/commands.mjs +0 -15
  124. package/dist/powerlines/src/types/config.d.cts +0 -416
  125. package/dist/powerlines/src/types/config.d.mts +0 -418
  126. package/dist/powerlines/src/types/context.d.cts +0 -514
  127. package/dist/powerlines/src/types/context.d.mts +0 -514
  128. package/dist/powerlines/src/types/fs.d.cts +0 -486
  129. package/dist/powerlines/src/types/fs.d.mts +0 -486
  130. package/dist/powerlines/src/types/hooks.d.cts +0 -30
  131. package/dist/powerlines/src/types/hooks.d.mts +0 -30
  132. package/dist/powerlines/src/types/internal.d.cts +0 -58
  133. package/dist/powerlines/src/types/internal.d.mts +0 -58
  134. package/dist/powerlines/src/types/plugin.cjs +0 -32
  135. package/dist/powerlines/src/types/plugin.d.cts +0 -234
  136. package/dist/powerlines/src/types/plugin.d.mts +0 -234
  137. package/dist/powerlines/src/types/plugin.mjs +0 -31
  138. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  139. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  140. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  141. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -1,32 +0,0 @@
1
- const require_build = require('./build.cjs');
2
- const require_commands = require('./commands.cjs');
3
-
4
- //#region ../powerlines/src/types/plugin.ts
5
- const PLUGIN_NON_HOOK_FIELDS = [
6
- "name",
7
- "api",
8
- "enforce",
9
- "dedupe",
10
- "applyToEnvironment"
11
- ];
12
- const KNOWN_HOOKS = [
13
- ...require_commands.SUPPORTED_COMMANDS,
14
- "config",
15
- "configEnvironment",
16
- "configResolved",
17
- "buildStart",
18
- "buildEnd",
19
- "transform",
20
- "load",
21
- "resolveId",
22
- "writeBundle"
23
- ];
24
- const KNOWN_PLUGIN_FIELDS = [
25
- ...PLUGIN_NON_HOOK_FIELDS,
26
- ...KNOWN_HOOKS,
27
- ...require_build.UNPLUGIN_BUILD_VARIANTS
28
- ];
29
-
30
- //#endregion
31
- exports.KNOWN_HOOKS = KNOWN_HOOKS;
32
- exports.PLUGIN_NON_HOOK_FIELDS = PLUGIN_NON_HOOK_FIELDS;
@@ -1,234 +0,0 @@
1
- import { UnpluginBuildVariant } from "./build.cjs";
2
- import { CommandType } from "./commands.cjs";
3
- import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.cjs";
4
- import { EnvironmentConfig, PluginConfig } from "./config.cjs";
5
- import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
6
- import { FunctionLike, MaybePromise } from "@stryke/types/base";
7
- import { ExternalIdResult, HookFilter, TransformResult, UnpluginOptions } from "unplugin";
8
- import { ArrayValues } from "@stryke/types/array";
9
-
10
- //#region ../powerlines/src/types/plugin.d.ts
11
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
12
- /**
13
- * The order in which the plugin should be applied.
14
- */
15
- order?: "pre" | "post" | null | undefined;
16
- /**
17
- * A filter to determine when the hook should be called.
18
- */
19
- filter?: Pick<HookFilter, TFilter>;
20
- /**
21
- * The hook function to be called.
22
- */
23
- handler: THookFunction;
24
- }
25
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
26
- /**
27
- * A result returned by the plugin from the `types` hook that describes the declaration types output file.
28
- */
29
- interface TypesResult {
30
- directives?: string[];
31
- code: string;
32
- }
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>> {
36
- /**
37
- * A function that returns configuration options to be merged with the build context's options.
38
- *
39
- * @remarks
40
- * 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.
41
- *
42
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
43
- *
44
- * @see https://vitejs.dev/guide/api-plugin#config
45
- *
46
- * @param this - The build context.
47
- * @param config - The partial configuration object to be modified.
48
- * @returns A promise that resolves to a partial configuration object.
49
- */
50
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
51
- /**
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
- *
54
- * @remarks
55
- * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
56
- *
57
- * @see https://vitejs.dev/guide/api-plugin#configenvironment
58
- *
59
- * @param this - The build context.
60
- * @param name - The name of the environment being configured.
61
- * @param environment - The Vite-like environment object containing information about the current build environment.
62
- * @returns A promise that resolves when the hook is complete.
63
- */
64
- configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
65
- /**
66
- * A hook that is called when the plugin is resolved.
67
- *
68
- * @see https://vitejs.dev/guide/api-plugin#configresolved
69
- *
70
- * @param this - The build context.
71
- * @returns A promise that resolves when the hook is complete.
72
- */
73
- configResolved: (this: TContext) => MaybePromise<void>;
74
- /**
75
- * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
76
- *
77
- * @param this - The build context.
78
- * @param code - The source code to generate types for.
79
- * @returns A promise that resolves when the hook is complete.
80
- */
81
- types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
82
- /**
83
- * A hook that is called at the start of the build process.
84
- *
85
- * @param this - The build context and unplugin build context.
86
- * @returns A promise that resolves when the hook is complete.
87
- */
88
- buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
89
- /**
90
- * A hook that is called at the end of the build process.
91
- *
92
- * @param this - The build context and unplugin build context.
93
- * @returns A promise that resolves when the hook is complete.
94
- */
95
- buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
96
- /**
97
- * A hook that is called to transform the source code.
98
- *
99
- * @param this - The build context, unplugin build context, and unplugin context.
100
- * @param code - The source code to transform.
101
- * @param id - The identifier of the source code.
102
- * @returns A promise that resolves when the hook is complete.
103
- */
104
- transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
105
- /**
106
- * A hook that is called to load the source code.
107
- *
108
- * @param this - The build context, unplugin build context, and unplugin context.
109
- * @param id - The identifier of the source code.
110
- * @returns A promise that resolves when the hook is complete.
111
- */
112
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
113
- /**
114
- * A hook that is called to resolve the identifier of the source code.
115
- *
116
- * @param this - The build context, unplugin build context, and unplugin context.
117
- * @param id - The identifier of the source code.
118
- * @param importer - The importer of the source code.
119
- * @param options - The options for resolving the identifier.
120
- * @returns A promise that resolves when the hook is complete.
121
- */
122
- resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
123
- isEntry: boolean;
124
- }) => MaybePromise<string | ExternalIdResult | null | undefined>;
125
- /**
126
- * A hook that is called to write the bundle to disk.
127
- *
128
- * @param this - The build context.
129
- * @returns A promise that resolves when the hook is complete.
130
- */
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
- };
183
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
184
- interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
185
- /**
186
- * The name of the plugin, for use in deduplication, error messages and logs.
187
- */
188
- name: string;
189
- /**
190
- * An API object that can be used for inter-plugin communication.
191
- *
192
- * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
193
- */
194
- api?: Record<string, any>;
195
- /**
196
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
197
- *
198
- * @remarks
199
- * The Plugin invocation order is as follows:
200
- * - `enforce: 'pre'` plugins
201
- * - `order: 'pre'` plugin hooks
202
- * - any other plugins (normal)
203
- * - `order: 'post'` plugin hooks
204
- * - `enforce: 'post'` plugins
205
- *
206
- * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
207
- * @see https://rollupjs.org/plugin-development/#build-hooks
208
- * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
209
- * @see https://esbuild.github.io/plugins/#concepts
210
- */
211
- enforce?: "pre" | "post";
212
- /**
213
- * A function to determine if two plugins are the same and can be de-duplicated.
214
- *
215
- * @remarks
216
- * If this is not provided, plugins are de-duplicated by comparing their names.
217
- *
218
- * @param other - The other plugin to compare against.
219
- * @returns `true` if the two plugins are the same, `false` otherwise.
220
- */
221
- dedupe?: false | ((other: Plugin<any>) => boolean);
222
- /**
223
- * A list of pre-requisite plugins that must be loaded before this plugin can be used.
224
- */
225
- /**
226
- * Define environments where this plugin should be active. By default, the plugin is active in all environments.
227
- *
228
- * @param environment - The environment to check.
229
- * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
230
- */
231
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
232
- }
233
- //#endregion
234
- export { BasePluginHookFunctions, ExternalPluginHookFunctions, Plugin, PluginHookFunctions, PluginHookObject };
@@ -1,234 +0,0 @@
1
- import { UnpluginBuildVariant } from "./build.mjs";
2
- import { CommandType } from "./commands.mjs";
3
- import { EnvironmentResolvedConfig, ResolvedConfig } from "./resolved.mjs";
4
- import { EnvironmentConfig, PluginConfig } from "./config.mjs";
5
- import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.mjs";
6
- import { ExternalIdResult, HookFilter, TransformResult, UnpluginOptions } from "unplugin";
7
- import { FunctionLike, MaybePromise } from "@stryke/types/base";
8
- import { ArrayValues } from "@stryke/types/array";
9
-
10
- //#region ../powerlines/src/types/plugin.d.ts
11
- interface PluginHookObject<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> {
12
- /**
13
- * The order in which the plugin should be applied.
14
- */
15
- order?: "pre" | "post" | null | undefined;
16
- /**
17
- * A filter to determine when the hook should be called.
18
- */
19
- filter?: Pick<HookFilter, TFilter>;
20
- /**
21
- * The hook function to be called.
22
- */
23
- handler: THookFunction;
24
- }
25
- type PluginHook<THookFunction extends FunctionLike, TFilter extends keyof HookFilter = never> = THookFunction | PluginHookObject<THookFunction, TFilter>;
26
- /**
27
- * A result returned by the plugin from the `types` hook that describes the declaration types output file.
28
- */
29
- interface TypesResult {
30
- directives?: string[];
31
- code: string;
32
- }
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>> {
36
- /**
37
- * A function that returns configuration options to be merged with the build context's options.
38
- *
39
- * @remarks
40
- * 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.
41
- *
42
- * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
43
- *
44
- * @see https://vitejs.dev/guide/api-plugin#config
45
- *
46
- * @param this - The build context.
47
- * @param config - The partial configuration object to be modified.
48
- * @returns A promise that resolves to a partial configuration object.
49
- */
50
- config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<ConfigResult<TContext>>;
51
- /**
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
- *
54
- * @remarks
55
- * This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
56
- *
57
- * @see https://vitejs.dev/guide/api-plugin#configenvironment
58
- *
59
- * @param this - The build context.
60
- * @param name - The name of the environment being configured.
61
- * @param environment - The Vite-like environment object containing information about the current build environment.
62
- * @returns A promise that resolves when the hook is complete.
63
- */
64
- configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
65
- /**
66
- * A hook that is called when the plugin is resolved.
67
- *
68
- * @see https://vitejs.dev/guide/api-plugin#configresolved
69
- *
70
- * @param this - The build context.
71
- * @returns A promise that resolves when the hook is complete.
72
- */
73
- configResolved: (this: TContext) => MaybePromise<void>;
74
- /**
75
- * A hook that is called to overwrite the generated declaration types file (.d.ts). The generated type definitions should describe the built-in modules/logic added during the `prepare` task.
76
- *
77
- * @param this - The build context.
78
- * @param code - The source code to generate types for.
79
- * @returns A promise that resolves when the hook is complete.
80
- */
81
- types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
82
- /**
83
- * A hook that is called at the start of the build process.
84
- *
85
- * @param this - The build context and unplugin build context.
86
- * @returns A promise that resolves when the hook is complete.
87
- */
88
- buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
89
- /**
90
- * A hook that is called at the end of the build process.
91
- *
92
- * @param this - The build context and unplugin build context.
93
- * @returns A promise that resolves when the hook is complete.
94
- */
95
- buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
96
- /**
97
- * A hook that is called to transform the source code.
98
- *
99
- * @param this - The build context, unplugin build context, and unplugin context.
100
- * @param code - The source code to transform.
101
- * @param id - The identifier of the source code.
102
- * @returns A promise that resolves when the hook is complete.
103
- */
104
- transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
105
- /**
106
- * A hook that is called to load the source code.
107
- *
108
- * @param this - The build context, unplugin build context, and unplugin context.
109
- * @param id - The identifier of the source code.
110
- * @returns A promise that resolves when the hook is complete.
111
- */
112
- load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
113
- /**
114
- * A hook that is called to resolve the identifier of the source code.
115
- *
116
- * @param this - The build context, unplugin build context, and unplugin context.
117
- * @param id - The identifier of the source code.
118
- * @param importer - The importer of the source code.
119
- * @param options - The options for resolving the identifier.
120
- * @returns A promise that resolves when the hook is complete.
121
- */
122
- resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
123
- isEntry: boolean;
124
- }) => MaybePromise<string | ExternalIdResult | null | undefined>;
125
- /**
126
- * A hook that is called to write the bundle to disk.
127
- *
128
- * @param this - The build context.
129
- * @returns A promise that resolves when the hook is complete.
130
- */
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
- };
183
- type PluginBuildPlugins<TContext extends PluginContext = PluginContext> = { [TBuildVariant in UnpluginBuildVariant]?: BuildPlugin<TContext, TBuildVariant> };
184
- interface Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> extends Partial<PluginHooks<TContext>>, PluginBuildPlugins<TContext> {
185
- /**
186
- * The name of the plugin, for use in deduplication, error messages and logs.
187
- */
188
- name: string;
189
- /**
190
- * An API object that can be used for inter-plugin communication.
191
- *
192
- * @see https://rollupjs.org/plugin-development/#direct-plugin-communication
193
- */
194
- api?: Record<string, any>;
195
- /**
196
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
197
- *
198
- * @remarks
199
- * The Plugin invocation order is as follows:
200
- * - `enforce: 'pre'` plugins
201
- * - `order: 'pre'` plugin hooks
202
- * - any other plugins (normal)
203
- * - `order: 'post'` plugin hooks
204
- * - `enforce: 'post'` plugins
205
- *
206
- * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
207
- * @see https://rollupjs.org/plugin-development/#build-hooks
208
- * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
209
- * @see https://esbuild.github.io/plugins/#concepts
210
- */
211
- enforce?: "pre" | "post";
212
- /**
213
- * A function to determine if two plugins are the same and can be de-duplicated.
214
- *
215
- * @remarks
216
- * If this is not provided, plugins are de-duplicated by comparing their names.
217
- *
218
- * @param other - The other plugin to compare against.
219
- * @returns `true` if the two plugins are the same, `false` otherwise.
220
- */
221
- dedupe?: false | ((other: Plugin<any>) => boolean);
222
- /**
223
- * A list of pre-requisite plugins that must be loaded before this plugin can be used.
224
- */
225
- /**
226
- * Define environments where this plugin should be active. By default, the plugin is active in all environments.
227
- *
228
- * @param environment - The environment to check.
229
- * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
230
- */
231
- applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
232
- }
233
- //#endregion
234
- export { BasePluginHookFunctions, ExternalPluginHookFunctions, Plugin, PluginHookFunctions, PluginHookObject };
@@ -1,31 +0,0 @@
1
- import { UNPLUGIN_BUILD_VARIANTS } from "./build.mjs";
2
- import { SUPPORTED_COMMANDS } from "./commands.mjs";
3
-
4
- //#region ../powerlines/src/types/plugin.ts
5
- const PLUGIN_NON_HOOK_FIELDS = [
6
- "name",
7
- "api",
8
- "enforce",
9
- "dedupe",
10
- "applyToEnvironment"
11
- ];
12
- const KNOWN_HOOKS = [
13
- ...SUPPORTED_COMMANDS,
14
- "config",
15
- "configEnvironment",
16
- "configResolved",
17
- "buildStart",
18
- "buildEnd",
19
- "transform",
20
- "load",
21
- "resolveId",
22
- "writeBundle"
23
- ];
24
- const KNOWN_PLUGIN_FIELDS = [
25
- ...PLUGIN_NON_HOOK_FIELDS,
26
- ...KNOWN_HOOKS,
27
- ...UNPLUGIN_BUILD_VARIANTS
28
- ];
29
-
30
- //#endregion
31
- export { KNOWN_HOOKS, PLUGIN_NON_HOOK_FIELDS };
@@ -1,82 +0,0 @@
1
- import { EnvironmentConfig, InlineConfig, OutputConfig, UserConfig as UserConfig$1, ViteUserConfig } from "./config.cjs";
2
- import { ResolvedPreviewOptions } from "vite";
3
- import { NonUndefined } from "@stryke/types/base";
4
- import { TypeDefinition } from "@stryke/types/configuration";
5
- import { AssetGlob } from "@stryke/types/file";
6
-
7
- //#region ../powerlines/src/types/resolved.d.ts
8
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
9
- /**
10
- * The user provided entry point in the source code
11
- */
12
- input?: TypeDefinition;
13
- /**
14
- * An optional name to use in the package export during the build process
15
- */
16
- output?: string;
17
- }
18
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "ssr" | "preview"> & Required<Pick<EnvironmentConfig, "consumer" | "ssr">> & {
19
- /**
20
- * The name of the environment
21
- */
22
- name: string;
23
- /**
24
- * Configuration options for the preview server
25
- */
26
- preview?: ResolvedPreviewOptions;
27
- };
28
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
29
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets" | "storage"> & {
30
- assets: ResolvedAssetGlob[];
31
- }> & Pick<OutputConfig, "storage">;
32
- /**
33
- * The resolved options for the Powerlines project configuration.
34
- */
35
- type ResolvedConfig<TUserConfig extends UserConfig$1 = UserConfig$1> = Omit<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "variant" | "type" | "output" | "logLevel" | "framework" | "sourceRoot"> & Required<Pick<TUserConfig, "name" | "title" | "compatibilityDate" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "deploy" | "framework" | "sourceRoot">> & {
36
- /**
37
- * The configuration options that were provided inline to the Powerlines CLI.
38
- */
39
- inlineConfig: InlineConfig<TUserConfig>;
40
- /**
41
- * The original configuration options that were provided by the user to the Powerlines process.
42
- */
43
- userConfig: TUserConfig;
44
- /**
45
- * A string identifier for the Powerlines command being executed.
46
- */
47
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
48
- /**
49
- * The root directory of the project's source code
50
- *
51
- * @defaultValue "\{projectRoot\}/src"
52
- */
53
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
54
- /**
55
- * The root directory of the project.
56
- */
57
- projectRoot: NonUndefined<TUserConfig["root"]>;
58
- /**
59
- * The type of project being built.
60
- */
61
- projectType: NonUndefined<TUserConfig["type"]>;
62
- /**
63
- * The output configuration options to use for the build process
64
- */
65
- output: OutputResolvedConfig;
66
- /**
67
- * Configuration provided to build processes
68
- *
69
- * @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
- */
72
- build: Omit<TUserConfig["build"], "override"> & Required<Pick<Required<TUserConfig["build"]>, "override">>;
73
- /**
74
- * The log level to use for the Powerlines processes.
75
- *
76
- * @defaultValue "info"
77
- */
78
- logLevel: "error" | "warn" | "info" | "debug" | "trace" | null;
79
- };
80
- type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
81
- //#endregion
82
- export { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition, ViteResolvedConfig };