-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
49 lines (47 loc) · 1.04 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
import { defineConfig, Options } from "tsup";
export default defineConfig((options) => {
const commonOptions: Partial<Options> = {
clean: true,
entry: {
index: "src/index.ts",
},
sourcemap: true,
...options,
};
return [
// Modern ESM
{
...commonOptions,
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
dts: true,
outDir: "./lib/esm/",
},
// Support Webpack 4 by pointing `"module"` to a file with a `.js` extension
{
...commonOptions,
entry: {
"index.legacy-esm": "src/index.ts",
},
format: ["esm"],
outExtension: () => ({ js: ".js" }),
target: "es2017",
outDir: "./lib/esm/",
},
// CJS
{
...commonOptions,
format: ["cjs"],
outExtension: () => ({ js: ".cjs" }),
dts: true,
outDir: "./lib/cjs/",
},
// CJS old extension
{
...commonOptions,
format: ["cjs"],
outExtension: () => ({ js: ".js" }),
outDir: "./lib/cjs/",
},
] as Options[];
});