Skip to content

Commit fae7c7e

Browse files
committed
major: API changes readme
1 parent 3de9d1b commit fae7c7e

File tree

1 file changed

+53
-32
lines changed

1 file changed

+53
-32
lines changed

README.md

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ You should also install the peer dependencies:
1313
```
1414
"rollup": "2.21.0",
1515
```
16+
1617
and the following (only those that you use are needed):
18+
1719
```
1820
"typescript": "^3.9.6",
1921
"coffeescript": "^1.12.7",
@@ -25,34 +27,54 @@ and the following (only those that you use are needed):
2527
Create a `rollup.config.js` file at the root of the project with the following content. See API section for more details
2628

2729
```js
28-
const { createPlugins, createConfig } = require("rollup-plugin-atomic");
30+
const { createPlugins } = require("rollup-plugin-atomic");
2931

3032
const plugins = createPlugins(["ts", "js"], true);
3133

32-
const config = createConfig(
33-
"src/main.ts",
34-
"dist",
35-
"cjs",
36-
["atom", "electron", "node-pty-prebuilt-multiarch"],
37-
plugins
38-
);
39-
40-
module.exports = config;
34+
module.exports = {
35+
input: "src/main.ts",
36+
output: [
37+
{
38+
dir: "dist",
39+
format: "cjs",
40+
sourcemap: true,
41+
},
42+
],
43+
plugins: plugins,
44+
};
4145
```
4246

4347
## API
4448

49+
### createPlugins
50+
4551
use `createPlugins` to create the plugins you need.
4652

4753
```ts
4854
createPlugins(
49-
languages: Array<string> = ["ts", "js", "json", "coffee"], // languages you use
50-
babel: boolean = true, // if you want to use babel
55+
inputPlugins: Array<Plugin> = ["ts", "babel", "json", "coffee"], // languages/plugins you use
5156
extraPlugins?: Array<any> // pass any extra plugins functions like `multientry()`
5257
)
5358
```
5459

55-
use `createConfig` to create the configs you need
60+
which `inputPlugins` is among these:
61+
```
62+
ts
63+
babel
64+
coffee
65+
json
66+
css
67+
(js is considered by default)
68+
```
69+
70+
You can pass an input plugin with their supported option:
71+
```js
72+
createPlugins(["ts", {noEmitOnError: false, tsconfig: "./lib/tsconfig.json"})
73+
```
74+
75+
### createConfig
76+
77+
You can use `createConfig` to create the configs you need. This is a simple wrapper around the rollup config.
5678

5779
```ts
5880
createConfig(
@@ -63,28 +85,27 @@ createConfig(
6385
plugins = createPlugins() // pass the plugins you created using `createPlugins()`
6486
)
6587
```
66-
You can create multiple configs using `createConfig` and export them as an array:
67-
```js
68-
module.exports = [config1, config2]
69-
```
7088

71-
## Only using createPlugins:
89+
An example that uses `createConfig`:
7290

73-
you can only use `createPlugins` and then export your config with the typical rollup style:
7491
```js
75-
const { createPlugins } = require("rollup-plugin-atomic");
92+
const { createPlugins, createConfig } = require("rollup-plugin-atomic");
7693

77-
const plugins = createPlugins(["ts", "js"], true);
94+
const plugins = createPlugins(["ts", "js"]);
7895

79-
module.exports = {
80-
input: "src/main.ts",
81-
output: [
82-
{
83-
dir: "dist",
84-
format: "cjs",
85-
sourcemap: true,
86-
},
87-
],
88-
plugins: plugins,
89-
}
96+
const config = createConfig(
97+
"src/main.ts",
98+
"dist",
99+
"cjs",
100+
["atom", "electron", "node-pty-prebuilt-multiarch"],
101+
plugins
102+
);
103+
104+
module.exports = config;
105+
```
106+
107+
You can create multiple configs using `createConfig` and export them as an array:
108+
109+
```js
110+
module.exports = [config1, config2];
90111
```

0 commit comments

Comments
 (0)