@powerlines/plugin-esbuild 0.13.298 → 0.13.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/core/src/lib/entry.mjs +22 -0
  2. package/dist/core/src/lib/entry.mjs.map +1 -0
  3. package/dist/core/src/lib/logger.mjs +40 -0
  4. package/dist/core/src/lib/logger.mjs.map +1 -0
  5. package/dist/core/src/lib/unplugin/helpers.mjs +19 -0
  6. package/dist/core/src/lib/unplugin/helpers.mjs.map +1 -0
  7. package/dist/core/src/lib/unplugin/index.mjs +5 -0
  8. package/dist/core/src/lib/unplugin/module-resolution.mjs +66 -0
  9. package/dist/core/src/lib/unplugin/module-resolution.mjs.map +1 -0
  10. package/dist/core/src/lib/unplugin/plugin.mjs +103 -0
  11. package/dist/core/src/lib/unplugin/plugin.mjs.map +1 -0
  12. package/dist/core/src/lib/utilities/source-file.mjs +21 -0
  13. package/dist/core/src/lib/utilities/source-file.mjs.map +1 -0
  14. package/dist/core/src/plugin-utils/paths.mjs +4 -0
  15. package/dist/core/src/types/api.d.mts +103 -0
  16. package/dist/core/src/types/api.d.mts.map +1 -0
  17. package/dist/core/src/types/commands.d.mts +10 -0
  18. package/dist/core/src/types/commands.d.mts.map +1 -0
  19. package/dist/core/src/types/config.d.mts +551 -0
  20. package/dist/core/src/types/config.d.mts.map +1 -0
  21. package/dist/core/src/types/context.d.mts +511 -0
  22. package/dist/core/src/types/context.d.mts.map +1 -0
  23. package/dist/core/src/types/fs.d.mts +487 -0
  24. package/dist/core/src/types/fs.d.mts.map +1 -0
  25. package/dist/core/src/types/hooks.d.mts +99 -0
  26. package/dist/core/src/types/hooks.d.mts.map +1 -0
  27. package/dist/core/src/types/index.d.mts +9 -0
  28. package/dist/core/src/types/plugin.d.mts +204 -0
  29. package/dist/core/src/types/plugin.d.mts.map +1 -0
  30. package/dist/core/src/types/tsconfig.d.mts +70 -0
  31. package/dist/core/src/types/tsconfig.d.mts.map +1 -0
  32. package/dist/core/src/types/unplugin.d.mts +25 -0
  33. package/dist/core/src/types/unplugin.d.mts.map +1 -0
  34. package/dist/core/src/types/unplugin.mjs +22 -0
  35. package/dist/core/src/types/unplugin.mjs.map +1 -0
  36. package/dist/helpers/bundle.d.mts +17 -0
  37. package/dist/helpers/bundle.d.mts.map +1 -0
  38. package/dist/helpers/bundle.mjs +42 -0
  39. package/dist/helpers/bundle.mjs.map +1 -0
  40. package/dist/helpers/index.d.mts +5 -2
  41. package/dist/helpers/index.mjs +5 -2
  42. package/dist/helpers/resolve-options.d.mts +25 -0
  43. package/dist/helpers/resolve-options.d.mts.map +1 -0
  44. package/dist/helpers/resolve-options.mjs +87 -0
  45. package/dist/helpers/resolve-options.mjs.map +1 -0
  46. package/dist/helpers/resolve.d.mts +28 -0
  47. package/dist/helpers/resolve.d.mts.map +1 -0
  48. package/dist/helpers/resolve.mjs +62 -0
  49. package/dist/helpers/resolve.mjs.map +1 -0
  50. package/dist/helpers/unplugin.d.mts +3 -3
  51. package/dist/helpers/unplugin.mjs +6 -5
  52. package/dist/helpers/unplugin.mjs.map +1 -1
  53. package/dist/index.d.mts +10 -5
  54. package/dist/index.d.mts.map +1 -1
  55. package/dist/index.mjs +8 -6
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/types/build.d.mts +8 -0
  58. package/dist/types/build.d.mts.map +1 -0
  59. package/dist/types/build.mjs +1 -0
  60. package/dist/types/index.d.mts +3 -2
  61. package/dist/types/plugin.d.mts +17 -10
  62. package/dist/types/plugin.d.mts.map +1 -1
  63. package/package.json +28 -93
  64. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  65. package/dist/helpers/index.cjs +0 -3
  66. package/dist/helpers/index.d.cts +0 -2
  67. package/dist/helpers/unplugin.cjs +0 -11
  68. package/dist/helpers/unplugin.d.cts +0 -8
  69. package/dist/helpers/unplugin.d.cts.map +0 -1
  70. package/dist/index.cjs +0 -40
  71. package/dist/index.d.cts +0 -14
  72. package/dist/index.d.cts.map +0 -1
  73. package/dist/types/index.cjs +0 -0
  74. package/dist/types/index.d.cts +0 -2
  75. package/dist/types/plugin.cjs +0 -0
  76. package/dist/types/plugin.d.cts +0 -14
  77. 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 { EnvironmentConfig, EnvironmentResolvedConfig, PluginConfig, ResolvedConfig } from "./config.mjs";
4
+ import { BuildPluginContext, PluginContext, UnresolvedContext } from "./context.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,mB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uBACtD,oBAAoB"}
@@ -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 { API } from "./api.mjs";
2
+ import { PluginHook } from "./plugin.mjs";
3
+ import "./config.mjs";
4
+ import { Context } from "./context.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,oB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/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 { };
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"}
@@ -0,0 +1,17 @@
1
+ import { PluginContext } from "../core/src/types/context.mjs";
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.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.mts","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,42 @@
1
+ import { resolveOptions } from "./resolve-options.mjs";
2
+ import { createUnpluginResolver } from "../core/src/lib/unplugin/plugin.mjs";
3
+ import "../core/src/lib/unplugin/index.mjs";
4
+ import defu from "defu";
5
+ import { build } from "esbuild";
6
+ import { createEsbuildPlugin } from "unplugin";
7
+ import { findFileName } from "@stryke/path/file-path-fns";
8
+
9
+ //#region src/helpers/bundle.ts
10
+ /**
11
+ * Bundle a type definition to a module.
12
+ *
13
+ * @param context - The context object containing the environment paths.
14
+ * @param file - The file path to bundle.
15
+ * @param overrides - Optional overrides for the ESBuild configuration.
16
+ * @returns A promise that resolves to the bundled module.
17
+ */
18
+ async function bundle(context, file, overrides = {}) {
19
+ const path = await context.fs.resolve(file);
20
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
21
+ const result = await build(defu({
22
+ ...resolveOptions(context),
23
+ entryPoints: [path],
24
+ write: false,
25
+ sourcemap: false,
26
+ splitting: false,
27
+ treeShaking: false,
28
+ bundle: true,
29
+ packages: "bundle",
30
+ platform: "node",
31
+ logLevel: "silent",
32
+ ...overrides
33
+ }, { plugins: [createEsbuildPlugin(createUnpluginResolver(context, `${findFileName(file)} Bundler`))({})] }));
34
+ if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
35
+ if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
36
+ 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.`);
37
+ return result.outputFiles.filter(Boolean)[0];
38
+ }
39
+
40
+ //#endregion
41
+ export { bundle };
42
+ //# sourceMappingURL=bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.mjs","names":[],"sources":["../../src/helpers/bundle.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 { createUnpluginResolver } from \"@powerlines/core/lib/unplugin\";\nimport { PluginContext } from \"@powerlines/core/types/context\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport { build, BuildOptions, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { resolveOptions } from \"./resolve-options\";\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle(\n context: PluginContext,\n file: string,\n overrides: Partial<BuildOptions> = {}\n): Promise<OutputFile> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const result = await build(\n defu(\n {\n ...resolveOptions(context),\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: false,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...overrides\n } as BuildOptions,\n {\n plugins: [\n createEsbuildPlugin(\n createUnpluginResolver(context, `${findFileName(file)} Bundler`)\n )({})\n ]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,eAAsB,OACpB,SACA,MACA,YAAmC,EAAE,EAChB;CACrB,MAAM,OAAO,MAAM,QAAQ,GAAG,QAAQ,KAAK;AAC3C,KAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,KAAK,CACvC,OAAM,IAAI,MACR,sBAAsB,KAAK,yCAC5B;CAGH,MAAM,SAAS,MAAM,MACnB,KACE;EACE,GAAG,eAAe,QAAQ;EAC1B,aAAa,CAAC,KAAK;EACnB,OAAO;EACP,WAAW;EACX,WAAW;EACX,aAAa;EACb,QAAQ;EACR,UAAU;EACV,UAAU;EACV,UAAU;EACV,GAAG;EACJ,EACD,EACE,SAAS,CACP,oBACE,uBAAuB,SAAS,GAAG,aAAa,KAAK,CAAC,UAAU,CACjE,CAAC,EAAE,CAAC,CACN,EACF,CACF,CACF;AACD,KAAI,OAAO,OAAO,SAAS,EACzB,OAAM,IAAI,MACR,oBAAoB,KAAK,IAAI,OAAO,OACjC,KAAI,UAAS,MAAM,KAAK,CACxB,KAAK,KAAK,GACd;AAEH,KAAI,OAAO,SAAS,SAAS,EAC3B,SAAQ,KACN,2BAA2B,KAAK,IAAI,OAAO,SACxC,KAAI,YAAW,QAAQ,KAAK,CAC5B,KAAK,KAAK,GACd;AAEH,KAAI,CAAC,OAAO,eAAe,OAAO,YAAY,OAAO,QAAQ,CAAC,WAAW,EACvE,OAAM,IAAI,MACR,iCACE,KACD,iDACF;AAGH,QAAO,OAAO,YAAY,OAAO,QAAQ,CAAC"}
@@ -1,2 +1,5 @@
1
- import { createESBuildPlugin } from "./unplugin.mjs";
2
- export { createESBuildPlugin };
1
+ import { bundle } from "./bundle.mjs";
2
+ import { resolve, resolveModule } from "./resolve.mjs";
3
+ import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./resolve-options.mjs";
4
+ import { createEsbuildPlugin } from "./unplugin.mjs";
5
+ export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
@@ -1,3 +1,6 @@
1
- import { createESBuildPlugin } from "./unplugin.mjs";
1
+ import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./resolve-options.mjs";
2
+ import { createEsbuildPlugin } from "./unplugin.mjs";
3
+ import { bundle } from "./bundle.mjs";
4
+ import { resolve, resolveModule } from "./resolve.mjs";
2
5
 
3
- export { createESBuildPlugin };
6
+ export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
@@ -0,0 +1,25 @@
1
+ import { ResolvedEntryTypeDefinition } from "../core/src/types/config.mjs";
2
+ import { Context } from "../core/src/types/context.mjs";
3
+ import "../core/src/types/index.mjs";
4
+ import { BuildOptions } from "esbuild";
5
+
6
+ //#region src/helpers/resolve-options.d.ts
7
+ declare const DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions>;
8
+ /**
9
+ * Resolves the entry options for esbuild.
10
+ *
11
+ * @param context - The build context.
12
+ * @param entryPoints - The entry points to resolve.
13
+ * @returns The resolved entry options.
14
+ */
15
+ declare function resolveEntry(context: Context, entryPoints?: ResolvedEntryTypeDefinition[] | string[]): BuildOptions["entryPoints"];
16
+ /**
17
+ * Resolves the esbuild options.
18
+ *
19
+ * @param context - The build context.
20
+ * @returns The resolved esbuild options.
21
+ */
22
+ declare function resolveOptions(context: Context): BuildOptions;
23
+ //#endregion
24
+ export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
25
+ //# 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":";;;;;;cA+Ba,wBAAwB,QAAQ;;;;AAA7C;AAqBA;;;AAGG,iBAHa,YAAA,CAGb,OAAA,EAFQ,OAER,EAAA,WAAA,CAAA,EADY,2BACZ,EAAA,GAAA,MAAA,EAAA,CAAA,EAAA,YAAA,CAAA,aAAA,CAAA;;AAsBH;;;;;iBAAgB,cAAA,UAAwB,UAAU"}
@@ -0,0 +1,87 @@
1
+ import { resolveEntryOutput } from "../core/src/lib/entry.mjs";
2
+ import defu from "defu";
3
+ import { joinPaths } from "@stryke/path/join-paths";
4
+ import { replaceExtension, replacePath } from "@stryke/path/replace";
5
+ import { isString } from "@stryke/type-checks/is-string";
6
+ import { camelCase } from "@stryke/string-format/camel-case";
7
+
8
+ //#region src/helpers/resolve-options.ts
9
+ const DEFAULT_ESBUILD_CONFIG = {
10
+ target: "esnext",
11
+ platform: "neutral",
12
+ format: "esm",
13
+ write: true,
14
+ minify: true,
15
+ sourcemap: false,
16
+ bundle: true,
17
+ treeShaking: true,
18
+ keepNames: true,
19
+ splitting: true,
20
+ logLevel: "silent"
21
+ };
22
+ /**
23
+ * Resolves the entry options for esbuild.
24
+ *
25
+ * @param context - The build context.
26
+ * @param entryPoints - The entry points to resolve.
27
+ * @returns The resolved entry options.
28
+ */
29
+ function resolveEntry(context, entryPoints = []) {
30
+ return entryPoints.reduce((ret, entry) => {
31
+ if (isString(entry)) ret[replaceExtension(replacePath(entry, context.config.root))] = replacePath(entry, context.config.root);
32
+ else ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;
33
+ return ret;
34
+ }, {});
35
+ }
36
+ /**
37
+ * Resolves the esbuild options.
38
+ *
39
+ * @param context - The build context.
40
+ * @returns The resolved esbuild options.
41
+ */
42
+ function resolveOptions(context) {
43
+ if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
44
+ if (value) if (Array.isArray(value)) {
45
+ if (camelCase(key) !== key) {
46
+ if (value.length === 1) return `
47
+ import ${camelCase(key)} from "${value[0]}";
48
+ export { ${camelCase(key)} as "${key}" }`;
49
+ else if (value.length > 1) return `
50
+ import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
51
+ export { ${camelCase(key)} as "${key}" }`;
52
+ } else if (value.length === 1) return `
53
+ import ${key} from "${value[0]}";
54
+ export { ${key} };`;
55
+ else if (value.length > 1) return `
56
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
57
+ export { ${key} };`;
58
+ } else if (camelCase(key) !== key) return `
59
+ import ${camelCase(key)} from "${value[0]}";
60
+ export { ${camelCase(key)} as "${key}" }`;
61
+ else return `
62
+ import ${key} from "${value}";
63
+ export { ${key} };`;
64
+ return "";
65
+ }).join("\n"));
66
+ return defu({
67
+ alias: context.alias,
68
+ inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
69
+ }, context.config?.esbuild ? context.config.esbuild : {}, {
70
+ mainFields: context.config.resolve.mainFields,
71
+ conditions: context.config.resolve.conditions,
72
+ define: context.config.define,
73
+ resolveExtensions: context.config.resolve.extensions,
74
+ packages: context.config.resolve.skipNodeModulesBundle ? "external" : context.config?.esbuild ? (context.config?.esbuild).packages : void 0,
75
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
76
+ platform: context.config.platform,
77
+ outdir: context.config.output.buildPath,
78
+ tsconfig: context.tsconfig.tsconfigFilePath,
79
+ minify: context.config.mode !== "development",
80
+ metafile: context.config.mode === "development",
81
+ sourcemap: context.config.mode === "development"
82
+ }, DEFAULT_ESBUILD_CONFIG);
83
+ }
84
+
85
+ //#endregion
86
+ export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
87
+ //# sourceMappingURL=resolve-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.mjs","names":["DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions>"],"sources":["../../src/helpers/resolve-options.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 { resolveEntryOutput } from \"@powerlines/core/lib/entry\";\nimport type {\n Context,\n ResolvedEntryTypeDefinition\n} from \"@powerlines/core/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { BuildOptions, Format, LogLevel, Platform } from \"esbuild\";\nimport { EsbuildPluginContext } from \"../types/plugin\";\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): BuildOptions[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[replaceExtension(replacePath(entry, context.config.root))] =\n replacePath(entry, context.config.root);\n } else {\n ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function resolveOptions(context: Context): BuildOptions {\n if (context.config.inject && Object.keys(context.config.inject).length > 0) {\n context.fs.writeSync(\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n ),\n Object.entries(context.config.inject)\n .map(([key, value]) => {\n if (value) {\n if (Array.isArray(value)) {\n if (camelCase(key) !== key) {\n if (value.length === 1) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n }\n } else if (value.length === 1) {\n return `\nimport ${key} from \"${value[0]}\";\nexport { ${key} };`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from \"${value[0]}\";\nexport { ${key} };`;\n }\n } else if (camelCase(key) !== key) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else {\n return `\nimport ${key} from \"${value}\";\nexport { ${key} };`;\n }\n }\n\n return \"\";\n })\n .join(\"\\n\")\n );\n }\n\n return defu(\n {\n alias: context.alias,\n inject:\n context.config.inject && Object.keys(context.config.inject).length > 0\n ? [\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n )\n ]\n : undefined\n },\n (context as EsbuildPluginContext).config?.esbuild\n ? (context as EsbuildPluginContext).config.esbuild\n : {},\n {\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n resolveExtensions: context.config.resolve.extensions,\n packages: context.config.resolve.skipNodeModulesBundle\n ? \"external\"\n : (context as EsbuildPluginContext).config?.esbuild\n ? ((context as EsbuildPluginContext).config?.esbuild as BuildOptions)\n .packages\n : undefined,\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.platform,\n outdir: context.config.output.buildPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n ) as BuildOptions;\n}\n"],"mappings":";;;;;;;;AA+BA,MAAaA,yBAAgD;CAC3D,QAAQ;CACR,UAAU;CAC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AI;aAEQ,UAAU,IAAI,KAAK,IAC5B,QAAO;SACZ,UAAU,IAAI,CAAC,SAAS,MAAM,GAAG;WAC/B,UAAU,IAAI,CAAC,OAAO,IAAI;MAEvB,QAAO;SACZ,IAAI,SAAS,MAAM;WACjB,IAAI;AAIL,SAAO;GACP,CACD,KAAK,KAAK,CACd;AAGH,QAAO,KACL;EACE,OAAO,QAAQ;EACf,QACE,QAAQ,OAAO,UAAU,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,IACjE,CACE,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,QAAQ,eACR,iBACD,CACF,GACD;EACP,EACA,QAAiC,QAAQ,UACrC,QAAiC,OAAO,UACzC,EAAE,EACN;EACE,YAAY,QAAQ,OAAO,QAAQ;EACnC,YAAY,QAAQ,OAAO,QAAQ;EACnC,QAAQ,QAAQ,OAAO;EACvB,mBAAmB,QAAQ,OAAO,QAAQ;EAC1C,UAAU,QAAQ,OAAO,QAAQ,wBAC7B,aACC,QAAiC,QAAQ,WACtC,QAAiC,QAAQ,SACxC,WACH;EACN,QAAS,MAAM,QAAQ,QAAQ,OAAO,OAAO,OAAO,GAChD,QAAQ,OAAO,OAAO,OAAO,KAC7B,QAAQ,OAAO,OAAO;EAC1B,UAAU,QAAQ,OAAO;EACzB,QAAQ,QAAQ,OAAO,OAAO;EAC9B,UAAU,QAAQ,SAAS;EAC3B,QAAQ,QAAQ,OAAO,SAAS;EAChC,UAAU,QAAQ,OAAO,SAAS;EAClC,WAAW,QAAQ,OAAO,SAAS;EACpC,EACD,uBACD"}
@@ -0,0 +1,28 @@
1
+ import { PluginContext } from "../core/src/types/context.mjs";
2
+ import "../core/src/types/index.mjs";
3
+ import { BuildOptions } from "esbuild";
4
+ import { TypeDefinitionParameter } from "@stryke/types/configuration";
5
+
6
+ //#region src/helpers/resolve.d.ts
7
+
8
+ /**
9
+ * Compiles a type definition to a module and returns the module.
10
+ *
11
+ * @param context - The context object containing the environment paths.
12
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
13
+ * @param overrides - Optional overrides for the ESBuild configuration.
14
+ * @returns A promise that resolves to the compiled module.
15
+ */
16
+ declare function resolveModule<TResult>(context: PluginContext, type: TypeDefinitionParameter, overrides?: Partial<BuildOptions>): Promise<TResult>;
17
+ /**
18
+ * Compiles a type definition to a module and returns the specified export from the module.
19
+ *
20
+ * @param context - The context object containing the environment paths.
21
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
22
+ * @param overrides - Optional overrides for the ESBuild configuration.
23
+ * @returns A promise that resolves to the compiled module.
24
+ */
25
+ declare function resolve<TResult>(context: PluginContext, type: TypeDefinitionParameter, overrides?: Partial<BuildOptions>): Promise<TResult>;
26
+ //#endregion
27
+ export { resolve, resolveModule };
28
+ //# sourceMappingURL=resolve.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.mts","names":[],"sources":["../../src/helpers/resolve.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAoCA;;;;;AAIW,iBAJW,aAIX,CAAA,OAAA,CAAA,CAAA,OAAA,EAHA,aAGA,EAAA,IAAA,EAFH,uBAEG,EAAA,SAAA,CAAA,EADE,OACF,CADU,YACV,CAAA,CAAA,EAAR,OAAQ,CAAA,OAAA,CAAA;;;AAqEX;;;;;;AAIG,iBAJmB,OAInB,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"}