-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrollup.config.mjs
45 lines (41 loc) · 1.12 KB
/
rollup.config.mjs
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
import path from 'path';
import { fileURLToPath } from 'url';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const input = path.resolve(__dirname, 'src', 'index.js');
const cjsOutputDirectory = path.resolve(__dirname, 'dist', 'cjs');
const esmOutputDirectory = path.resolve(__dirname, 'dist', 'esm');
const isExternal = id => !id.startsWith('.') && !id.startsWith('/');
export default [
{
input,
output: {
dir: cjsOutputDirectory,
format: 'cjs',
// https://rollupjs.org/guide/en/#changed-defaults
// https://rollupjs.org/guide/en/#outputinterop
interop: 'auto',
preserveModules: true,
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
],
},
{
input,
output: {
dir: esmOutputDirectory,
format: 'esm',
preserveModules: true,
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
],
}
];