forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.base.config.ts
61 lines (57 loc) · 1.75 KB
/
tsup.base.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
import { type Options } from 'tsup';
import { babelPlugin, defaultPredicate, type Predicate } from './esbuildBabelPluginIstanbul';
type Target = Exclude<Options['target'], Array<unknown> | undefined>;
const env = process.env.NODE_ENV || 'development';
const { npm_package_version } = process.env;
const istanbulPredicate: Predicate = args => defaultPredicate(args) && !/\.worker\.[cm]?[jt]s$/u.test(args.path);
const baseConfig: Options & { target: Target[] } = {
dts: true,
env: {
build_tool: 'tsup',
module_format: 'esmodules',
node_env: env,
NODE_ENV: env,
...(npm_package_version ? { npm_package_version } : {})
},
esbuildOptions: options => {
options.legalComments = 'linked';
},
esbuildPlugins:
env === 'test'
? [
babelPlugin({
filter: /\.[cm]?js$/u,
loader: 'jsx',
name: 'babel-plugin-istanbul:js',
predicate: istanbulPredicate
}),
babelPlugin({
filter: /\.jsx$/u,
loader: 'jsx',
name: 'babel-plugin-istanbul:jsx',
predicate: istanbulPredicate
}),
babelPlugin({
filter: /\.[cm]?ts$/u,
loader: 'ts',
name: 'babel-plugin-istanbul:ts',
predicate: istanbulPredicate
}),
babelPlugin({
filter: /\.tsx$/u,
loader: 'tsx',
name: 'babel-plugin-istanbul:tsx',
predicate: istanbulPredicate
})
]
: [],
format: 'esm',
loader: { '.js': 'jsx' },
metafile: true,
minify: env === 'production',
platform: 'browser',
sourcemap: true,
splitting: true,
target: ['chrome100', 'firefox100', 'safari15'] satisfies Target[]
};
export default baseConfig;