-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.ts
71 lines (68 loc) · 2.1 KB
/
rollup.config.ts
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
import { RollupOptions } from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import virtual from '@rollup/plugin-virtual';
import nodeWasm from '@rosen-bridge/rollup-plugin-node-wasm';
import nativePlugin from 'rollup-plugin-natives';
import externals from 'rollup-plugin-node-externals';
const config: RollupOptions = {
input: './src/index.ts',
output: [
{
file: './out/index.cjs',
format: 'cjs',
sourcemap: true,
},
],
plugins: [
/**
* This plugin is needed to resolve wasm-pack based modules correctly.
*/
nodeWasm(),
json(),
/**
* We need to exclude `await-semaphore` because it publishes ts files. The
* ts files causes `resolveId` of this plugin to resolve `await-semaphore`
* imports to the ts files (instead of js ones), which is unexpected.
*/
typescript({ sourceMap: true, exclude: [/await-semaphore/] }),
/**
* This plugin is needed because the `sqlite3` package includes node native
* addons
*/
nativePlugin({
copyTo: './out/libs',
destDir: './libs',
}),
commonjs(),
/**
* This plugin is used to externalize all node native modules
*/
externals({
deps: false,
devDeps: false,
peerDeps: false,
optDeps: false,
}),
/**
* The extra export conditions is needed so that we can resolve `typeorm`
* correctly. The current `exports` field in `package.json` of the package
* is not compatible with the defaults of `nodeResolve` plugin.
*/
nodeResolve({ exportConditions: ['node'], preferBuiltins: false }),
/**
* Most of the following packages are optional peer dependencies which is
* not installed by npm, but included in the bundle, which causes errors. We
* need to virtually resolve them so the errors disappear.
*/
virtual({
'pg-native': '',
nock: '',
'mock-aws-s3': '',
'aws-sdk': '',
}),
],
};
export default config;