-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
48 lines (47 loc) · 1.31 KB
/
tsdown.config.ts
File metadata and controls
48 lines (47 loc) · 1.31 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
46
47
48
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",
};
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
},
}),
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 = () => {};
`,
},
}),
];