-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
64 lines (60 loc) · 1.76 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import path from "path";
import alias from "@rollup/plugin-alias";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import { keys } from "ramda";
import analyze from "rollup-plugin-analyzer";
import cleaner from "rollup-plugin-cleaner";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import packageJSON from "./package.json";
import { globSync } from "glob";
const rootResolve = require("./resolve.js");
const globals = Object.fromEntries(
keys(packageJSON.peerDependencies).map(lib => [lib, lib])
);
export default {
input: `./src/index.js`,
output: [
{
inlineDynamicImports: true,
file: `index.cjs.js`,
format: "cjs",
sourcemap: true,
name: `neeto-cist/index`,
globals,
},
{
inlineDynamicImports: true,
file: `index.mjs`,
format: "esm",
sourcemap: true,
name: `neeto-cist/index`,
globals,
},
],
plugins: [
// To delete previously existing bundle.
cleaner({ targets: globSync(path.resolve(__dirname, `index.*`)) }),
// Analyze created bundle.
analyze({ summaryOnly: true }),
// To automatically externalize peerDependencies in a rollup bundle.
peerDepsExternal(),
// To use third party modules from node_modules
resolve({
extensions: [".js", ".jsx", ".svg"],
}),
// To define aliases when bundling packages.
alias({ entries: rootResolve.alias }),
// To convert .json files to ES6 modules.
json(),
// To integrate Rollup and Babel.
babel({
exclude: /node_modules\/(?!immer)/,
babelHelpers: "runtime",
}),
// To convert CommonJS modules to ES6.
commonjs(),
],
};