-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
tsup.config.ts
114 lines (112 loc) · 2.54 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { defineConfig } from "tsup";
import esbuildPluginLicense from "esbuild-plugin-license";
const licenseNoticeOpts = {
banner: `
/*!
* <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %>
* Find third-party licenses in LICENSE.txt
*/
`,
thirdParty: {
output: {
file: "LICENSE.txt",
template(dependencies: any) {
return dependencies
.map(
(dep: any) =>
`${dep.packageJson.name}:${dep.packageJson.version} by ${dep.packageJson.author?.name} -- ${dep.packageJson.license} -- ${dep.packageJson.repositoery?.url || dep.packageJson.homepage}`,
)
.join("\n");
},
},
},
};
export default defineConfig([
// npm module (no bundling)
{
entry: ["src/index.ts"],
format: ["esm"],
target: "esnext",
dts: true,
splitting: true,
sourcemap: false,
clean: true,
treeshake: true,
// minify: true,
external: ["p5"],
},
// es6 module (bundled) - this works. include LICENSE notice at top; use plugin?
{
entry: {
ssam: "src/index.ts",
},
format: ["esm"],
outDir: "dist",
bundle: true,
skipNodeModulesBundle: false,
target: "esnext",
dts: true,
splitting: false,
sourcemap: true,
clean: true,
treeshake: true,
minify: true,
outExtension() {
return {
js: ".esm.js",
};
},
esbuildPlugins: [esbuildPluginLicense(licenseNoticeOpts)],
external: ["p5"],
noExternal: [/./],
},
// iife
// {
// entry: {
// ssam: "src/index.ts",
// },
// globalName: "Ssam",
// format: ["iife"],
// outDir: "dist",
// platform: "browser",
// // bundle: true,
// target: "esnext",
// dts: true,
// splitting: false,
// sourcemap: true,
// clean: true,
// treeshake: true,
// minify: true,
// outExtension() {
// return {
// js: ".min.js",
// };
// },
// esbuildPlugins: [esbuildPluginLicense(licenseNoticeOpts)],
// external: ["p5"],
// },
// {
// entry: {
// ssam: "src/index.ts",
// },
// globalName: "Ssam",
// format: ["iife"],
// outDir: "dist",
// platform: "browser",
// // bundle: true,
// target: "esnext",
// dts: true,
// splitting: false,
// sourcemap: true,
// clean: true,
// treeshake: true,
// minify: false,
// outExtension() {
// return {
// js: ".js",
// };
// },
// esbuildPlugins: [esbuildPluginLicense(licenseNoticeOpts)],
// external: ["p5"],
// },
]);