-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
62 lines (60 loc) · 1.53 KB
/
rollup.config.js
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
import ts from '@rollup/plugin-typescript';
import { builtinModules } from 'node:module';
import path from 'node:path';
import { defineConfig } from 'rollup';
import flatDts from 'rollup-plugin-flat-dts';
import typescript from 'typescript';
const externalModules = new Set([...builtinModules, 'deepmerge', 'jest', 'typescript']);
export default defineConfig({
input: {
'project-config': './src/mod.ts',
'rollup.config': './src/rollup.config.js/main.ts',
},
plugins: [
ts({
typescript,
tsconfig: './tsconfig.main.json',
cacheDir: 'target/.ts_cache',
}),
],
external(id) {
return (
id.startsWith('node:') ||
externalModules.has(id) ||
id.startsWith('rollup') ||
id.startsWith('@run-z/') ||
id.startsWith('@rollup/')
);
},
output: {
dir: 'dist',
format: 'esm',
sourcemap: true,
entryFileNames: '[name].js',
chunkFileNames: '_[name].js',
manualChunks(id) {
if (id.startsWith(path.resolve('src', 'rollup.config.js'))) {
return 'rollup.config.js';
}
if (id.startsWith(path.resolve('src'))) {
return 'project-config';
}
},
plugins: [
flatDts({
tsconfig: './tsconfig.main.json',
lib: true,
file: 'project-config.d.ts',
compilerOptions: {
declarationMap: true,
},
entries: {
'rollup.config.js': {
file: './rollup.config.d.ts',
},
},
internal: ['**/impl/**', '**/*.impl'],
}),
],
},
});