-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
109 lines (104 loc) · 2.74 KB
/
rollup.config.mjs
File metadata and controls
109 lines (104 loc) · 2.74 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { createRequire } from 'node:module';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';
import typescript from 'rollup-plugin-typescript2';
const require = createRequire(import.meta.url);
const packageJson = require('./package.json');
const _isProduction = process.env.NODE_ENV === 'production';
const shouldGenerateSourceMaps = false;
// Base configuration for core (no React, no CSS)
const baseConfig = {
input: 'src/index.ts',
plugins: [
json(),
resolve({
browser: true,
preferBuiltins: false,
exportConditions: ['browser', 'module', 'import'],
}),
commonjs({
include: /node_modules/,
transformMixedEsModules: true,
ignoreTryCatch: false,
}),
typescript({
tsconfig: './tsconfig.json',
useTsconfigDeclarationDir: true,
}),
],
external: [
// Peer dependencies that consumers should install
...Object.keys(packageJson.peerDependencies || {}),
/^viem/,
'buffer',
// External dependencies that consumers should install
'@avail-project/ca-common',
'@tronweb3/tronwallet-abstract-adapter',
// Ensure TronWeb is not bundled to preserve its side-effectful proto setup
'tronweb',
'@cosmjs/proto-signing',
'@cosmjs/stargate',
'@starkware-industries/starkware-crypto-utils',
'@metamask/safe-event-emitter',
'decimal.js',
'long',
'posthog-js',
'msgpackr',
'tslib',
'axios',
'es-toolkit',
],
treeshake: {
// Preserve side effects for external deps like tronweb that rely on global proto init
moduleSideEffects: 'no-external',
propertyReadSideEffects: false,
unknownGlobalSideEffects: false,
},
};
export default defineConfig([
// Build configurations
{
...baseConfig,
output: [
{
file: 'dist/index.js',
format: 'cjs',
sourcemap: shouldGenerateSourceMaps,
exports: 'named',
interop: 'auto',
},
{
file: 'dist/index.esm.js',
format: 'esm',
sourcemap: shouldGenerateSourceMaps,
exports: 'named',
},
],
},
// TypeScript declarations
{
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
plugins: [dts()],
external: [
...Object.keys(packageJson.peerDependencies || {}),
/^viem/,
/^@arcana/,
/^@cosmjs/,
/^@starkware-industries/,
'@metamask/safe-event-emitter',
'@tronweb3/tronwallet-abstract-adapter',
'tronweb',
'decimal.js',
'long',
'msgpackr',
'tslib',
'axios',
'es-toolkit',
'posthog-js',
],
},
]);