-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrollup.config.js
44 lines (42 loc) · 1.12 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
import { promises as fs } from "fs";
import nodeResolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
const zenBabelPlugins = require("zen-observable/scripts/babel-plugins.js");
const babelPlugins = zenBabelPlugins
.filter(name => !name.startsWith("@babel/plugin-transform-modules"))
.map(name => {
if (
name.startsWith("@babel/plugin-transform-classes") ||
name.startsWith("@babel/plugin-transform-for-of")
) {
// These plugins compile to less code (without loss of functionality) if
// we enable "loose" mode.
return [name, { loose: true }];
}
return name;
});
export default [
{
input: ["./src/module.js"],
output: {
file: "module.js",
format: "esm",
},
plugins: [
nodeResolve(),
babel({
plugins: babelPlugins,
babelHelpers: "inline",
}),
{
name: "copy index.cjs to index.cjs.native.js",
async writeBundle() {
await fs.writeFile(
"index.cjs.native.js",
await fs.readFile("index.cjs"),
);
},
},
],
},
];