-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
tsup.config.ts
51 lines (48 loc) · 1.57 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
import { defineConfig, Options } from "tsup";
import { version, engines, name } from "./package.json";
import semver from "semver";
const minNode = semver.minVersion(engines.node)!;
const commons: Options = {
format: ["cjs", "esm"],
splitting: false,
sourcemap: false,
clean: true,
dts: true,
minify: true,
target: `node${minNode.major}.${minNode.minor}.${minNode.patch}`,
removeNodeProtocol: false, // @todo will be default in v9
};
export default defineConfig([
{
...commons,
name,
entry: ["src/index.ts"],
esbuildOptions: (options, { format }) => {
options.supported = options.supported || {};
if (format === "cjs") {
/**
* Downgrade dynamic imports for CJS even they are actually supported, but still are problematic for Jest
* @example jest with ts-jest
* @link https://github.com/evanw/esbuild/issues/2651
*/
options.supported["dynamic-import"] = false;
}
options.define = {
"process.env.TSUP_BUILD": `"v${version} (${format.toUpperCase()})"`,
"process.env.TSUP_STATIC": `"static"`, // used by isProduction()
};
},
},
{
...commons,
name: "./migration".padStart(name.length),
entry: { index: "src/migration.ts" },
outDir: "migration",
/**
* This replaces "export { _default as default }" with "export = _default" in the CJS DTS build
* @link https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/MissingExportEquals.md
* */
cjsInterop: true,
skipNodeModulesBundle: true,
},
]);