Skip to content

Commit a6092f5

Browse files
committed
fix: add try catch to warn about passing extra plugins as an array
1 parent 9658039 commit a6092f5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use `createPlugins` to create the plugins you need.
5353
```ts
5454
createPlugins(
5555
inputPlugins: Array<Plugin> = ["ts", "babel", "json", "coffee"], // languages/plugins you use
56-
extraPlugins?: Array<any> // pass any extra plugins functions like `multientry()`
56+
extraPlugins?: Array<any> // pass any extra plugins functions as an array like `[multientry()]`
5757
)
5858
```
5959

@@ -77,7 +77,7 @@ createPlugins(["ts", {noEmitOnError: false, tsconfig: "./lib/tsconfig.json"})
7777
For adding extra plugins, you can:
7878
```ts
7979
import multyentry from '@rollup/plugin-multi-entry'
80-
createPlugins(["ts", multyentry())
80+
createPlugins(["ts", [multyentry()])
8181
```
8282
8383
### createConfig

src/main.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,21 @@ export function createPlugins(
165165

166166
// extra plugins
167167
if (typeof extraPlugins !== "boolean" && extraPlugins !== undefined) {
168-
plugins.push(...extraPlugins);
168+
try {
169+
plugins.push(...extraPlugins);
170+
}
171+
catch (e) {
172+
console.error("You should pass extraPlugins as an array")
173+
}
169174
}
170175

171176
if (extraPluginsDeprecated) {
172-
plugins.push(...extraPluginsDeprecated);
177+
try {
178+
plugins.push(...extraPluginsDeprecated);
179+
}
180+
catch (e) {
181+
console.error("You should pass extraPluginsDeprecated as an array")
182+
}
173183
}
174184

175185
let pluginsCommon = [

0 commit comments

Comments
 (0)