-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtsup.config.ts
37 lines (32 loc) · 936 Bytes
/
tsup.config.ts
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
import { defineConfig } from 'tsup'
import * as preset from 'tsup-preset-solid'
import pkg from './package.json'
const preset_options: preset.PresetOptions = {
entries: [
{
entry: 'src/index.tsx',
server_entry: true,
}
],
drop_console: true,
cjs: true,
}
export default defineConfig(config => {
const watching = !!config.watch
const parsedOptions = preset.parsePresetOptions(preset_options, watching)
if (!watching) {
const package_fields = preset.generatePackageExports(parsedOptions)
console.log(`\npackage.json: \n${JSON.stringify(package_fields, null, 2)}\n\n`)
preset.writePackageJson(package_fields)
}
const tsupOptions = preset
.generateTsupOptions(parsedOptions)
.map((tsupOption) => ({
...tsupOption,
name: pkg.name,
dts: !tsupOption.dts ? undefined : {
footer: `declare module '${pkg.name}'`,
},
}));
return tsupOptions;
});