-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
76 lines (71 loc) · 1.7 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
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
import * as path from 'path'
import * as url from 'url'
import alias from '@rollup/plugin-alias'
import typescript from '@rollup/plugin-typescript'
import { dts } from 'rollup-plugin-dts'
/**
* We have a internal circular dependency in the compiler,
* which is intentional. We think in this case Rollup is too noisy.
*
* @param {import('rollup').RollupLog} warning
* @returns {boolean}
*/
function isInternalCircularDependency(warning) {
return (
warning.code == 'CIRCULAR_DEPENDENCY' &&
warning.message.includes('src/compiler') &&
!warning.message.includes('node_modules')
)
}
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const aliasEntries = {
entries: [{ find: '$promptl', replacement: path.resolve(__dirname, 'src') }],
}
/** @type {import('rollup').RollupOptions} */
export default [
{
onwarn: (warning, warn) => {
if (isInternalCircularDependency(warning)) return
warn(warning)
},
input: 'src/index.ts',
output: [
{
file: 'dist/index.js',
sourcemap: true,
},
{
file: 'dist/index.cjs',
format: 'cjs',
sourcemap: true,
},
],
plugins: [
typescript({
noEmit: true,
tsconfig: './tsconfig.json',
exclude: ['**/__tests__', '**/*.test.ts'],
}),
],
external: [
'acorn',
'locate-character',
'code-red',
'node:crypto',
'yaml',
'crypto',
'zod',
],
},
{
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [
alias(aliasEntries),
dts({
tsconfig: './tsconfig.json',
exclude: ['**/__tests__', '**/*.test.ts'],
}),
],
},
]