Skip to content

Commit 8e81e2a

Browse files
committedMar 27, 2023
feat(rollup): allow passing any all common esbuild options
1 parent e8988ae commit 8e81e2a

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed
 

‎src/builder/plugins/esbuild.ts

+9-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { extname, relative } from "pathe";
44
import type { Plugin, PluginContext } from "rollup";
5-
import { Loader, TransformResult, Charset, transform } from "esbuild";
5+
import { Loader, TransformResult, CommonOptions, transform } from "esbuild";
66
import { createFilter } from "@rollup/pluginutils";
77
import type { FilterPattern } from "@rollup/pluginutils";
88

@@ -13,23 +13,19 @@ const defaultLoaders: { [ext: string]: Loader } = {
1313
".jsx": "jsx",
1414
};
1515

16-
export interface Options {
16+
export interface Options extends CommonOptions {
17+
/** alias to `sourcemap` */
18+
sourceMap?: boolean;
19+
1720
include?: FilterPattern;
1821
exclude?: FilterPattern;
19-
sourceMap?: boolean;
20-
minify?: boolean;
21-
charset?: Charset;
22-
target: string | string[];
23-
jsxFactory?: string;
24-
jsxFragment?: string;
25-
define?: {
26-
[k: string]: string;
27-
};
22+
2823
/**
2924
* Use this tsconfig file instead
3025
* Disable it by setting to `false`
3126
*/
3227
tsconfig?: string | false;
28+
3329
/**
3430
* Map extension to esbuild loader
3531
* Note that each entry (the extension) needs to start with a dot
@@ -82,14 +78,10 @@ export function esbuild(options: Options): Plugin {
8278
}
8379

8480
const result = await transform(code, {
81+
...options,
8582
loader,
86-
target: options.target,
87-
define: options.define,
88-
charset: options.charset,
89-
sourcemap: options.sourceMap,
9083
sourcefile: id,
91-
jsxFactory: options.jsxFactory,
92-
jsxFragment: options.jsxFragment,
84+
sourcemap: options.sourceMap ?? options.sourceMap,
9385
});
9486

9587
printWarnings(id, result, this);

0 commit comments

Comments
 (0)
Please sign in to comment.