@powerlines/plugin-esbuild 0.13.302 → 0.13.304
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/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/core/src/lib/entry.cjs +22 -0
- package/dist/core/src/lib/logger.cjs +41 -0
- package/dist/core/src/lib/unplugin/helpers.cjs +19 -0
- package/dist/core/src/lib/unplugin/index.cjs +3 -0
- package/dist/core/src/lib/unplugin/module-resolution.cjs +66 -0
- package/dist/core/src/lib/unplugin/plugin.cjs +104 -0
- package/dist/core/src/lib/utilities/source-file.cjs +22 -0
- package/dist/core/src/plugin-utils/paths.cjs +2 -0
- package/dist/core/src/types/api.d.cts +103 -0
- package/dist/core/src/types/api.d.cts.map +1 -0
- package/dist/core/src/types/commands.d.cts +9 -0
- package/dist/core/src/types/commands.d.cts.map +1 -0
- package/dist/core/src/types/config.d.cts +551 -0
- package/dist/core/src/types/config.d.cts.map +1 -0
- package/dist/core/src/types/context.d.cts +511 -0
- package/dist/core/src/types/context.d.cts.map +1 -0
- package/dist/core/src/types/fs.d.cts +487 -0
- package/dist/core/src/types/fs.d.cts.map +1 -0
- package/dist/core/src/types/hooks.d.cts +99 -0
- package/dist/core/src/types/hooks.d.cts.map +1 -0
- package/dist/core/src/types/plugin.d.cts +204 -0
- package/dist/core/src/types/plugin.d.cts.map +1 -0
- package/dist/core/src/types/tsconfig.d.cts +70 -0
- package/dist/core/src/types/tsconfig.d.cts.map +1 -0
- package/dist/core/src/types/unplugin.cjs +21 -0
- package/dist/core/src/types/unplugin.d.cts +24 -0
- package/dist/core/src/types/unplugin.d.cts.map +1 -0
- package/dist/helpers/bundle.cjs +43 -0
- package/dist/helpers/bundle.d.cts +17 -0
- package/dist/helpers/bundle.d.cts.map +1 -0
- package/dist/helpers/index.cjs +12 -0
- package/dist/helpers/index.d.cts +5 -0
- package/dist/helpers/resolve-options.cjs +90 -0
- package/dist/helpers/resolve-options.d.cts +24 -0
- package/dist/helpers/resolve-options.d.cts.map +1 -0
- package/dist/helpers/resolve.cjs +63 -0
- package/dist/helpers/resolve.d.cts +27 -0
- package/dist/helpers/resolve.d.cts.map +1 -0
- package/dist/helpers/unplugin.cjs +12 -0
- package/dist/helpers/unplugin.d.cts +8 -0
- package/dist/helpers/unplugin.d.cts.map +1 -0
- package/dist/index.cjs +48 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/types/build.cjs +0 -0
- package/dist/types/build.d.cts +8 -0
- package/dist/types/build.d.cts.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +20 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/package.json +37 -13
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { CommandType } from "./commands.cjs";
|
|
2
|
+
import { BuilderVariant, InferUnpluginOptions } from "./unplugin.cjs";
|
|
3
|
+
import { EnvironmentConfig, EnvironmentResolvedConfig, PluginConfig, ResolvedConfig } from "./config.cjs";
|
|
4
|
+
import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.cjs";
|
|
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 };
|
|
204
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../../../../core/src/types/plugin.ts"],"sourcesContent":[],"mappings":"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"}
|
|
@@ -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 { ParsedTypeScriptConfig, TSConfig };
|
|
70
|
+
//# sourceMappingURL=tsconfig.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.d.cts","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,21 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../core/src/types/unplugin.ts
|
|
3
|
+
const UNPLUGIN_BUILDER_VARIANTS = [
|
|
4
|
+
"rollup",
|
|
5
|
+
"webpack",
|
|
6
|
+
"rspack",
|
|
7
|
+
"vite",
|
|
8
|
+
"esbuild",
|
|
9
|
+
"farm",
|
|
10
|
+
"unloader",
|
|
11
|
+
"rolldown",
|
|
12
|
+
"bun"
|
|
13
|
+
];
|
|
14
|
+
const BUILDER_VARIANTS = [
|
|
15
|
+
...UNPLUGIN_BUILDER_VARIANTS,
|
|
16
|
+
"tsup",
|
|
17
|
+
"tsdown",
|
|
18
|
+
"unbuild"
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { API } from "./api.cjs";
|
|
2
|
+
import { PluginHook } from "./plugin.cjs";
|
|
3
|
+
import { Context } from "./context.cjs";
|
|
4
|
+
import { HookFilter, UnpluginOptions } from "unplugin";
|
|
5
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
6
|
+
|
|
7
|
+
//#region ../core/src/types/unplugin.d.ts
|
|
8
|
+
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
9
|
+
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
10
|
+
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
11
|
+
interface UnpluginOptions$1<TContext extends Context = Context> extends UnpluginOptions {
|
|
12
|
+
/**
|
|
13
|
+
* An API object that can be used for inter-plugin communication.
|
|
14
|
+
*
|
|
15
|
+
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
16
|
+
*/
|
|
17
|
+
api: API<TContext["config"]>;
|
|
18
|
+
}
|
|
19
|
+
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 | {
|
|
20
|
+
handler: infer THandler;
|
|
21
|
+
} ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] };
|
|
22
|
+
//#endregion
|
|
23
|
+
export { BuilderVariant, InferUnpluginOptions, UnpluginBuilderVariant };
|
|
24
|
+
//# sourceMappingURL=unplugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unplugin.d.cts","names":[],"sources":["../../../../../core/src/types/unplugin.ts"],"sourcesContent":[],"mappings":";;;;;;;KA6BY,sBAAA;AAuBA,KAAA,cAAA,GACR,sBAAA,GAAA,MAAsB,GAAA,QAAA,GAAA,SAAA;AAY6B,KAA3C,oBAA2C,CAAA,sBAAA,cAAA,CAAA,GACrD,aADqD,SAAA,MAAA,GAAA,SAAA,GAGjD,aAHiD,SAAA,QAAA,GAAA,UAAA,GAK/C,aAL+C,SAAA,SAAA,GAAA,QAAA,GAO7C,aAP6C;AACrD,UAQe,iBARf,CAAA,iBASiB,OATjB,GAS2B,OAT3B,CAAA,SAUQ,eAVR,CAAA;EAEI;;;;AAMN;EACmB,GAAA,EAOZ,GAPY,CAOR,QAPQ,CAAA,QAAA,CAAA,CAAA;;AAOR,KAGC,oBAHD,CAAA,iBAIQ,OAJR,GAIkB,OAJlB,EAAA,wBAKe,cALf,GAKgC,cALhC,EAAA,yBAMgB,oBANhB,CAMqC,eANrC,CAAA,GAOP,oBAPO,CAOc,eAPd,CAAA,CAAA,GAAA,WAAJ,MASU,QATV,CAUH,iBAVG,CAUa,QAVb,CAAA,CAAA,CAWH,gBAXG,CAAA,IAWkB,QAXlB,CAYH,iBAZG,CAYa,QAZb,CAAA,CAAA,CAaH,gBAbG,CAAA,CAae,IAbf,CAAA,SAAA,KAAA,SAAA,GAAA;EANG,OAAA,EAAA,KAAA,SAAA;AAAmB,CAAA,GAAA,QAAA,UAAA,CAAA,IAAA,EAAA,KAAA,iBAAA,EAAA,GAAA,IAAA,EAAA,KAAA,MAAA,EAAA,GAAA,KAAA,QAAA,IA4BrB,UA5BqB,CAAA,CAAA,IAAA,EA8BX,gBA9BW,GA8BQ,QA9BR,EAAA,GAAA,IAAA,EA+BR,KA/BQ,EAAA,GAgCd,YAhCc,CAgCD,OAhCC,CAAA,EAAA,MAiCb,UAjCa,CAAA,GAmCrB,QAnCqB,CAmCZ,iBAnCY,CAmCI,QAnCJ,CAAA,CAAA,CAmCe,gBAnCf,CAAA,CAmCiC,IAnCjC,CAAA,GAoCvB,QApCuB,CAoCd,iBApCc,CAoCE,QApCF,CAAA,CAAA,CAoCa,gBApCb,CAAA,CAoC+B,IApC/B,CAAA,EAS7B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_helpers_resolve_options = require('./resolve-options.cjs');
|
|
3
|
+
const require_plugin = require('../core/src/lib/unplugin/plugin.cjs');
|
|
4
|
+
require('../core/src/lib/unplugin/index.cjs');
|
|
5
|
+
let defu = require("defu");
|
|
6
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
7
|
+
let esbuild = require("esbuild");
|
|
8
|
+
let unplugin = require("unplugin");
|
|
9
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
10
|
+
|
|
11
|
+
//#region src/helpers/bundle.ts
|
|
12
|
+
/**
|
|
13
|
+
* Bundle a type definition to a module.
|
|
14
|
+
*
|
|
15
|
+
* @param context - The context object containing the environment paths.
|
|
16
|
+
* @param file - The file path to bundle.
|
|
17
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
18
|
+
* @returns A promise that resolves to the bundled module.
|
|
19
|
+
*/
|
|
20
|
+
async function bundle(context, file, overrides = {}) {
|
|
21
|
+
const path = await context.fs.resolve(file);
|
|
22
|
+
if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
|
|
23
|
+
const result = await (0, esbuild.build)((0, defu.default)({
|
|
24
|
+
...require_helpers_resolve_options.resolveOptions(context),
|
|
25
|
+
entryPoints: [path],
|
|
26
|
+
write: false,
|
|
27
|
+
sourcemap: false,
|
|
28
|
+
splitting: false,
|
|
29
|
+
treeShaking: false,
|
|
30
|
+
bundle: true,
|
|
31
|
+
packages: "bundle",
|
|
32
|
+
platform: "node",
|
|
33
|
+
logLevel: "silent",
|
|
34
|
+
...overrides
|
|
35
|
+
}, { plugins: [(0, unplugin.createEsbuildPlugin)(require_plugin.createUnpluginResolver(context, `${(0, __stryke_path_file_path_fns.findFileName)(file)} Bundler`))({})] }));
|
|
36
|
+
if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
|
|
37
|
+
if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
|
|
38
|
+
if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
|
|
39
|
+
return result.outputFiles.filter(Boolean)[0];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.bundle = bundle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PluginContext } from "../core/src/types/context.cjs";
|
|
2
|
+
import { BuildOptions, OutputFile } from "esbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/bundle.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Bundle a type definition to a module.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The context object containing the environment paths.
|
|
10
|
+
* @param file - The file path to bundle.
|
|
11
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
12
|
+
* @returns A promise that resolves to the bundled module.
|
|
13
|
+
*/
|
|
14
|
+
declare function bundle(context: PluginContext, file: string, overrides?: Partial<BuildOptions>): Promise<OutputFile>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { bundle };
|
|
17
|
+
//# sourceMappingURL=bundle.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.cts","names":[],"sources":["../../src/helpers/bundle.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkCA;;;;;;AAIU,iBAJY,MAAA,CAIZ,OAAA,EAHC,aAGD,EAAA,IAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EADG,OACH,CADW,YACX,CAAA,CAAA,EAAP,OAAO,CAAC,UAAD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_helpers_resolve_options = require('./resolve-options.cjs');
|
|
2
|
+
const require_helpers_unplugin = require('./unplugin.cjs');
|
|
3
|
+
const require_helpers_bundle = require('./bundle.cjs');
|
|
4
|
+
const require_helpers_resolve = require('./resolve.cjs');
|
|
5
|
+
|
|
6
|
+
exports.DEFAULT_ESBUILD_CONFIG = require_helpers_resolve_options.DEFAULT_ESBUILD_CONFIG;
|
|
7
|
+
exports.bundle = require_helpers_bundle.bundle;
|
|
8
|
+
exports.createEsbuildPlugin = require_helpers_unplugin.createEsbuildPlugin;
|
|
9
|
+
exports.resolve = require_helpers_resolve.resolve;
|
|
10
|
+
exports.resolveEntry = require_helpers_resolve_options.resolveEntry;
|
|
11
|
+
exports.resolveModule = require_helpers_resolve.resolveModule;
|
|
12
|
+
exports.resolveOptions = require_helpers_resolve_options.resolveOptions;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { bundle } from "./bundle.cjs";
|
|
2
|
+
import { resolve, resolveModule } from "./resolve.cjs";
|
|
3
|
+
import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./resolve-options.cjs";
|
|
4
|
+
import { createEsbuildPlugin } from "./unplugin.cjs";
|
|
5
|
+
export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_entry = require('../core/src/lib/entry.cjs');
|
|
3
|
+
let defu = require("defu");
|
|
4
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
5
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
6
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
7
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
9
|
+
|
|
10
|
+
//#region src/helpers/resolve-options.ts
|
|
11
|
+
const DEFAULT_ESBUILD_CONFIG = {
|
|
12
|
+
target: "esnext",
|
|
13
|
+
platform: "neutral",
|
|
14
|
+
format: "esm",
|
|
15
|
+
write: true,
|
|
16
|
+
minify: true,
|
|
17
|
+
sourcemap: false,
|
|
18
|
+
bundle: true,
|
|
19
|
+
treeShaking: true,
|
|
20
|
+
keepNames: true,
|
|
21
|
+
splitting: true,
|
|
22
|
+
logLevel: "silent"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the entry options for esbuild.
|
|
26
|
+
*
|
|
27
|
+
* @param context - The build context.
|
|
28
|
+
* @param entryPoints - The entry points to resolve.
|
|
29
|
+
* @returns The resolved entry options.
|
|
30
|
+
*/
|
|
31
|
+
function resolveEntry(context, entryPoints = []) {
|
|
32
|
+
return entryPoints.reduce((ret, entry) => {
|
|
33
|
+
if ((0, __stryke_type_checks_is_string.isString)(entry)) ret[(0, __stryke_path_replace.replaceExtension)((0, __stryke_path_replace.replacePath)(entry, context.config.root))] = (0, __stryke_path_replace.replacePath)(entry, context.config.root);
|
|
34
|
+
else ret[entry.output || require_entry.resolveEntryOutput(context, entry)] = entry.file;
|
|
35
|
+
return ret;
|
|
36
|
+
}, {});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the esbuild options.
|
|
40
|
+
*
|
|
41
|
+
* @param context - The build context.
|
|
42
|
+
* @returns The resolved esbuild options.
|
|
43
|
+
*/
|
|
44
|
+
function resolveOptions(context) {
|
|
45
|
+
if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
|
|
46
|
+
if (value) if (Array.isArray(value)) {
|
|
47
|
+
if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) {
|
|
48
|
+
if (value.length === 1) return `
|
|
49
|
+
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
50
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
51
|
+
else if (value.length > 1) return `
|
|
52
|
+
import ${value[1] === "*" ? `* as ${(0, __stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, __stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
|
|
53
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
54
|
+
} else if (value.length === 1) return `
|
|
55
|
+
import ${key} from "${value[0]}";
|
|
56
|
+
export { ${key} };`;
|
|
57
|
+
else if (value.length > 1) return `
|
|
58
|
+
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
59
|
+
export { ${key} };`;
|
|
60
|
+
} else if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) return `
|
|
61
|
+
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
62
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
63
|
+
else return `
|
|
64
|
+
import ${key} from "${value}";
|
|
65
|
+
export { ${key} };`;
|
|
66
|
+
return "";
|
|
67
|
+
}).join("\n"));
|
|
68
|
+
return (0, defu.default)({
|
|
69
|
+
alias: context.alias,
|
|
70
|
+
inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [(0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
|
|
71
|
+
}, context.config?.esbuild ? context.config.esbuild : {}, {
|
|
72
|
+
mainFields: context.config.resolve.mainFields,
|
|
73
|
+
conditions: context.config.resolve.conditions,
|
|
74
|
+
define: context.config.define,
|
|
75
|
+
resolveExtensions: context.config.resolve.extensions,
|
|
76
|
+
packages: context.config.resolve.skipNodeModulesBundle ? "external" : context.config?.esbuild ? (context.config?.esbuild).packages : void 0,
|
|
77
|
+
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
78
|
+
platform: context.config.platform,
|
|
79
|
+
outdir: context.config.output.buildPath,
|
|
80
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
81
|
+
minify: context.config.mode !== "development",
|
|
82
|
+
metafile: context.config.mode === "development",
|
|
83
|
+
sourcemap: context.config.mode === "development"
|
|
84
|
+
}, DEFAULT_ESBUILD_CONFIG);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.DEFAULT_ESBUILD_CONFIG = DEFAULT_ESBUILD_CONFIG;
|
|
89
|
+
exports.resolveEntry = resolveEntry;
|
|
90
|
+
exports.resolveOptions = resolveOptions;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ResolvedEntryTypeDefinition } from "../core/src/types/config.cjs";
|
|
2
|
+
import { Context } from "../core/src/types/context.cjs";
|
|
3
|
+
import { BuildOptions } from "esbuild";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/resolve-options.d.ts
|
|
6
|
+
declare const DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions>;
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the entry options for esbuild.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The build context.
|
|
11
|
+
* @param entryPoints - The entry points to resolve.
|
|
12
|
+
* @returns The resolved entry options.
|
|
13
|
+
*/
|
|
14
|
+
declare function resolveEntry(context: Context, entryPoints?: ResolvedEntryTypeDefinition[] | string[]): BuildOptions["entryPoints"];
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the esbuild options.
|
|
17
|
+
*
|
|
18
|
+
* @param context - The build context.
|
|
19
|
+
* @returns The resolved esbuild options.
|
|
20
|
+
*/
|
|
21
|
+
declare function resolveOptions(context: Context): BuildOptions;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
|
|
24
|
+
//# sourceMappingURL=resolve-options.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-options.d.cts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cA+Ba,wBAAwB,QAAQ;;;AAA7C;AAqBA;;;;AAGe,iBAHC,YAAA,CAGD,OAAA,EAFJ,OAEI,EAAA,WAAA,CAAA,EADA,2BACA,EAAA,GAAA,MAAA,EAAA,CAAA,EAAZ,YAAY,CAAA,aAAA,CAAA;AAsBf;;;;;;iBAAgB,cAAA,UAAwB,UAAU"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_helpers_bundle = require('./bundle.cjs');
|
|
3
|
+
let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
4
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/resolve.ts
|
|
7
|
+
/**
|
|
8
|
+
* Compiles a type definition to a module and returns the module.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context object containing the environment paths.
|
|
11
|
+
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
12
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
13
|
+
* @returns A promise that resolves to the compiled module.
|
|
14
|
+
*/
|
|
15
|
+
async function resolveModule(context, type, overrides = {}) {
|
|
16
|
+
let typeDefinition;
|
|
17
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(type);
|
|
18
|
+
else typeDefinition = type;
|
|
19
|
+
const result = await require_helpers_bundle.bundle(context, typeDefinition.file, overrides);
|
|
20
|
+
let resolved;
|
|
21
|
+
try {
|
|
22
|
+
resolved = await context.resolver.evalModule(result.text, {
|
|
23
|
+
filename: result.path,
|
|
24
|
+
forceTranspile: true
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(error.message) && (/* @__PURE__ */ new RegExp(`Cannot find module '${context.config.framework || "powerlines"}:.*'`)).test(error.message)) {
|
|
28
|
+
const moduleName = error.message.match(/* @__PURE__ */ new RegExp(`Cannot find module '(${context.config.framework || "powerlines"}:.*)'`))?.[1];
|
|
29
|
+
throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${typeDefinition.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
|
|
30
|
+
|
|
31
|
+
Bundle output for module:
|
|
32
|
+
${result.text}` : ""}`);
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`Failed to evaluate the bundled module for "${typeDefinition.file}". Error: ${error.message}${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
|
|
35
|
+
|
|
36
|
+
Bundle output for module:
|
|
37
|
+
${result.text}` : ""}`);
|
|
38
|
+
}
|
|
39
|
+
return resolved;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compiles a type definition to a module and returns the specified export from the module.
|
|
43
|
+
*
|
|
44
|
+
* @param context - The context object containing the environment paths.
|
|
45
|
+
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
46
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
47
|
+
* @returns A promise that resolves to the compiled module.
|
|
48
|
+
*/
|
|
49
|
+
async function resolve(context, type, overrides = {}) {
|
|
50
|
+
let typeDefinition;
|
|
51
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(type);
|
|
52
|
+
else typeDefinition = type;
|
|
53
|
+
const resolved = await resolveModule(context, typeDefinition, overrides);
|
|
54
|
+
let exportName = typeDefinition.name;
|
|
55
|
+
if (!exportName) exportName = "default";
|
|
56
|
+
const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];
|
|
57
|
+
if (resolvedExport === void 0) throw new Error(`The export "${exportName}" could not be resolved in the "${typeDefinition.file}" module. ${Object.keys(resolved).length === 0 ? `After bundling, no exports were found in the module. Please ensure that the "${typeDefinition.file}" module has a "${exportName}" export with the desired value.` : `After bundling, the available exports were: ${Object.keys(resolved).join(", ")}. Please ensure that the export exists and is correctly named.`}`);
|
|
58
|
+
return resolvedExport;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.resolve = resolve;
|
|
63
|
+
exports.resolveModule = resolveModule;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PluginContext } from "../core/src/types/context.cjs";
|
|
2
|
+
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
3
|
+
import { BuildOptions } from "esbuild";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/resolve.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compiles a type definition to a module and returns the module.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context object containing the environment paths.
|
|
11
|
+
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
12
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
13
|
+
* @returns A promise that resolves to the compiled module.
|
|
14
|
+
*/
|
|
15
|
+
declare function resolveModule<TResult>(context: PluginContext, type: TypeDefinitionParameter, overrides?: Partial<BuildOptions>): Promise<TResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Compiles a type definition to a module and returns the specified export from the module.
|
|
18
|
+
*
|
|
19
|
+
* @param context - The context object containing the environment paths.
|
|
20
|
+
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
21
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
22
|
+
* @returns A promise that resolves to the compiled module.
|
|
23
|
+
*/
|
|
24
|
+
declare function resolve<TResult>(context: PluginContext, type: TypeDefinitionParameter, overrides?: Partial<BuildOptions>): Promise<TResult>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { resolve, resolveModule };
|
|
27
|
+
//# sourceMappingURL=resolve.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.cts","names":[],"sources":["../../src/helpers/resolve.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAoCA;;;;;;AAIG,iBAJmB,aAInB,CAAA,OAAA,CAAA,CAAA,OAAA,EAHQ,aAGR,EAAA,IAAA,EAFK,uBAEL,EAAA,SAAA,CAAA,EADU,OACV,CADkB,YAClB,CAAA,CAAA,EAAA,OAAA,CAAQ,OAAR,CAAA;;AAqEH;;;;;;;AAIU,iBAJY,OAIZ,CAAA,OAAA,CAAA,CAAA,OAAA,EAHC,aAGD,EAAA,IAAA,EAFF,uBAEE,EAAA,SAAA,CAAA,EADG,OACH,CADW,YACX,CAAA,CAAA,EAAP,OAAO,CAAC,OAAD,CAAA"}
|