-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
65 lines (58 loc) · 1.36 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
import type { Options } from 'tsup';
import { defineConfig } from 'tsup';
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
// import { umdWrapper } from "esbuild-plugin-umd-wrapper"
const baseConfig: Options = {
name: "riscript",
entry: { riscript: 'src/index.js' },
outDir: 'dist',
watch: false,
clean: true,
minify: false,
sourcemap: true,
bundle: true,
dts: false,
target: 'es2020',
esbuildPlugins: [
esbuildPluginVersionInjector(),
// umdWrapper(),
],
outExtension({ format }) { return { js: `.js` } },
}
const esm: Options = {
...baseConfig,
format: ['esm'],
}
const cjs: Options = {
...baseConfig,
format: ['cjs'],
noExternal: ['chevrotain'],
platform: "node",
cjsInterop: true,
splitting: true,
outExtension({ format }) { return { js: `.cjs` } },
}
const iife: Options = {
...baseConfig,
format: ['iife'],
minify: true,
platform: "browser",
globalName: "iife",
footer: { js: "RiScript = iife.RiScript" },
outExtension({ format }) { return { js: `.min.js` } }
}
const testEsm: Options = {
format: ['esm'],
target: 'es2020', // ?
platform: "node",
name: "test",
entry: ['test/*.tests.js'],
outDir: 'test/dist',
watch: false,
clean: false,
minify: false,
sourcemap: false,
dts: false,
bundle: false,
}
export default defineConfig([esm, cjs, iife, testEsm]);