-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.mjs
41 lines (39 loc) · 1.08 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
import {
DependencyCategory,
createRollupConfig,
dtsPresetConfigBuilder,
modify,
tsPresetConfigBuilder,
} from '@guanghechen/rollup-config'
import fs from 'node:fs/promises'
import path from 'node:path'
const builtins = new Set([])
const externals = new Set([])
export default async function rollupConfig() {
const manifestPath = path.resolve('package.json')
const manifestRaw = await fs.readFile(manifestPath, 'utf8')
const manifest = JSON.parse(manifestRaw)
const config = await createRollupConfig({
manifest,
presetConfigBuilders: [
tsPresetConfigBuilder({
typescriptOptions: {
tsconfig: 'tsconfig.lib.json',
},
additionalPlugins: [modify()],
}),
dtsPresetConfigBuilder({
dtsOptions: {
respectExternal: true,
tsconfig: 'tsconfig.lib.json',
},
}),
],
classifyDependency: id => {
if (builtins.has(id)) return DependencyCategory.BUILTIN
if (externals.has(id)) return DependencyCategory.EXTERNAL
return DependencyCategory.UNKNOWN
},
})
return config
}