-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
70 lines (67 loc) · 1.88 KB
/
Copy pathtsdown.config.ts
File metadata and controls
70 lines (67 loc) · 1.88 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { glob, mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname, join, sep } from "node:path";
import { defineConfig } from "tsdown";
async function copyFileSafely(
source: string,
destination: string,
): Promise<void> {
await mkdir(dirname(destination), { recursive: true });
await writeFile(destination, await readFile(source));
}
export default [
defineConfig({
entry: [
"./src/mod.ts",
],
dts: { compilerOptions: { isolatedDeclarations: true, declaration: true } },
format: ["esm", "cjs"],
platform: "neutral",
deps: { neverBundle: [/^node:/] },
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({
outDir: "dist-tests",
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
.map((f) => f.replace(sep, "/")),
dts: false,
deps: { neverBundle: [/^node:/, "@fedify/fixture"] },
inputOptions: {
onwarn(warning, defaultHandler) {
if (
warning.code === "UNRESOLVED_IMPORT" &&
warning.id?.endsWith("vocab.test.ts") &&
warning.exporter &&
warning.exporter === "@std/testing/snapshot"
) {
return;
}
defaultHandler(warning);
},
},
outputOptions: {
intro: `
import { Temporal } from "@js-temporal/polyfill";
globalThis.addEventListener = () => {};
`,
},
hooks: {
"build:done": async (ctx) => {
for await (const file of glob("src/**/*.yaml")) {
await copyFileSafely(
file,
join(ctx.options.outDir, file.replace(`src${sep}`, "")),
);
}
},
},
}),
];
// cSpell: ignore onwarn