@powerlines/plugin-tsdown 0.1.243 → 0.1.244
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/core/src/lib/logger.mjs +40 -0
- package/dist/core/src/lib/logger.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/helpers.mjs +19 -0
- package/dist/core/src/lib/unplugin/helpers.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/index.mjs +5 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs +66 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/plugin.mjs +71 -0
- package/dist/core/src/lib/unplugin/plugin.mjs.map +1 -0
- package/dist/core/src/lib/utilities/format.mjs +29 -0
- package/dist/core/src/lib/utilities/format.mjs.map +1 -0
- package/dist/core/src/lib/utilities/source-file.mjs +21 -0
- package/dist/core/src/lib/utilities/source-file.mjs.map +1 -0
- package/dist/core/src/plugin-utils/build-helpers.mjs +35 -0
- package/dist/core/src/plugin-utils/build-helpers.mjs.map +1 -0
- package/dist/core/src/plugin-utils/context-helpers.mjs +4 -0
- package/dist/core/src/plugin-utils/extend.mjs +5 -0
- package/dist/core/src/plugin-utils/get-config-path.mjs +3 -0
- package/dist/core/src/plugin-utils/helpers.mjs +48 -0
- package/dist/core/src/plugin-utils/helpers.mjs.map +1 -0
- package/dist/core/src/plugin-utils/index.mjs +9 -0
- package/dist/core/src/plugin-utils/merge.mjs +47 -0
- package/dist/core/src/plugin-utils/merge.mjs.map +1 -0
- package/dist/core/src/plugin-utils/paths.mjs +4 -0
- package/dist/core/src/types/api.d.mts +103 -0
- package/dist/core/src/types/api.d.mts.map +1 -0
- package/dist/core/src/types/commands.d.mts +10 -0
- package/dist/core/src/types/commands.d.mts.map +1 -0
- package/dist/core/src/types/commands.mjs +16 -0
- package/dist/core/src/types/commands.mjs.map +1 -0
- package/dist/core/src/types/config.d.mts +551 -0
- package/dist/core/src/types/config.d.mts.map +1 -0
- package/dist/core/src/types/context.d.mts +511 -0
- package/dist/core/src/types/context.d.mts.map +1 -0
- package/dist/core/src/types/fs.d.mts +487 -0
- package/dist/core/src/types/fs.d.mts.map +1 -0
- package/dist/core/src/types/hooks.d.mts +99 -0
- package/dist/core/src/types/hooks.d.mts.map +1 -0
- package/dist/core/src/types/index.d.mts +9 -0
- package/dist/core/src/types/plugin.d.mts +204 -0
- package/dist/core/src/types/plugin.d.mts.map +1 -0
- package/dist/core/src/types/plugin.mjs +33 -0
- package/dist/core/src/types/plugin.mjs.map +1 -0
- package/dist/core/src/types/tsconfig.d.mts +70 -0
- package/dist/core/src/types/tsconfig.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.d.mts +25 -0
- package/dist/core/src/types/unplugin.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.mjs +22 -0
- package/dist/core/src/types/unplugin.mjs.map +1 -0
- package/dist/helpers/format-package-json.mjs +4 -4
- package/dist/helpers/format-package-json.mjs.map +1 -1
- package/dist/helpers/index.d.mts +3 -1
- package/dist/helpers/index.mjs +3 -1
- package/dist/helpers/resolve-options.d.mts +31 -0
- package/dist/helpers/resolve-options.d.mts.map +1 -0
- package/dist/helpers/resolve-options.mjs +124 -0
- package/dist/helpers/resolve-options.mjs.map +1 -0
- package/dist/helpers/unplugin.mjs +2 -1
- package/dist/helpers/unplugin.mjs.map +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -9
- package/dist/index.mjs.map +1 -1
- package/dist/types/build.d.mts +8 -0
- package/dist/types/build.d.mts.map +1 -0
- package/dist/types/build.mjs +1 -0
- package/dist/types/index.d.mts +2 -1
- package/dist/types/plugin.d.mts +11 -7
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +28 -107
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/helpers/format-package-json.cjs +0 -19
- package/dist/helpers/format-package-json.d.cts +0 -13
- package/dist/helpers/format-package-json.d.cts.map +0 -1
- package/dist/helpers/index.cjs +0 -3
- package/dist/helpers/index.d.cts +0 -2
- package/dist/helpers/unplugin.cjs +0 -11
- package/dist/helpers/unplugin.d.cts +0 -8
- package/dist/helpers/unplugin.d.cts.map +0 -1
- package/dist/index.cjs +0 -43
- package/dist/index.d.cts +0 -14
- package/dist/index.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/is-type.cjs +0 -28
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/is-type.mjs +0 -29
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/is-type.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.cjs +0 -122
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs +0 -123
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/join-paths.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/regex.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/regex.mjs +0 -9
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/regex.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/slash.cjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/slash.mjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_path@0.26.6/node_modules/@stryke/path/dist/slash.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-empty.cjs +0 -20
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-empty.mjs +0 -21
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-null.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-null.mjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-null.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set-string.cjs +0 -20
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set-string.mjs +0 -21
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set.cjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set.mjs +0 -20
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-set.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-string.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-string.mjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-string.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-undefined.cjs +0 -8
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-undefined.mjs +0 -8
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.25/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +0 -1
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +0 -2
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +0 -17
- package/dist/types/plugin.d.cts.map +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { CommandType } from "./commands.mjs";
|
|
2
|
+
import { BuilderVariant, InferUnpluginOptions } from "./unplugin.mjs";
|
|
3
|
+
import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.mjs";
|
|
4
|
+
import { EnvironmentConfig, EnvironmentResolvedConfig, PluginConfig, ResolvedConfig } from "./config.mjs";
|
|
5
|
+
import { ExternalIdResult, HookFilter, TransformResult } from "unplugin";
|
|
6
|
+
import { AnyFunction, MaybePromise } from "@stryke/types/base";
|
|
7
|
+
import { ArrayValues } from "@stryke/types/array";
|
|
8
|
+
import { LoadResult } from "rollup";
|
|
9
|
+
|
|
10
|
+
//#region ../core/src/types/plugin.d.ts
|
|
11
|
+
interface PluginHookObject<THookFunction extends AnyFunction, 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 AnyFunction, 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 PluginHookFunctions<TContext extends PluginContext> = { [TCommandType in CommandType]: (this: TContext) => MaybePromise<void> } & {
|
|
34
|
+
/**
|
|
35
|
+
* A function that returns configuration options to be merged with the build context's options.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* 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.
|
|
39
|
+
*
|
|
40
|
+
* @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
|
|
41
|
+
*
|
|
42
|
+
* @see https://vitejs.dev/guide/api-plugin#config
|
|
43
|
+
*
|
|
44
|
+
* @param this - The build context.
|
|
45
|
+
* @param config - The partial configuration object to be modified.
|
|
46
|
+
* @returns A promise that resolves to a partial configuration object.
|
|
47
|
+
*/
|
|
48
|
+
config: (this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>;
|
|
49
|
+
/**
|
|
50
|
+
* 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.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* 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.
|
|
54
|
+
*
|
|
55
|
+
* @see https://vitejs.dev/guide/api-plugin#configenvironment
|
|
56
|
+
*
|
|
57
|
+
* @param this - The build context.
|
|
58
|
+
* @param name - The name of the environment being configured.
|
|
59
|
+
* @param environment - The Vite-like environment object containing information about the current build environment.
|
|
60
|
+
* @returns A promise that resolves when the hook is complete.
|
|
61
|
+
*/
|
|
62
|
+
configEnvironment: (this: TContext, name: string, environment: EnvironmentConfig) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;
|
|
63
|
+
/**
|
|
64
|
+
* A hook that is called when the plugin is resolved.
|
|
65
|
+
*
|
|
66
|
+
* @see https://vitejs.dev/guide/api-plugin#configresolved
|
|
67
|
+
*
|
|
68
|
+
* @param this - The build context.
|
|
69
|
+
* @returns A promise that resolves when the hook is complete.
|
|
70
|
+
*/
|
|
71
|
+
configResolved: (this: TContext) => MaybePromise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* 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.
|
|
74
|
+
*
|
|
75
|
+
* @param this - The build context.
|
|
76
|
+
* @param code - The source code to generate types for.
|
|
77
|
+
* @returns A promise that resolves when the hook is complete.
|
|
78
|
+
*/
|
|
79
|
+
types: (this: TContext, code: string) => MaybePromise<TypesResult | string | undefined | null>;
|
|
80
|
+
/**
|
|
81
|
+
* A hook that is called at the start of the build process.
|
|
82
|
+
*
|
|
83
|
+
* @param this - The build context and unplugin build context.
|
|
84
|
+
* @returns A promise that resolves when the hook is complete.
|
|
85
|
+
*/
|
|
86
|
+
buildStart: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* A hook that is called at the end of the build process.
|
|
89
|
+
*
|
|
90
|
+
* @param this - The build context and unplugin build context.
|
|
91
|
+
* @returns A promise that resolves when the hook is complete.
|
|
92
|
+
*/
|
|
93
|
+
buildEnd: (this: BuildPluginContext<TContext["config"]> & TContext) => MaybePromise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* A hook that is called to transform the source code.
|
|
96
|
+
*
|
|
97
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
98
|
+
* @param code - The source code to transform.
|
|
99
|
+
* @param id - The identifier of the source code.
|
|
100
|
+
* @returns A promise that resolves when the hook is complete.
|
|
101
|
+
*/
|
|
102
|
+
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
|
|
103
|
+
/**
|
|
104
|
+
* A hook that is called to load the source code.
|
|
105
|
+
*
|
|
106
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
107
|
+
* @param id - The identifier of the source code.
|
|
108
|
+
* @returns A promise that resolves when the hook is complete.
|
|
109
|
+
*/
|
|
110
|
+
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<LoadResult>;
|
|
111
|
+
/**
|
|
112
|
+
* A hook that is called to resolve the identifier of the source code.
|
|
113
|
+
*
|
|
114
|
+
* @param this - The build context, unplugin build context, and unplugin context.
|
|
115
|
+
* @param id - The identifier of the source code.
|
|
116
|
+
* @param importer - The importer of the source code.
|
|
117
|
+
* @param options - The options for resolving the identifier.
|
|
118
|
+
* @returns A promise that resolves when the hook is complete.
|
|
119
|
+
*/
|
|
120
|
+
resolveId: (this: BuildPluginContext<TContext["config"]> & TContext, id: string, importer: string | undefined, options: {
|
|
121
|
+
isEntry: boolean;
|
|
122
|
+
}) => MaybePromise<string | ExternalIdResult | null | undefined>;
|
|
123
|
+
/**
|
|
124
|
+
* A hook that is called to write the bundle to disk.
|
|
125
|
+
*
|
|
126
|
+
* @param this - The build context.
|
|
127
|
+
* @returns A promise that resolves when the hook is complete.
|
|
128
|
+
*/
|
|
129
|
+
writeBundle: (this: TContext) => MaybePromise<void>;
|
|
130
|
+
};
|
|
131
|
+
type PluginHooks<TContext extends PluginContext> = { [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<PluginHookFunctions<TContext>[TPluginHook]> } & {
|
|
132
|
+
transform: PluginHook<PluginHookFunctions<TContext>["transform"], "code" | "id">;
|
|
133
|
+
load: PluginHook<PluginHookFunctions<TContext>["load"], "id">;
|
|
134
|
+
resolveId: PluginHook<PluginHookFunctions<TContext>["resolveId"], "id">;
|
|
135
|
+
};
|
|
136
|
+
type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
|
|
137
|
+
type Plugin<TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>> = Partial<PluginHooks<TContext>> & {
|
|
138
|
+
/**
|
|
139
|
+
* The name of the plugin, for use in deduplication, error messages and logs.
|
|
140
|
+
*/
|
|
141
|
+
name: string;
|
|
142
|
+
/**
|
|
143
|
+
* An API object that can be used for inter-plugin communication.
|
|
144
|
+
*
|
|
145
|
+
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
146
|
+
*/
|
|
147
|
+
api?: Record<string, any>;
|
|
148
|
+
/**
|
|
149
|
+
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* The Plugin invocation order is as follows:
|
|
153
|
+
* - `enforce: 'pre'` plugins
|
|
154
|
+
* - `order: 'pre'` plugin hooks
|
|
155
|
+
* - any other plugins (normal)
|
|
156
|
+
* - `order: 'post'` plugin hooks
|
|
157
|
+
* - `enforce: 'post'` plugins
|
|
158
|
+
*
|
|
159
|
+
* @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering
|
|
160
|
+
* @see https://rollupjs.org/plugin-development/#build-hooks
|
|
161
|
+
* @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post
|
|
162
|
+
* @see https://esbuild.github.io/plugins/#concepts
|
|
163
|
+
*/
|
|
164
|
+
enforce?: "pre" | "post";
|
|
165
|
+
/**
|
|
166
|
+
* A function to determine if two plugins are the same and can be de-duplicated.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* If this is not provided, plugins are de-duplicated by comparing their names.
|
|
170
|
+
*
|
|
171
|
+
* @param other - The other plugin to compare against.
|
|
172
|
+
* @returns `true` if the two plugins are the same, `false` otherwise.
|
|
173
|
+
*/
|
|
174
|
+
dedupe?: false | ((other: Plugin<any>) => boolean);
|
|
175
|
+
/**
|
|
176
|
+
* A list of pre-requisite plugins that must be loaded before this plugin can be used.
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Define environments where this plugin should be active. By default, the plugin is active in all environments.
|
|
180
|
+
*
|
|
181
|
+
* @param environment - The environment to check.
|
|
182
|
+
* @returns `true` if the plugin should be active in the specified environment, `false` otherwise.
|
|
183
|
+
*/
|
|
184
|
+
applyToEnvironment?: (environment: EnvironmentResolvedConfig) => boolean | PluginConfig<TContext>;
|
|
185
|
+
/**
|
|
186
|
+
* A function that returns configuration options to be merged with the build context's options.
|
|
187
|
+
*
|
|
188
|
+
* @remarks
|
|
189
|
+
* 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.
|
|
190
|
+
*
|
|
191
|
+
* @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.
|
|
192
|
+
*
|
|
193
|
+
* @see https://vitejs.dev/guide/api-plugin#config
|
|
194
|
+
*
|
|
195
|
+
* @param this - The build context.
|
|
196
|
+
* @param config - The partial configuration object to be modified.
|
|
197
|
+
* @returns A promise that resolves to a partial configuration object.
|
|
198
|
+
*/
|
|
199
|
+
config?: PluginHook<(this: UnresolvedContext<TContext["config"]>) => MaybePromise<DeepPartial<TContext["config"]> & Record<string, any>>> | (DeepPartial<TContext["config"]> & Record<string, any>);
|
|
200
|
+
} & { [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<TContext, TBuilderVariant> };
|
|
201
|
+
type PluginHookFields<TContext extends PluginContext = PluginContext> = keyof PluginHookFunctions<TContext>;
|
|
202
|
+
//#endregion
|
|
203
|
+
export { Plugin, PluginHook, PluginHookFields, PluginHookFunctions, PluginHookObject, PluginHooks, TypesResult };
|
|
204
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../../../../core/src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAsCiB,uCACO,mCACA;EAFP;;;EAYD,KAAA,CAAA,EAAA,KAAA,GAAA,MAAA,GAAA,IAAA,GAAA,SAAA;EAAY;;;EAKJ,MAAA,CAAA,EALb,IAKa,CALR,UAKQ,EALI,OAKJ,CAAA;EAGZ;;;EAGR,OAAA,EANO,aAMP;;AAAgD,KAHxC,UAGwC,CAAA,sBAF5B,WAE4B,EAAA,gBAAA,MAD5B,UAC4B,GAAA,KAAA,CAAA,GAAhD,aAAgD,GAAhC,gBAAgC,CAAf,aAAe,EAAA,OAAA,CAAA;;;AAKpD;AAKY,UALK,WAAA,CAKc;EAAkB,UAAA,CAAA,EAAA,MAAA,EAAA;EAC9B,IAAA,EAAA,MAAA;;AAAkC,KADzC,mBACyC,CAAA,iBADJ,aACI,CAAA,GAAA,mBAAlC,WAiBS,GAAA,CAAA,IAAA,EAjBY,QAiBZ,EAAA,GAjByB,YAiBzB,CAAA,IAAA,CAAA,EAAlB,GAAA;EACsB;;;;;;;;;;;;;;EAkDH,MAAA,EAAA,CAAA,IAAA,EAnDnB,iBAmDmB,CAnDD,QAmDC,CAAA,QAAA,CAAA,CAAA,EAAA,GAlDtB,YAkDsB,CAlDT,WAkDS,CAlDG,QAkDH,CAAA,QAAA,CAAA,CAAA,GAlDyB,MAkDzB,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA;EAAnB;;;;;;;;;;;;;EAmCA,iBAAA,EAAA,CAAA,IAAA,EArEA,QAqEA,EAAA,IAAA,EAAA,MAAA,EAAA,WAAA,EAnEO,iBAmEP,EAAA,GAlEH,YAkEG,CAlEU,OAkEV,CAlEkB,yBAkElB,CAAA,GAAA,SAAA,GAAA,IAAA,CAAA;EAAyC;;;;;;;;EA0B7B,cAAA,EAAA,CAAA,IAAA,EAlFG,QAkFH,EAAA,GAlFgB,YAkFhB,CAAA,IAAA,CAAA;EAAa;;AAGnC;;;;;EAEI,KAAA,EAAA,CAAA,IAAA,EA7EM,QA6EN,EAAA,IAAA,EAAA,MAAA,EAAA,GA3EG,YA2EH,CA3EgB,WA2EhB,GAAA,MAAA,GAAA,SAAA,GAAA,IAAA,CAAA;EAA8B;;;;;;EAOf,UAAA,EAAA,CAAA,IAAA,EAzET,kBAyES,CAzEU,QAyEV,CAAA,QAAA,CAAA,CAAA,GAzEgC,QAyEhC,EAAA,GAxEZ,YAwEY,CAAA,IAAA,CAAA;EAAX;;;;;AAEN;EAGY,QAAA,EAAA,CAAA,IAAA,EApEJ,kBAoEI,CApEe,QAoEf,CAAA,QAAA,CAAA,CAAA,GApEqC,QAoErC,EAAA,GAnEP,YAmEO,CAAA,IAAA,CAAA;EAAiB;;;;AAG/B;;;;EACmD,SAAA,EAAA,CAAA,IAAA,EA5DzC,kBA4DyC,CA5DtB,QA4DsB,CAAA,QAAA,CAAA,CAAA,GA5DA,QA4DA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,EAAA,MAAA,EAAA,GAzD5C,YAyD4C,CAzD/B,eAyD+B,CAAA;EAC3B;;;;;;;EAuDP,IAAA,EAAA,CAAA,IAAA,EAvGP,kBAuGO,CAvGY,QAuGZ,CAAA,QAAA,CAAA,CAAA,GAvGkC,QAuGlC,EAAA,EAAA,EAAA,MAAA,EAAA,GArGV,YAqGU,CArGG,UAqGH,CAAA;EAmBiB;;;;;;;;;EAGO,SAAA,EAAA,CAAA,IAAA,EA/G/B,kBA+G+B,CA/GZ,QA+GY,CAAA,QAAA,CAAA,CAAA,GA/GU,QA+GV,EAAA,EAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,GAAA,SAAA,EAAA,OAAA,EAAA;IAEnB,OAAA,EAAA,OAAA;EAClB,CAAA,EAAA,GA9GG,YA8GH,CAAA,MAAA,GA9GyB,gBA8GzB,GAAA,IAAA,GAAA,SAAA,CAAA;EACA;;;AA8BJ;;;EAC4B,WAAA,EAAA,CAAA,IAAA,EAtIN,QAsIM,EAAA,GAtIO,YAsIP,CAAA,IAAA,CAAA;CAApB;AAAmB,KAnIf,WAmIe,CAAA,iBAnIc,aAmId,CAAA,GAAA,wBAlIH,oBAAoB,aAAa,WACrD,oBAAoB,UAAU;aAGrB,WACT,oBAAoB;QAGhB,WAAW,oBAAoB;aAC1B,WAAW,oBAAoB;;KAGvC,+BACS,KAAK,YAAY,EAAE;KAGrB,wBACO,cAAc,kBAAkB,cAAc,mBAC7D,QAAQ,YAAY;;;;;;;;;;QAWhB;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA6BoB;;;;;;;;;;qCAcX,wCACA,aAAa;;;;;;;;;;;;;;;WAiBxB,kBAEU,kBAAkB,wBACrB,aAAa,YAAY,sBAAsB,yBAErD,YAAY,sBAAsB;0BAEnB,kBAAkB,qBACpC,UACA;KA8BQ,kCAAkC,gBAAgB,uBACtD,oBAAoB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SUPPORTED_COMMANDS } from "./commands.mjs";
|
|
2
|
+
import { BUILDER_VARIANTS } from "./unplugin.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/types/plugin.ts
|
|
5
|
+
const PLUGIN_NON_HOOK_FIELDS = [
|
|
6
|
+
"name",
|
|
7
|
+
"api",
|
|
8
|
+
"enforce",
|
|
9
|
+
"dedupe",
|
|
10
|
+
"applyToEnvironment"
|
|
11
|
+
];
|
|
12
|
+
const PLUGIN_HOOKS_FIELDS = [
|
|
13
|
+
...SUPPORTED_COMMANDS,
|
|
14
|
+
"config",
|
|
15
|
+
"configEnvironment",
|
|
16
|
+
"configResolved",
|
|
17
|
+
"types",
|
|
18
|
+
"buildStart",
|
|
19
|
+
"buildEnd",
|
|
20
|
+
"transform",
|
|
21
|
+
"load",
|
|
22
|
+
"resolveId",
|
|
23
|
+
"writeBundle"
|
|
24
|
+
];
|
|
25
|
+
const KNOWN_PLUGIN_FIELDS = [
|
|
26
|
+
...PLUGIN_NON_HOOK_FIELDS,
|
|
27
|
+
...PLUGIN_HOOKS_FIELDS,
|
|
28
|
+
...BUILDER_VARIANTS
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { };
|
|
33
|
+
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../../../core/src/types/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ArrayValues } from \"@stryke/types/array\";\nimport type { AnyFunction, MaybePromise } from \"@stryke/types/base\";\nimport { LoadResult } from \"rollup\";\nimport type { ExternalIdResult, HookFilter, TransformResult } from \"unplugin\";\nimport type { CommandType } from \"./commands\";\nimport { SUPPORTED_COMMANDS } from \"./commands\";\nimport type {\n EnvironmentConfig,\n EnvironmentResolvedConfig,\n PluginConfig,\n ResolvedConfig\n} from \"./config\";\nimport type {\n BuildPluginContext,\n PluginContext,\n UnresolvedContext\n} from \"./context\";\nimport type { BuilderVariant, UnpluginBuilderVariant } from \"./unplugin\";\nimport { BUILDER_VARIANTS, InferUnpluginOptions } from \"./unplugin\";\n\nexport interface PluginHookObject<\n THookFunction extends AnyFunction,\n TFilter extends keyof HookFilter = never\n> {\n /**\n * The order in which the plugin should be applied.\n */\n order?: \"pre\" | \"post\" | null | undefined;\n\n /**\n * A filter to determine when the hook should be called.\n */\n filter?: Pick<HookFilter, TFilter>;\n\n /**\n * The hook function to be called.\n */\n handler: THookFunction;\n}\n\nexport type PluginHook<\n THookFunction extends AnyFunction,\n TFilter extends keyof HookFilter = never\n> = THookFunction | PluginHookObject<THookFunction, TFilter>;\n\n/**\n * A result returned by the plugin from the `types` hook that describes the declaration types output file.\n */\nexport interface TypesResult {\n directives?: string[];\n code: string;\n}\n\nexport type PluginHookFunctions<TContext extends PluginContext> = {\n [TCommandType in CommandType]: (this: TContext) => MaybePromise<void>;\n} & {\n /**\n * A function that returns configuration options to be merged with the build context's options.\n *\n * @remarks\n * 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.\n *\n * @warning User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.\n *\n * @see https://vitejs.dev/guide/api-plugin#config\n *\n * @param this - The build context.\n * @param config - The partial configuration object to be modified.\n * @returns A promise that resolves to a partial configuration object.\n */\n config: (\n this: UnresolvedContext<TContext[\"config\"]>\n ) => MaybePromise<DeepPartial<TContext[\"config\"]> & Record<string, any>>;\n\n /**\n * 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.\n *\n * @remarks\n * 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.\n *\n * @see https://vitejs.dev/guide/api-plugin#configenvironment\n *\n * @param this - The build context.\n * @param name - The name of the environment being configured.\n * @param environment - The Vite-like environment object containing information about the current build environment.\n * @returns A promise that resolves when the hook is complete.\n */\n configEnvironment: (\n this: TContext,\n name: string,\n environment: EnvironmentConfig\n ) => MaybePromise<Partial<EnvironmentResolvedConfig> | undefined | null>;\n\n /**\n * A hook that is called when the plugin is resolved.\n *\n * @see https://vitejs.dev/guide/api-plugin#configresolved\n *\n * @param this - The build context.\n * @returns A promise that resolves when the hook is complete.\n */\n configResolved: (this: TContext) => MaybePromise<void>;\n\n /**\n * 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.\n *\n * @param this - The build context.\n * @param code - The source code to generate types for.\n * @returns A promise that resolves when the hook is complete.\n */\n types: (\n this: TContext,\n code: string\n ) => MaybePromise<TypesResult | string | undefined | null>;\n\n /**\n * A hook that is called at the start of the build process.\n *\n * @param this - The build context and unplugin build context.\n * @returns A promise that resolves when the hook is complete.\n */\n buildStart: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext\n ) => MaybePromise<void>;\n\n /**\n * A hook that is called at the end of the build process.\n *\n * @param this - The build context and unplugin build context.\n * @returns A promise that resolves when the hook is complete.\n */\n buildEnd: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext\n ) => MaybePromise<void>;\n\n /**\n * A hook that is called to transform the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param code - The source code to transform.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n transform: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n code: string,\n id: string\n ) => MaybePromise<TransformResult>;\n\n /**\n * A hook that is called to load the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @returns A promise that resolves when the hook is complete.\n */\n load: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string\n ) => MaybePromise<LoadResult>;\n\n /**\n * A hook that is called to resolve the identifier of the source code.\n *\n * @param this - The build context, unplugin build context, and unplugin context.\n * @param id - The identifier of the source code.\n * @param importer - The importer of the source code.\n * @param options - The options for resolving the identifier.\n * @returns A promise that resolves when the hook is complete.\n */\n resolveId: (\n this: BuildPluginContext<TContext[\"config\"]> & TContext,\n id: string,\n importer: string | undefined,\n options: { isEntry: boolean }\n ) => MaybePromise<string | ExternalIdResult | null | undefined>;\n\n /**\n * A hook that is called to write the bundle to disk.\n *\n * @param this - The build context.\n * @returns A promise that resolves when the hook is complete.\n */\n writeBundle: (this: TContext) => MaybePromise<void>;\n};\n\nexport type PluginHooks<TContext extends PluginContext> = {\n [TPluginHook in keyof PluginHookFunctions<TContext>]?: PluginHook<\n PluginHookFunctions<TContext>[TPluginHook]\n >;\n} & {\n transform: PluginHook<\n PluginHookFunctions<TContext>[\"transform\"],\n \"code\" | \"id\"\n >;\n load: PluginHook<PluginHookFunctions<TContext>[\"load\"], \"id\">;\n resolveId: PluginHook<PluginHookFunctions<TContext>[\"resolveId\"], \"id\">;\n};\n\ntype DeepPartial<T> = {\n [K in keyof T]?: DeepPartial<T[K]>;\n};\n\nexport type Plugin<\n TContext extends PluginContext<ResolvedConfig> = PluginContext<ResolvedConfig>\n> = Partial<PluginHooks<TContext>> & {\n /**\n * The name of the plugin, for use in deduplication, error messages and logs.\n */\n name: string;\n\n /**\n * An API object that can be used for inter-plugin communication.\n *\n * @see https://rollupjs.org/plugin-development/#direct-plugin-communication\n */\n api?: Record<string, any>;\n\n /**\n * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the `order` property in the hook object.\n *\n * @remarks\n * The Plugin invocation order is as follows:\n * - `enforce: 'pre'` plugins\n * - `order: 'pre'` plugin hooks\n * - any other plugins (normal)\n * - `order: 'post'` plugin hooks\n * - `enforce: 'post'` plugins\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-ordering\n * @see https://rollupjs.org/plugin-development/#build-hooks\n * @see https://webpack.js.org/concepts/loaders/#enforce---pre-and-post\n * @see https://esbuild.github.io/plugins/#concepts\n */\n enforce?: \"pre\" | \"post\";\n\n /**\n * A function to determine if two plugins are the same and can be de-duplicated.\n *\n * @remarks\n * If this is not provided, plugins are de-duplicated by comparing their names.\n *\n * @param other - The other plugin to compare against.\n * @returns `true` if the two plugins are the same, `false` otherwise.\n */\n dedupe?: false | ((other: Plugin<any>) => boolean);\n\n /**\n * A list of pre-requisite plugins that must be loaded before this plugin can be used.\n */\n // dependsOn?: PluginConfig<TContext>[];\n\n /**\n * Define environments where this plugin should be active. By default, the plugin is active in all environments.\n *\n * @param environment - The environment to check.\n * @returns `true` if the plugin should be active in the specified environment, `false` otherwise.\n */\n applyToEnvironment?: (\n environment: EnvironmentResolvedConfig\n ) => boolean | PluginConfig<TContext>;\n\n /**\n * A function that returns configuration options to be merged with the build context's options.\n *\n * @remarks\n * 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.\n *\n * @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.\n *\n * @see https://vitejs.dev/guide/api-plugin#config\n *\n * @param this - The build context.\n * @param config - The partial configuration object to be modified.\n * @returns A promise that resolves to a partial configuration object.\n */\n config?:\n | PluginHook<\n (\n this: UnresolvedContext<TContext[\"config\"]>\n ) => MaybePromise<DeepPartial<TContext[\"config\"]> & Record<string, any>>\n >\n | (DeepPartial<TContext[\"config\"]> & Record<string, any>);\n} & {\n [TBuilderVariant in BuilderVariant]?: InferUnpluginOptions<\n TContext,\n TBuilderVariant\n >;\n};\n\nexport const PLUGIN_NON_HOOK_FIELDS = [\n \"name\",\n \"api\",\n \"enforce\",\n \"dedupe\",\n \"applyToEnvironment\"\n] as const;\n\nexport type PluginNonHookFields =\n | ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n | UnpluginBuilderVariant;\n\nexport const PLUGIN_HOOKS_FIELDS = [\n ...SUPPORTED_COMMANDS,\n \"config\",\n \"configEnvironment\",\n \"configResolved\",\n \"types\",\n \"buildStart\",\n \"buildEnd\",\n \"transform\",\n \"load\",\n \"resolveId\",\n \"writeBundle\"\n] as const;\n\nexport type PluginHookFields<TContext extends PluginContext = PluginContext> =\n keyof PluginHookFunctions<TContext>;\n\nexport const KNOWN_PLUGIN_FIELDS = [\n ...PLUGIN_NON_HOOK_FIELDS,\n ...PLUGIN_HOOKS_FIELDS,\n ...BUILDER_VARIANTS\n] as const;\n\nexport type PluginFields = ArrayValues<typeof KNOWN_PLUGIN_FIELDS>;\n"],"mappings":";;;;AAoTA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACD;AAMD,MAAa,sBAAsB;CACjC,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAKD,MAAa,sBAAsB;CACjC,GAAG;CACH,GAAG;CACH,GAAG;CACJ"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CompilerOptions, TsConfigJson } from "@stryke/types/tsconfig";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/types/tsconfig.d.ts
|
|
5
|
+
type ReflectionMode = "default" | "explicit" | "never";
|
|
6
|
+
type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Defines the level of reflection to be used during the transpilation process.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
12
|
+
* - `minimal` - Only the essential type information is captured.
|
|
13
|
+
* - `normal` - Additional type information is captured, including some contextual data.
|
|
14
|
+
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
15
|
+
*/
|
|
16
|
+
type ReflectionLevel = "minimal" | "normal" | "verbose";
|
|
17
|
+
interface DeepkitOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Either true to activate reflection for all files compiled using this tsconfig,
|
|
20
|
+
* or a list of globs/file paths relative to this tsconfig.json.
|
|
21
|
+
* Globs/file paths can be prefixed with a ! to exclude them.
|
|
22
|
+
*/
|
|
23
|
+
reflection?: RawReflectionMode;
|
|
24
|
+
/**
|
|
25
|
+
* Defines the level of reflection to be used during the transpilation process.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
29
|
+
* - `minimal` - Only the essential type information is captured.
|
|
30
|
+
* - `normal` - Additional type information is captured, including some contextual data.
|
|
31
|
+
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
32
|
+
*/
|
|
33
|
+
reflectionLevel?: ReflectionLevel;
|
|
34
|
+
}
|
|
35
|
+
type TSCompilerOptions = CompilerOptions & DeepkitOptions;
|
|
36
|
+
/**
|
|
37
|
+
* The TypeScript compiler configuration.
|
|
38
|
+
*
|
|
39
|
+
* @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
|
|
40
|
+
*/
|
|
41
|
+
interface TSConfig extends Omit<TsConfigJson, "reflection"> {
|
|
42
|
+
/**
|
|
43
|
+
* Either true to activate reflection for all files compiled using this tsconfig,
|
|
44
|
+
* or a list of globs/file paths relative to this tsconfig.json.
|
|
45
|
+
* Globs/file paths can be prefixed with a ! to exclude them.
|
|
46
|
+
*/
|
|
47
|
+
reflection?: RawReflectionMode;
|
|
48
|
+
/**
|
|
49
|
+
* Defines the level of reflection to be used during the transpilation process.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
53
|
+
* - `minimal` - Only the essential type information is captured.
|
|
54
|
+
* - `normal` - Additional type information is captured, including some contextual data.
|
|
55
|
+
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
56
|
+
*/
|
|
57
|
+
reflectionLevel?: ReflectionLevel;
|
|
58
|
+
/**
|
|
59
|
+
* Instructs the TypeScript compiler how to compile `.ts` files.
|
|
60
|
+
*/
|
|
61
|
+
compilerOptions?: TSCompilerOptions;
|
|
62
|
+
}
|
|
63
|
+
type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
|
|
64
|
+
originalTsconfigJson: TsConfigJson;
|
|
65
|
+
tsconfigJson: TSConfig;
|
|
66
|
+
tsconfigFilePath: string;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { DeepkitOptions, ParsedTypeScriptConfig, RawReflectionMode, ReflectionLevel, ReflectionMode, TSCompilerOptions, TSConfig };
|
|
70
|
+
//# sourceMappingURL=tsconfig.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.d.mts","names":[],"sources":["../../../../../core/src/types/tsconfig.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,cAAA;KACA,iBAAA,GACR;AAFJ;AACA;AAiBA;AAEA;AAoBA;AAOA;;;;AAsBoB,KAnDR,eAAA,GAmDQ,SAAA,GAAA,QAAA,GAAA,SAAA;AAtBc,UA3BjB,cAAA,CA2BiB;EAAI;AAyBtC;;;;EAEwB,UAAA,CAAA,EAhDT,iBAgDS;;;;;;;;;;oBArCJ;;KAGR,iBAAA,GAAoB,kBAAkB;;;;;;UAOjC,QAAA,SAAiB,KAAK;;;;;;eAMxB;;;;;;;;;;oBAWK;;;;oBAKA;;KAGR,sBAAA,GAAyB,EAAA,CAAG;wBAChB;gBACR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PluginHook } from "./plugin.mjs";
|
|
2
|
+
import { Context } from "./context.mjs";
|
|
3
|
+
import "./config.mjs";
|
|
4
|
+
import { API } from "./api.mjs";
|
|
5
|
+
import { HookFilter, UnpluginOptions } from "unplugin";
|
|
6
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
7
|
+
|
|
8
|
+
//#region ../core/src/types/unplugin.d.ts
|
|
9
|
+
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
10
|
+
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
11
|
+
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
12
|
+
interface UnpluginOptions$1<TContext extends Context = Context> extends UnpluginOptions {
|
|
13
|
+
/**
|
|
14
|
+
* An API object that can be used for inter-plugin communication.
|
|
15
|
+
*
|
|
16
|
+
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
17
|
+
*/
|
|
18
|
+
api: API<TContext["config"]>;
|
|
19
|
+
}
|
|
20
|
+
type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TContext>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] extends infer THandler | {
|
|
21
|
+
handler: infer THandler;
|
|
22
|
+
} ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] };
|
|
23
|
+
//#endregion
|
|
24
|
+
export { BuilderVariant, InferUnpluginOptions, InferUnpluginVariant, UnpluginBuilderVariant, UnpluginOptions$1 as UnpluginOptions };
|
|
25
|
+
//# sourceMappingURL=unplugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unplugin.d.mts","names":[],"sources":["../../../../../core/src/types/unplugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6BY,sBAAA;AAAA,KAuBA,cAAA,GACR,sBAxB8B,GAAA,MAAA,GAAA,QAAA,GAAA,SAAA;AAoCtB,KAAA,oBAAoB,CAAA,sBAAuB,cAAvB,CAAA,GAC9B,aAD8B,SAAA,MAAA,GAAA,SAAA,GAG1B,aAH0B,SAAA,QAAA,GAAA,UAAA,GAKxB,aALwB,SAAA,SAAA,GAAA,QAAA,GAOtB,aAPsB;AAAuB,UAStC,iBATsC,CAAA,iBAUpC,OAVoC,GAU1B,OAV0B,CAAA,SAW7C,eAX6C,CAAA;EACrD;;;;;EAQe,GAAA,EAQV,GARU,CAQN,QARM,CAAA,QAAe,CAAA,CAAA;;AACH,KAUjB,oBAViB,CAAA,iBAWV,OAXU,GAWA,OAXA,EAAA,wBAYH,cAZG,GAYc,cAZd,EAAA,yBAaF,oBAbE,CAamB,eAbnB,CAAA,GAczB,oBAdyB,CAcJ,eAdI,CAAA,CAAA,GAAA,WAOlB,MASM,QATN,CAUP,iBAVO,CAUS,QAVT,CAAA,CAAA,CAWP,gBAXO,CAAA,IAWc,QAXd,CAYP,iBAZO,CAYS,QAZT,CAAA,CAAA,CAaP,gBAbO,CAAA,CAaW,IAbX,CAAA,SAAA,KAAA,SAAA,GAAA;EAAJ,OAAA,EAAA,KAAA,SAAA;AANG,CAAA,GAAA,QAAA,UAAA,CAAA,IAAA,EAAA,KAAA,iBAAA,EAAA,GAAA,IAAA,EAAA,KAAA,MAAA,EAAA,GAAA,KAAA,QAAA,IA4BF,UA5BE,CAAA,CAAA,IAAA,EA8BQ,gBA9BR,GA8B2B,QA9B3B,EAAA,GAAA,IAAA,EA+BW,KA/BX,EAAA,GAgCK,YAhCL,CAgCkB,OAhClB,CAAA,EAAA,MAiCM,UAjCN,CAAA,GAmCF,QAnCE,CAmCO,iBAnCP,CAmCuB,QAnCvB,CAAA,CAAA,CAmCkC,gBAnClC,CAAA,CAmCoD,IAnCpD,CAAA,GAoCJ,QApCI,CAoCK,iBApCL,CAoCqB,QApCrB,CAAA,CAAA,CAoCgC,gBApChC,CAAA,CAoCkD,IApClD,CAAA,EAAmB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region ../core/src/types/unplugin.ts
|
|
2
|
+
const UNPLUGIN_BUILDER_VARIANTS = [
|
|
3
|
+
"rollup",
|
|
4
|
+
"webpack",
|
|
5
|
+
"rspack",
|
|
6
|
+
"vite",
|
|
7
|
+
"esbuild",
|
|
8
|
+
"farm",
|
|
9
|
+
"unloader",
|
|
10
|
+
"rolldown",
|
|
11
|
+
"bun"
|
|
12
|
+
];
|
|
13
|
+
const BUILDER_VARIANTS = [
|
|
14
|
+
...UNPLUGIN_BUILDER_VARIANTS,
|
|
15
|
+
"tsup",
|
|
16
|
+
"tsdown",
|
|
17
|
+
"unbuild"
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { BUILDER_VARIANTS };
|
|
22
|
+
//# sourceMappingURL=unplugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unplugin.mjs","names":["UNPLUGIN_BUILDER_VARIANTS: UnpluginBuilderVariant[]","BUILDER_VARIANTS: BuilderVariant[]"],"sources":["../../../../../core/src/types/unplugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { MaybePromise } from \"@stryke/types/base\";\nimport type {\n UnpluginOptions as BaseUnpluginOptions,\n HookFilter,\n UnpluginContextMeta\n} from \"unplugin\";\nimport type { API } from \"./api\";\nimport type { UserConfig } from \"./config\";\nimport type { Context } from \"./context\";\nimport type { PluginHook } from \"./plugin\";\n\nexport type UnpluginBuilderVariant =\n | \"rollup\"\n | \"webpack\"\n | \"rspack\"\n | \"vite\"\n | \"esbuild\"\n | \"farm\"\n | \"unloader\"\n | \"rolldown\"\n | \"bun\";\n\nexport const UNPLUGIN_BUILDER_VARIANTS: UnpluginBuilderVariant[] = [\n \"rollup\",\n \"webpack\",\n \"rspack\",\n \"vite\",\n \"esbuild\",\n \"farm\",\n \"unloader\",\n \"rolldown\",\n \"bun\"\n] as const;\n\nexport type BuilderVariant =\n | UnpluginBuilderVariant\n | \"tsup\"\n | \"tsdown\"\n | \"unbuild\";\n\nexport const BUILDER_VARIANTS: BuilderVariant[] = [\n ...UNPLUGIN_BUILDER_VARIANTS,\n \"tsup\",\n \"tsdown\",\n \"unbuild\"\n] as const;\n\nexport type InferUnpluginVariant<TBuildVariant extends BuilderVariant> =\n TBuildVariant extends \"tsup\"\n ? \"esbuild\"\n : TBuildVariant extends \"tsdown\"\n ? \"rolldown\"\n : TBuildVariant extends \"unbuild\"\n ? \"rollup\"\n : TBuildVariant;\n\nexport interface UnpluginOptions<\n TContext extends Context = Context\n> extends BaseUnpluginOptions {\n /**\n * An API object that can be used for inter-plugin communication.\n *\n * @see https://rollupjs.org/plugin-development/#direct-plugin-communication\n */\n api: API<TContext[\"config\"]>;\n}\n\nexport type InferUnpluginOptions<\n TContext extends Context = Context,\n TBuilderVariant extends BuilderVariant = BuilderVariant,\n TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> =\n InferUnpluginVariant<TBuilderVariant>\n> = {\n [TKey in keyof Required<\n UnpluginOptions<TContext>\n >[TUnpluginVariant]]?: Required<\n UnpluginOptions<TContext>\n >[TUnpluginVariant][TKey] extends\n | infer THandler\n | {\n handler: infer THandler;\n }\n ? THandler extends (\n this: infer TOriginalContext,\n ...args: infer TArgs\n ) => infer TReturn\n ? PluginHook<\n (\n this: TOriginalContext & TContext,\n ...args: TArgs\n ) => MaybePromise<TReturn>,\n keyof HookFilter\n >\n : Required<UnpluginOptions<TContext>>[TUnpluginVariant][TKey]\n : Required<UnpluginOptions<TContext>>[TUnpluginVariant][TKey];\n};\n\nexport type UnpluginUserConfig = UserConfig & {\n /**\n * The meta information for the unplugin context\n */\n unplugin: UnpluginContextMeta;\n};\n\nexport type UnpluginFactory<TContext extends Context = Context> = (\n options: Partial<TContext[\"config\"][\"userConfig\"]>,\n meta: UnpluginContextMeta\n) => UnpluginOptions<TContext>;\n"],"mappings":";AAwCA,MAAaA,4BAAsD;CACjE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAQD,MAAaC,mBAAqC;CAChD,GAAG;CACH;CACA;CACA;CACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { format } from "../core/src/lib/utilities/format.mjs";
|
|
2
|
+
import { joinPaths } from "@stryke/path/join";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/format-package-json.ts
|
|
6
6
|
/**
|
|
@@ -9,7 +9,7 @@ import { format } from "powerlines/lib/utilities/format";
|
|
|
9
9
|
* @param context - The Tsdown plugin context.
|
|
10
10
|
*/
|
|
11
11
|
async function formatPackageJson(context) {
|
|
12
|
-
const packageJsonPath = joinPaths(context.workspaceConfig.workspaceRoot, context.config.
|
|
12
|
+
const packageJsonPath = joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "package.json");
|
|
13
13
|
const packageJsonFile = await context.fs.read(packageJsonPath);
|
|
14
14
|
if (isSetString(packageJsonFile)) await context.fs.write(packageJsonPath, await format(context, packageJsonPath, packageJsonFile));
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-package-json.mjs","names":[],"sources":["../../src/helpers/format-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {
|
|
1
|
+
{"version":3,"file":"format-package-json.mjs","names":[],"sources":["../../src/helpers/format-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { format } from \"@powerlines/core/lib/utilities/format\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { TsdownPluginContext } from \"../types/plugin\";\n\n/**\n * Formats the `package.json` file in the project root.\n *\n * @param context - The Tsdown plugin context.\n */\nexport async function formatPackageJson(context: TsdownPluginContext) {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"package.json\"\n );\n const packageJsonFile = await context.fs.read(packageJsonPath);\n if (isSetString(packageJsonFile)) {\n await context.fs.write(\n packageJsonPath,\n await format(context, packageJsonPath, packageJsonFile)\n );\n }\n}\n"],"mappings":";;;;;;;;;;AA4BA,eAAsB,kBAAkB,SAA8B;CACpE,MAAM,kBAAkB,UACtB,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,eACD;CACD,MAAM,kBAAkB,MAAM,QAAQ,GAAG,KAAK,gBAAgB;AAC9D,KAAI,YAAY,gBAAgB,CAC9B,OAAM,QAAQ,GAAG,MACf,iBACA,MAAM,OAAO,SAAS,iBAAiB,gBAAgB,CACxD"}
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { formatPackageJson } from "./format-package-json.mjs";
|
|
2
|
+
import { DEFAULT_TSDOWN_CONFIG, resolveFormat, resolveFromFormat, resolveOptions } from "./resolve-options.mjs";
|
|
1
3
|
import { createTsdownPlugin } from "./unplugin.mjs";
|
|
2
|
-
export { createTsdownPlugin };
|
|
4
|
+
export { DEFAULT_TSDOWN_CONFIG, createTsdownPlugin, formatPackageJson, resolveFormat, resolveFromFormat, resolveOptions };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { formatPackageJson } from "./format-package-json.mjs";
|
|
2
|
+
import { DEFAULT_TSDOWN_CONFIG, resolveFormat, resolveFromFormat, resolveOptions } from "./resolve-options.mjs";
|
|
1
3
|
import { createTsdownPlugin } from "./unplugin.mjs";
|
|
2
4
|
|
|
3
|
-
export { createTsdownPlugin };
|
|
5
|
+
export { DEFAULT_TSDOWN_CONFIG, createTsdownPlugin, formatPackageJson, resolveFormat, resolveFromFormat, resolveOptions };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context } from "../core/src/types/context.mjs";
|
|
2
|
+
import "../core/src/types/index.mjs";
|
|
3
|
+
import { Format, UserConfig } from "tsdown";
|
|
4
|
+
import { Format as Format$1 } from "@storm-software/build-tools/types";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/resolve-options.d.ts
|
|
7
|
+
declare const DEFAULT_TSDOWN_CONFIG: Partial<UserConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
10
|
+
*
|
|
11
|
+
* @param formats - The formats to resolve.
|
|
12
|
+
* @returns The resolved entry options.
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveFormat(formats?: Format$1 | Format$1[]): Format[];
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
17
|
+
*
|
|
18
|
+
* @param formats - The formats to resolve.
|
|
19
|
+
* @returns The resolved entry options.
|
|
20
|
+
*/
|
|
21
|
+
declare function resolveFromFormat(formats?: Format | Format[]): Format$1[];
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
24
|
+
*
|
|
25
|
+
* @param context - The build context.
|
|
26
|
+
* @returns The resolved options.
|
|
27
|
+
*/
|
|
28
|
+
declare function resolveOptions(context: Context): UserConfig;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { DEFAULT_TSDOWN_CONFIG, resolveFormat, resolveFromFormat, resolveOptions };
|
|
31
|
+
//# sourceMappingURL=resolve-options.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-options.d.mts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;;cAgCa,uBAAuB,QAAQ;;;AAA5C;AAcA;;;AAA4D,iBAA5C,aAAA,CAA4C,OAAA,CAAA,EAApB,QAAoB,GAAX,QAAW,EAAA,CAAA,EAAA,MAAA,EAAA;;AAoB5D;;;;;AAmCgB,iBAnCA,iBAAA,CAmCkC,OAAY,CAAZ,EAlCtC,MAkCkD,GAlCnC,MAkCmC,EAAA,CAAA,EAjC3D,QAiC2D,EAAA;;;;;;;iBAA9C,cAAA,UAAwB,UAAU"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { getDependencyConfig } from "../core/src/plugin-utils/build-helpers.mjs";
|
|
2
|
+
import "../core/src/plugin-utils/index.mjs";
|
|
3
|
+
import defu$1 from "defu";
|
|
4
|
+
import { appendPath } from "@stryke/path/append";
|
|
5
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
6
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
7
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
9
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
10
|
+
|
|
11
|
+
//#region src/helpers/resolve-options.ts
|
|
12
|
+
const DEFAULT_TSDOWN_CONFIG = {
|
|
13
|
+
platform: "neutral",
|
|
14
|
+
target: "esnext",
|
|
15
|
+
fixedExtension: true,
|
|
16
|
+
nodeProtocol: true,
|
|
17
|
+
clean: false
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
21
|
+
*
|
|
22
|
+
* @param formats - The formats to resolve.
|
|
23
|
+
* @returns The resolved entry options.
|
|
24
|
+
*/
|
|
25
|
+
function resolveFormat(formats) {
|
|
26
|
+
return toArray(formats).map((format) => {
|
|
27
|
+
switch (format) {
|
|
28
|
+
case "cjs": return "cjs";
|
|
29
|
+
case "iife": return "iife";
|
|
30
|
+
case "esm":
|
|
31
|
+
default: return "esm";
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
37
|
+
*
|
|
38
|
+
* @param formats - The formats to resolve.
|
|
39
|
+
* @returns The resolved entry options.
|
|
40
|
+
*/
|
|
41
|
+
function resolveFromFormat(formats) {
|
|
42
|
+
return toArray(formats).map((format) => {
|
|
43
|
+
switch (format) {
|
|
44
|
+
case "cjs":
|
|
45
|
+
case "commonjs": return "cjs";
|
|
46
|
+
case "iife": return "iife";
|
|
47
|
+
case "esm":
|
|
48
|
+
case "es":
|
|
49
|
+
case "module":
|
|
50
|
+
case "umd":
|
|
51
|
+
default: return "esm";
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const formatMessage = (context, ...msgs) => msgs.filter(Boolean).join(" ").replace(new RegExp(`\\[${context.config.name}\\]`, "g"), "").replaceAll(/^\s+/g, "").replaceAll(/\s+$/g, "").trim();
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
58
|
+
*
|
|
59
|
+
* @param context - The build context.
|
|
60
|
+
* @returns The resolved options.
|
|
61
|
+
*/
|
|
62
|
+
function resolveOptions(context) {
|
|
63
|
+
const { external, noExternal } = getDependencyConfig(context);
|
|
64
|
+
return defu$1({
|
|
65
|
+
entry: context.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(context.entry.filter((entry) => entry?.file).map((entry) => [entry.output || replaceExtension(replacePath(replacePath(entry.file, joinPaths(context.config.root, "src")), context.entryPath)), entry.file])) : [joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src", "**/*.ts"), joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src", "**/*.tsx")],
|
|
66
|
+
external,
|
|
67
|
+
noExternal,
|
|
68
|
+
alias: context.alias,
|
|
69
|
+
resolve: { alias: context.alias },
|
|
70
|
+
exports: context.config?.tsdown && context.config.tsdown?.exports ? defu$1(isSetObject(context.config.tsdown?.exports) ? context.config.tsdown?.exports : {}, { customExports: (exports) => {
|
|
71
|
+
const result = Object.fromEntries(Object.entries(exports).map(([key, value]) => {
|
|
72
|
+
if (isSetString(value)) return [key, value];
|
|
73
|
+
const currentExport = {};
|
|
74
|
+
if (isSetString(value.require)) currentExport.require = {
|
|
75
|
+
types: replaceExtension(value.require, ".d.cts", { fullExtension: true }),
|
|
76
|
+
default: value.require
|
|
77
|
+
};
|
|
78
|
+
if (isSetString(value.import)) currentExport.import = {
|
|
79
|
+
types: replaceExtension(value.import, ".d.mts", { fullExtension: true }),
|
|
80
|
+
default: value.import
|
|
81
|
+
};
|
|
82
|
+
if (!isSetObject(value.default)) {
|
|
83
|
+
if (isSetObject(currentExport.import)) currentExport.default = currentExport.import;
|
|
84
|
+
else if (isSetObject(currentExport.require)) currentExport.default = currentExport.require;
|
|
85
|
+
}
|
|
86
|
+
return [key, currentExport];
|
|
87
|
+
}));
|
|
88
|
+
return Object.keys(result).sort().reduce((ret, key) => {
|
|
89
|
+
ret[key] = result[key];
|
|
90
|
+
return ret;
|
|
91
|
+
}, {});
|
|
92
|
+
} }) : void 0
|
|
93
|
+
}, context.config?.tsdown ? context.config?.tsdown : {}, context.config?.rolldown ? { inputOptions: context.config?.rolldown } : {}, {
|
|
94
|
+
name: context.config.name,
|
|
95
|
+
cwd: appendPath(context.config.root, context.workspaceConfig.workspaceRoot),
|
|
96
|
+
define: context.config.define,
|
|
97
|
+
inputOptions: { transform: { inject: context.config.inject } },
|
|
98
|
+
platform: context.config.platform,
|
|
99
|
+
dts: true,
|
|
100
|
+
outDir: appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot),
|
|
101
|
+
tsconfig: appendPath(context.tsconfig.tsconfigFilePath, context.workspaceConfig.workspaceRoot),
|
|
102
|
+
format: resolveFormat(context.config.output.format).filter(Boolean),
|
|
103
|
+
mode: context.config.mode,
|
|
104
|
+
treeshake: context.config?.tsdown ? context.config?.tsdown?.treeshake : void 0,
|
|
105
|
+
minify: context.config.mode === "production",
|
|
106
|
+
metafile: context.config.mode === "development",
|
|
107
|
+
sourcemap: context.config.mode === "development",
|
|
108
|
+
debug: context.config.mode === "development",
|
|
109
|
+
silent: context.config.logLevel === null || context.config.mode === "production",
|
|
110
|
+
logLevel: context.config.logLevel === "trace" ? "debug" : context.config.logLevel,
|
|
111
|
+
customLogger: {
|
|
112
|
+
level: context.config.logLevel === "trace" ? "debug" : context.config.logLevel,
|
|
113
|
+
info: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.debug(formatMessage(context, ...msgs)),
|
|
114
|
+
warn: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
115
|
+
warnOnce: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
116
|
+
error: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.error(formatMessage(context, ...msgs)),
|
|
117
|
+
success: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.debug(formatMessage(context, ...msgs))
|
|
118
|
+
}
|
|
119
|
+
}, DEFAULT_TSDOWN_CONFIG);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { DEFAULT_TSDOWN_CONFIG, resolveFormat, resolveFromFormat, resolveOptions };
|
|
124
|
+
//# sourceMappingURL=resolve-options.mjs.map
|