-
-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
80 lines (77 loc) · 2.03 KB
/
Copy pathtsdown.config.ts
File metadata and controls
80 lines (77 loc) · 2.03 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
71
72
73
74
75
76
77
78
79
80
import { glob, mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname, join, sep } from "node:path";
import { defineConfig } from "tsdown";
import {
temporalPolyfillCjsBanner,
temporalPolyfillCjsDeps,
temporalPolyfillEsmBanner,
temporalPolyfillImportPlugin,
temporalPolyfillIntro,
} from "../../scripts/tsdown/temporal.mts";
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: {
banner: temporalPolyfillEsmBanner(),
},
cjs: {
deps: temporalPolyfillCjsDeps({
neverBundle: [/^node:/],
}),
plugins: [temporalPolyfillImportPlugin],
banner: temporalPolyfillCjsBanner(),
},
},
platform: "neutral",
deps: {
neverBundle: [/^node:/],
},
}),
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: `${temporalPolyfillIntro}
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