-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
45 lines (44 loc) · 1.27 KB
/
tsdown.config.ts
File metadata and controls
45 lines (44 loc) · 1.27 KB
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
import { glob } from "node:fs/promises";
import { sep } from "node:path";
import { defineConfig } from "tsdown";
export default [
defineConfig({
entry: ["src/mod.ts"],
dts: { compilerOptions: { isolatedDeclarations: true, declaration: true } },
format: ["esm", "cjs"],
platform: "node",
outExtensions({ format }) {
return {
js: format === "cjs" ? ".cjs" : ".js",
dts: format === "cjs" ? ".d.cts" : ".d.ts",
};
},
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
}),
defineConfig({
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
.map((f) => f.replace(sep, "/")),
outExtensions({ format }) {
return {
js: format === "cjs" ? ".cjs" : ".js",
dts: format === "cjs" ? ".d.cts" : ".d.ts",
};
},
deps: { neverBundle: [/^node:/] },
outputOptions: {
intro: `
import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
globalThis.addEventListener = () => {};
`,
},
}),
];