Skip to content

Commit 73d8a64

Browse files
authored
Merge pull request #70 from atom-community/override-by-default
2 parents e4b294f + 1a87dce commit 73d8a64

File tree

3 files changed

+18
-41
lines changed

3 files changed

+18
-41
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,32 @@ terser (in production)
8888
replace (in production)
8989
```
9090

91-
### Override Default Options for the plugins `[name, overriddenOptions, true]`
91+
### Override Default Options for the plugins `[name, overriddenOptions]`
9292

93-
You can pass an input plugin with the overridden options using the `[name, overriddenOptions, true]` syntax.
93+
You can pass an input plugin with the overridden options using the `[name, overriddenOptions]` syntax.
9494

9595
```ts
96-
const plugins = createPlugins([
97-
["ts", { tsconfig: "./lib/tsconfig.json" }, true], // third element makes the config merge to and override the default options
98-
"js",
99-
])
96+
const plugins = createPlugins([["ts", { tsconfig: "./lib/tsconfig.json" }], "js"])
10097
```
10198

102-
The difference with the next syntax is that these are merged into the default options and if there is a config with the same name, they override it, but the next syntax completely replaces the default options.
99+
### Completely New Options for the plugins `[name, newOptions, false]`
103100

104-
### Completely New Options for the plugins `[name, newOptions]`
105-
106-
You can pass an input plugin with their supported option using the `[name, newOptions]` syntax:
101+
You can pass an input plugin with their supported option using the `[name, newOptions, false]` syntax:
107102

108103
```ts
109104
const plugins = createPlugins([
110-
["ts", { tsconfig: "./lib/tsconfig.json", noEmitOnError: false, module: "ESNext" }],
105+
["ts", { tsconfig: "./lib/tsconfig.json", noEmitOnError: false, module: "ESNext" }, false],
111106
"js",
112107
])
113108
```
114109

110+
Passing false as the third argument results in discarding the `rollup-config-atomic` built-in options.
111+
115112
### Adding New Extra Plugins
116113

117-
For adding extra plugins, you can pass them in array to the second argument
114+
For adding extra plugins, you can simply concatenate your plugins with the output of `createPlugins`
118115

119116
```ts
120117
import multyentry from "@rollup/plugin-multi-entry"
121-
createPlugins(["ts"], [multyentry()])
118+
const plugins = [...createPlugins(["ts"]), multyentry()]
122119
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"rollup-plugin-sourcemaps": "^0.6.3",
5858
"rollup-plugin-terser": "7.0.2",
5959
"rollup-plugin-visualizer": "^5.5.2",
60-
"tslib": "^2.3.0",
60+
"tslib": "^2.3.1",
6161
"rollup": "^2",
6262
"@babel/core": "^7",
6363
"typescript": "^4"

src/main.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export function createPlugins(
132132

133133
// extra plugins
134134
if (extraPlugins !== undefined && typeof extraPlugins === "object" /*array*/) {
135+
console.warn(
136+
"Passing extra plugins to `createPlugins` is deprecated. Instead concatenate the output of `createPlugins` with your extra plugins."
137+
)
135138
try {
136139
plugins.push(...extraPlugins)
137140
} catch (e) {
@@ -225,7 +228,10 @@ export function createPlugins(
225228
if (typeof inputPluginsNames[index] === "string") {
226229
// plugin name only
227230
plugins.push(pluginFunction(pluginDefaultOptions))
228-
} else if (typeof inputPluginsNames[index][2] === "boolean" && inputPluginsNames[index][2] === true) {
231+
} else if (inputPluginsNames[index].length == 3 && inputPluginsNames[index][2] === false) {
232+
// plugin with options from scratch
233+
plugins.push(pluginFunction(inputPluginsNames[index][1]))
234+
} else {
229235
// plugin with options that override pluginDefaultOptions
230236
const pluginOptions = inputPluginsNames[index][1]
231237
plugins.push(
@@ -235,9 +241,6 @@ export function createPlugins(
235241
: { ...pluginDefaultOptions, pluginOptions }
236242
)
237243
)
238-
} else {
239-
// plugin with options
240-
plugins.push(pluginFunction(inputPluginsNames[index][1]))
241244
}
242245
} else if (includeByDefault) {
243246
const pluginFunction = getPluginFunction(require(moduleName), prop)
@@ -247,26 +250,3 @@ export function createPlugins(
247250

248251
return plugins
249252
}
250-
251-
/** @deprecated Use default Rollup syntax - this function will be removed in the next major version */
252-
export function createConfig(
253-
input: string | Array<string> = "src/main.ts",
254-
output_dir: string = "dist",
255-
output_format = "cjs",
256-
externals: Array<string> = ["atom", "electron"],
257-
plugins = createPlugins()
258-
) {
259-
return {
260-
input: input,
261-
output: [
262-
{
263-
dir: output_dir,
264-
format: output_format,
265-
sourcemap: true,
266-
},
267-
],
268-
// loaded externally
269-
external: externals,
270-
plugins: plugins,
271-
}
272-
}

0 commit comments

Comments
 (0)