forked from civiccc/react-waypoint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
40 lines (32 loc) · 847 Bytes
/
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
import babel from '@rollup/plugin-babel';
import pkg from './package.json';
const depsSet = new Set([
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
]);
/**
* @param {'es' | 'cjs'} format
*/
function makeBuild(format) {
return {
input: 'src/waypoint.jsx',
external: (id) => {
if (id.startsWith('.') || id.startsWith('/')) {
return false;
}
const packageName = id.startsWith('@')
? id.split('/').slice(0, 2).join('/')
: id.split('/')[0];
return depsSet.has(packageName);
},
output: [{ file: format === 'es' ? pkg.module : pkg.main, format }],
plugins: [
babel({
babelHelpers: 'runtime',
envName: format,
exclude: ['node_modules/**'],
}),
],
};
}
export default [makeBuild('es'), makeBuild('cjs')];