forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
44 lines (37 loc) · 1.07 KB
/
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
38
39
40
41
42
43
44
import type { Options } from 'tsup';
import { defineConfig } from 'tsup';
import { runAfterLast } from '../../scripts/utils';
// @ts-ignore
import { name, version } from './package.json';
export default defineConfig(overrideOptions => {
const isWatch = !!overrideOptions.watch;
const shouldPublish = !!overrideOptions.env?.publish;
const common: Options = {
entry: ['./src/**/*.{ts,tsx,js,jsx}'],
bundle: false,
clean: true,
minify: false,
sourcemap: true,
legacyOutput: true,
define: {
PACKAGE_NAME: `"${name}"`,
PACKAGE_VERSION: `"${version}"`,
__DEV__: `${isWatch}`,
},
};
const onSuccess = (format: 'esm' | 'cjs') => {
return `cp ./package.${format}.json ./dist/${format}/package.json`;
};
const esm: Options = {
...common,
format: 'esm',
onSuccess: onSuccess('esm'),
};
const cjs: Options = {
...common,
format: 'cjs',
outDir: './dist/cjs',
onSuccess: onSuccess('cjs'),
};
return runAfterLast(['npm run build:declarations', shouldPublish && 'npm run publish:local'])(esm, cjs);
});