forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 4
/
tsup.base.config.ts
56 lines (54 loc) · 1.61 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
import { defineConfig, type Options } from 'tsup';
import { babelPlugin, defaultPredicate, type Predicate } from './esbuildBabelPluginIstanbul';
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);
export default defineConfig({
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,
target: ['chrome100', 'firefox100', 'safari15']
}) as Options;