forked from fedify-dev/fedify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
75 lines (73 loc) · 2.26 KB
/
Copy pathtsdown.config.ts
File metadata and controls
75 lines (73 loc) · 2.26 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
import { glob } from "node:fs/promises";
import { join, sep } from "node:path";
import { defineConfig } from "tsdown";
export default [
defineConfig({
entry: [
"./src/mod.ts",
"./src/compat/mod.ts",
"./src/federation/mod.ts",
"./src/nodeinfo/mod.ts",
"./src/otel/mod.ts",
"./src/runtime/mod.ts",
"./src/utils/mod.ts",
"./src/sig/mod.ts",
"./src/vocab/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");`,
`const { URLPattern } = require("urlpattern-polyfill");`,
].join("\n")
: [
`import { Temporal } from "@js-temporal/polyfill";`,
`import { URLPattern } from "urlpattern-polyfill";`,
].join("\n");
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
}),
defineConfig({
entry: [
"./src/testing/mod.ts",
...(await Array.fromAsync(glob(`src/**/*.test.ts`)))
.map((f) => f.replace(sep, "/")),
],
external: [/^node:/, "@fedify/fixture"],
// Bundle @fedify/fixture back in for src/testing/ files (needed for
// cfworkers), while keeping it external for test files so that
// pnpm pack --recursive does not try to resolve the private package:
noExternal: (id: string, importer: string | undefined) => {
if (id !== "@fedify/fixture") return false;
const normalized = importer?.replaceAll(sep, "/");
return normalized?.includes("/src/testing/") ?? false;
},
inputOptions: {
onwarn(warning, defaultHandler) {
if (
warning.code === "UNRESOLVED_IMPORT" &&
warning.id?.endsWith(join("testing", "mod.ts")) &&
warning.exporter === "bun:test"
) {
return;
}
defaultHandler(warning);
},
},
outputOptions: {
intro: `
import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
globalThis.addEventListener = () => {};
`,
},
}),
];
// cSpell: ignore onwarn