-
Notifications
You must be signed in to change notification settings - Fork 254
/
rollup.config.mjs
78 lines (75 loc) · 2.07 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { RequireRewriter } from './etc/rollup/rollup-plugin-require-rewriter/require_rewriter.mjs';
import { RequireVendor } from './etc/rollup/rollup-plugin-require-vendor/require_vendor.mjs';
/** @type {typescript.RollupTypescriptOptions} */
const tsConfig = {
allowJs: false,
checkJs: false,
strict: true,
alwaysStrict: true,
target: 'es2021',
module: 'esnext',
moduleResolution: 'node',
removeComments: true,
lib: ['es2021', 'ES2022.Error'],
importHelpers: false,
noEmitHelpers: false,
noEmitOnError: true,
// preserveConstEnums: false is the default, but we explicitly set it here to ensure we do not mistakenly generate objects where we expect literals
preserveConstEnums: false,
// Generate separate source maps files with sourceContent included
sourceMap: true,
inlineSourceMap: false,
inlineSources: false,
// API-extractor makes use of the declarations, npm script should be cleaning these up
declaration: false,
types: [],
tsconfig: false,
include: ['src/**/*']
};
const input = 'src/index.ts';
/** @type {import('rollup').RollupOptions} */
const config = [
{
input,
plugins: [typescript(tsConfig), nodeResolve({ resolveOnly: [] })],
output: [
{
file: 'lib/bson.cjs',
format: 'commonjs',
exports: 'named',
sourcemap: true
},
{
file: 'lib/bson.bundle.js',
format: 'iife',
name: 'BSON',
exports: 'named',
indent: false,
sourcemap: true
}
]
},
{
input,
plugins: [typescript(tsConfig), new RequireRewriter(), nodeResolve({ resolveOnly: [] })],
output: {
file: 'lib/bson.mjs',
format: 'esm',
sourcemap: true
}
},
{
input,
plugins: [typescript(tsConfig), new RequireVendor(), nodeResolve({ resolveOnly: [] })],
output: {
file: 'lib/bson.rn.cjs',
format: 'commonjs',
exports: 'named',
sourcemap: true
},
treeshake: false
}
];
export default config;