-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrollup.config.js
More file actions
49 lines (46 loc) · 1.23 KB
/
Copy pathrollup.config.js
File metadata and controls
49 lines (46 loc) · 1.23 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
import typescript from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
import { readFileSync } from 'fs'
// Read package.json to get dependencies
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
const external = [
// Don't bundle dependencies - they should be installed by consumers
...Object.keys(pkg.dependencies || {}),
// Don't bundle Node.js built-ins
'fs', 'path', 'util', 'stream', 'events', 'http', 'https', 'url',
// Handle deep imports from dependencies (e.g., 'fp-ts/function', 'io-ts/PathReporter')
/^fp-ts\//,
/^io-ts\//,
/^axios/
]
export default [
// JavaScript bundle
{
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'cjs',
sourcemap: false
},
external,
plugins: [
typescript({
tsconfig: './tsconfig.json',
declaration: false, // dts plugin handles declarations
compilerOptions: {
module: 'ESNext' // Override tsconfig - Rollup needs ES modules as input
}
})
]
},
// TypeScript declarations bundle
{
input: 'src/index.ts',
output: {
file: 'dist/index.d.ts',
format: 'es'
},
external,
plugins: [dts({ tsconfig: './tsconfig.json' })]
}
]