Skip to content

Commit

Permalink
feat(rollup): allow passing any all common esbuild options
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 27, 2023
1 parent e8988ae commit 8e81e2a
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/builder/plugins/esbuild.ts
Expand Up @@ -2,7 +2,7 @@

import { extname, relative } from "pathe";
import type { Plugin, PluginContext } from "rollup";
import { Loader, TransformResult, Charset, transform } from "esbuild";
import { Loader, TransformResult, CommonOptions, transform } from "esbuild";
import { createFilter } from "@rollup/pluginutils";
import type { FilterPattern } from "@rollup/pluginutils";

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

export interface Options {
export interface Options extends CommonOptions {
/** alias to `sourcemap` */
sourceMap?: boolean;

include?: FilterPattern;
exclude?: FilterPattern;
sourceMap?: boolean;
minify?: boolean;
charset?: Charset;
target: string | string[];
jsxFactory?: string;
jsxFragment?: string;
define?: {
[k: string]: string;
};

/**
* Use this tsconfig file instead
* Disable it by setting to `false`
*/
tsconfig?: string | false;

/**
* Map extension to esbuild loader
* Note that each entry (the extension) needs to start with a dot
Expand Down Expand Up @@ -82,14 +78,10 @@ export function esbuild(options: Options): Plugin {
}

const result = await transform(code, {
...options,
loader,
target: options.target,
define: options.define,
charset: options.charset,
sourcemap: options.sourceMap,
sourcefile: id,
jsxFactory: options.jsxFactory,
jsxFragment: options.jsxFragment,
sourcemap: options.sourceMap ?? options.sourceMap,
});

printWarnings(id, result, this);
Expand Down

0 comments on commit 8e81e2a

Please sign in to comment.