Skip to content

Commit ded2ef9

Browse files
committed
chore(plugin-esbuild): Add reusable BundleOptions types to override bundle options
1 parent eb9b2f3 commit ded2ef9

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/plugin-esbuild/src/helpers/bundle.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ import { findFileName } from "@stryke/path/file-path-fns";
2323
import defu from "defu";
2424
import { build, BuildOptions, OutputFile } from "esbuild";
2525
import { createEsbuildPlugin } from "unplugin";
26-
import { EsbuildPluginContext } from "../types";
26+
import { EsbuildOptions, EsbuildPluginContext } from "../types";
2727
import { resolveOptions } from "./resolve-options";
2828

29+
export type BundleOptions = Partial<EsbuildOptions> & {
30+
resolve?: Partial<ResolveResolvedConfig>;
31+
};
32+
2933
/**
3034
* Bundle a type definition to a module.
3135
*
@@ -37,9 +41,7 @@ import { resolveOptions } from "./resolve-options";
3741
export async function bundle(
3842
context: PluginContext,
3943
file: string,
40-
overrides: Partial<BuildOptions> & {
41-
resolve?: Partial<ResolveResolvedConfig>;
42-
} = {}
44+
overrides: BundleOptions = {}
4345
): Promise<OutputFile> {
4446
const path = await context.fs.resolve(file);
4547
if (!path || !context.fs.existsSync(path)) {

packages/plugin-esbuild/src/helpers/resolve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
------------------------------------------------------------------- */
1818

1919
import { PluginContext } from "@powerlines/core";
20-
import { bundle } from "@powerlines/plugin-esbuild/helpers/bundle";
2120
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
2221
import { isSetString } from "@stryke/type-checks/is-set-string";
2322
import {
2423
TypeDefinition,
2524
TypeDefinitionParameter
2625
} from "@stryke/types/configuration";
2726
import { BuildOptions } from "esbuild";
27+
import { bundle, BundleOptions } from "./bundle";
2828

2929
/**
3030
* Compiles a type definition to a module and returns the module.
@@ -37,7 +37,7 @@ import { BuildOptions } from "esbuild";
3737
export async function resolveModule<TResult>(
3838
context: PluginContext,
3939
type: TypeDefinitionParameter,
40-
overrides: Partial<BuildOptions> = {}
40+
overrides: BundleOptions = {}
4141
): Promise<TResult> {
4242
let typeDefinition!: TypeDefinition;
4343
if (isSetString(type)) {

0 commit comments

Comments
 (0)