-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsup.config.ts
76 lines (74 loc) · 1.69 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
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig } from 'tsup'
import { workerScriptPlugin } from './config/plugins/esbuild/workerScriptPlugin'
// Prevent from bunlding the "@mswjs/*" packages
// so that the users get the latest versions without
// having to bump them in "msw'."
const ecosystemDependencies = /^@mswjs\/(.+)$/
export default defineConfig([
{
name: 'main',
entry: ['./src/index.ts'],
outDir: './lib',
format: ['cjs'],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: false,
esbuildPlugins: [workerScriptPlugin()],
},
{
name: 'iife',
entry: ['./src/index.ts'],
outDir: './lib',
legacyOutput: true,
format: ['iife'],
platform: 'browser',
globalName: 'MockServiceWorker',
bundle: true,
sourcemap: true,
splitting: false,
dts: false,
esbuildPlugins: [workerScriptPlugin()],
},
{
name: 'node',
entry: ['./src/node/index.ts'],
format: ['esm', 'cjs'],
outDir: './lib/node',
platform: 'node',
external: [
'http',
'https',
'util',
'events',
'tty',
'os',
'timers',
ecosystemDependencies,
],
clean: true,
inject: ['./config/polyfills-node.ts'],
sourcemap: true,
dts: false,
esbuildPlugins: [workerScriptPlugin()],
},
{
name: 'native',
entry: ['./src/native/index.ts'],
format: ['esm', 'cjs'],
outDir: './lib/native',
clean: true,
external: ['chalk', 'util', 'events', ecosystemDependencies],
},
{
name: 'typedefs',
entry: ['./src/index.ts', './src/node/index.ts', './src/native/index.ts'],
outDir: './lib',
clean: false,
dts: {
only: true,
},
},
])