2
2
3
3
import { extname , relative } from "pathe" ;
4
4
import type { Plugin , PluginContext } from "rollup" ;
5
- import { Loader , TransformResult , Charset , transform } from "esbuild" ;
5
+ import { Loader , TransformResult , CommonOptions , transform } from "esbuild" ;
6
6
import { createFilter } from "@rollup/pluginutils" ;
7
7
import type { FilterPattern } from "@rollup/pluginutils" ;
8
8
@@ -13,23 +13,19 @@ const defaultLoaders: { [ext: string]: Loader } = {
13
13
".jsx" : "jsx" ,
14
14
} ;
15
15
16
- export interface Options {
16
+ export interface Options extends CommonOptions {
17
+ /** alias to `sourcemap` */
18
+ sourceMap ?: boolean ;
19
+
17
20
include ?: FilterPattern ;
18
21
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
+
28
23
/**
29
24
* Use this tsconfig file instead
30
25
* Disable it by setting to `false`
31
26
*/
32
27
tsconfig ?: string | false ;
28
+
33
29
/**
34
30
* Map extension to esbuild loader
35
31
* Note that each entry (the extension) needs to start with a dot
@@ -82,14 +78,10 @@ export function esbuild(options: Options): Plugin {
82
78
}
83
79
84
80
const result = await transform ( code , {
81
+ ...options ,
85
82
loader,
86
- target : options . target ,
87
- define : options . define ,
88
- charset : options . charset ,
89
- sourcemap : options . sourceMap ,
90
83
sourcefile : id ,
91
- jsxFactory : options . jsxFactory ,
92
- jsxFragment : options . jsxFragment ,
84
+ sourcemap : options . sourceMap ?? options . sourceMap ,
93
85
} ) ;
94
86
95
87
printWarnings ( id , result , this ) ;
0 commit comments