forked from jotaijs/jotai-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
63 lines (56 loc) · 1.65 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { replace } from 'esbuild-plugin-replace';
import { Options, defineConfig } from 'tsup';
const defaultOutExtension: Options['outExtension'] = ({ format }) => {
return {
js: `.${format}.js`,
};
};
const defaultEsBuildPlugins: Options['esbuildPlugins'] = [
replace({
// FIXME - Should filter it by `include` instead of `exclude`. This doesn't seem to be working /^.*\.js$/,
exclude: /\.woff2$/,
__DEV__: '(process.env.NODE_ENV!=="production")',
}),
];
const baseConfig: Options = {
// Outputs `dist/index.js` and `dist/utils.js`
entry: {
index: 'src/index.ts',
// Workaround to generate seperate chunks for DevTools so we could export a null component for production builds
internal__devtools: 'src/DevTools/index.ts',
utils: 'src/utils/index.ts',
},
loader: {
'.woff2': 'dataurl',
},
sourcemap: false,
// Clean output directory before each build
clean: true,
minify: false,
splitting: true,
tsconfig: './tsconfig.build.json',
dts: true,
external: ['jotai', 'react', 'react-dom'],
noExternal: ['@tabler/icons-react'],
platform: 'node',
outExtension: defaultOutExtension,
esbuildPlugins: defaultEsBuildPlugins,
// // TSUP does not appear to be respecting tsconfig's jsx property
// // See - https://github.com/egoist/tsup/issues/792
inject: ['./react-shim.js'],
};
const cjsConfig: Options = {
...baseConfig,
format: ['cjs'],
};
const mjsOutExtension: Options['outExtension'] = ({ format }) => {
return {
js: `.${format}.mjs`,
};
};
const mjsConfig: Options = {
...baseConfig,
format: ['esm'],
outExtension: mjsOutExtension,
};
export default defineConfig([cjsConfig, mjsConfig]);