Skip to content

Commit d95b335

Browse files
committed
feat: allow overriding default options
1 parent 032a197 commit d95b335

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/main.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import type sourcemaps from "rollup-plugin-sourcemaps"
88
import type replace from "@rollup/plugin-replace"
99
// @ts-ignore
1010
import type autoExternal from "rollup-plugin-auto-external"
11-
1211
import type typescript from "@rollup/plugin-typescript"
12+
// @ts-ignore
1313
import type coffeescript from "rollup-plugin-coffee-script"
1414
import type json from "@rollup/plugin-json"
15+
// @ts-ignore
1516
import type cssOnly from "rollup-plugin-css-only"
1617
import type babel from "@rollup/plugin-babel"
1718
import type { wasm } from "@rollup/plugin-wasm"
19+
// @ts-ignore
1820
import type { asc } from "rollup-plugin-assemblyscript"
1921

2022
export type Plugin =
@@ -31,18 +33,18 @@ export type Plugin =
3133
| "sourcemaps"
3234
| "commonjs"
3335
| "resolve"
34-
| ["ts", typeof typescript]
35-
| ["babel", typeof babel]
36-
| ["coffee", typeof coffeescript]
37-
| ["json", typeof json]
38-
| ["css", typeof cssOnly]
39-
| ["wasm", typeof wasm]
40-
| ["as", typeof asc]
41-
| ["terser", typeof terser]
42-
| ["replace", typeof replace]
43-
| ["sourcemaps", typeof sourcemaps]
44-
| ["commonjs", typeof commonjs]
45-
| ["resolve", typeof resolve]
36+
| ["ts", typeof typescript, boolean?]
37+
| ["babel", typeof babel, boolean?]
38+
| ["coffee", typeof coffeescript, boolean?]
39+
| ["json", typeof json, boolean?]
40+
| ["css", typeof cssOnly, boolean?]
41+
| ["wasm", typeof wasm, boolean?]
42+
| ["as", typeof asc, boolean?]
43+
| ["terser", typeof terser, boolean?]
44+
| ["replace", typeof replace, boolean?]
45+
| ["sourcemaps", typeof sourcemaps, boolean?]
46+
| ["commonjs", typeof commonjs, boolean?]
47+
| ["resolve", typeof resolve, boolean?]
4648

4749
export function createPlugins(
4850
inputPluginsNames: Array<Plugin> = ["ts", "js", "json", "coffee"],
@@ -193,6 +195,9 @@ export function createPlugins(
193195
if (typeof inputPluginsNames[index] === "string") {
194196
// plugin name only
195197
plugins.push(pluginFunction(pluginDefaultOptions))
198+
} else if (typeof inputPluginsNames[index][2] === "boolean" && inputPluginsNames[index][2] === true) {
199+
// plugin with options that override pluginDefaultOptions
200+
plugins.push(pluginFunction( {...pluginDefaultOptions, ...inputPluginsNames[index][1]}))
196201
} else {
197202
// plugin with options
198203
plugins.push(pluginFunction(inputPluginsNames[index][1]))

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// function to check if the first array has any of the second array
22
// first array can have `[string, object]` as their input
3-
export function includesAny(arr1: Array<string | [string, Object]>, arr2: Array<string>): null | number {
3+
export function includesAny(arr1: Array<string | [string, Object, boolean?]>, arr2: Array<string>): null | number {
44
for (let index = 0; index < arr1.length; index++) {
55
const elm = arr1[index]
66
let name: string

0 commit comments

Comments
 (0)