-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
60 lines (57 loc) · 1.57 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
import path from 'node:path';
// Convert CommonJS modules to ES6
import commonjs from '@rollup/plugin-commonjs';
// Convert .json files to ES6 modules
import json from '@rollup/plugin-json';
// Locate modules using the Node resolution algorithm,
// for using third party modules in node_modules.
import resolve from '@rollup/plugin-node-resolve';
// Minify generated es bundle.
import terser from '@rollup/plugin-terser';
// Enable typescript support for rollup.
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
import pkg from './package.json' assert { type: 'json' };
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
// `@rollup/plugin-typescript` package needs tslib as a peer dependency.
// If not specified, it breaks installation in consumer applications using
// yarn pnp mode.
'tslib',
];
export default defineConfig({
input: 'src/index.ts',
output: [
{
dir: path.dirname(pkg.exports.require),
entryFileNames: '[name].cjs',
exports: 'named',
format: 'cjs',
preserveModules: true,
sourcemap: true,
},
{
dir: path.dirname(pkg.exports.import),
entryFileNames: '[name].js',
exports: 'named',
format: 'esm',
preserveModules: true,
sourcemap: true,
},
],
plugins: [
json(),
commonjs(),
resolve(),
terser(),
typescript({
noEmit: true,
emitDeclarationOnly: false,
declaration: false,
outDir: undefined,
}),
],
external,
treeshake: 'smallest',
});