-
Notifications
You must be signed in to change notification settings - Fork 41
/
rollup.config.mjs
46 lines (44 loc) · 1.2 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
46
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import filesize from 'rollup-plugin-filesize';
import external from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json' with { type: 'json' };
const extensions = ['.ts', '.tsx'];
export default {
input: 'src/index.tsx',
output: {
file: pkg.main,
format: 'cjs',
sourcemap: true,
exports: 'named',
// Use 'auto' instead of 'default' for better interoperability with CRA etc.
// https://rollupjs.org/guide/en/#outputinterop
interop: 'auto',
// Rollup does not support this React Server Components directive yet.
// https://github.com/rollup/rollup/issues/4699
banner: `'use client';`,
},
plugins: [
external({
includeDependencies: true,
}),
postcss({
modules: true,
}),
babel({
extensions,
babelHelpers: 'bundled',
}),
resolve({
extensions,
}),
filesize(),
],
onwarn(warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && warning.message.includes('use client')) {
return; // ignore the error for now
}
warn(warning);
},
};