-
Notifications
You must be signed in to change notification settings - Fork 1
/
bundleTypes.js
52 lines (47 loc) · 1.33 KB
/
bundleTypes.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
const { gray, red, green } = require('kleur/colors')
const { startTask } = require('misty/task')
const path = require('path')
const rollup = require('rollup')
const dts = require('rollup-plugin-dts').default
const ts = require('typescript')
const outFile = 'src/dist/bundle/index.d.ts'
async function run() {
const bundle = await rollup.rollup({
input: 'src/bundle/runtime/bundle/api.ts',
external: id => !/^[./]/.test(id),
plugins: [
dts({
// compilerOptions: ts.parseJsonConfigFileContent(
// ts.readConfigFile(
// path.resolve('src/client/tsconfig.json'),
// ts.sys.readFile
// ).config,
// ts.sys,
// path.resolve('src/client')
// ).options,
compilerOptions: {
lib: ['lib.dom.d.ts', 'lib.es2019.d.ts'],
module: ts.ModuleKind.ESNext,
types: [path.resolve('src/dist/env/client')],
},
}),
reporter,
],
})
await bundle.write({
file: outFile,
format: 'es',
})
}
const task = startTask(`bundling types...`, { spinner: false })
const reporter = {
async load(id) {
console.log(gray(`load`), path.relative(process.cwd(), id))
},
}
run()
.then(
() => task.finish(`saved types to ${green(outFile)}`),
e => console.error(red(e.message))
)
.then(() => task.finish())