Skip to content

Commit 1c6f829

Browse files
committed
Bundle modules into neutral modules
1 parent c2f6d66 commit 1c6f829

1 file changed

Lines changed: 77 additions & 61 deletions

File tree

fedify/tsdown.config.ts

Lines changed: 77 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,90 @@ import { cp, glob } from "node:fs/promises";
22
import { join, sep } from "node:path";
33
import { defineConfig } from "tsdown";
44

5-
export default defineConfig({
6-
entry: [
7-
"./mod.ts",
8-
"./compat/mod.ts",
9-
"./federation/mod.ts",
10-
"./nodeinfo/mod.ts",
11-
"./runtime/mod.ts",
12-
"./sig/mod.ts",
13-
"./testing/mod.ts",
14-
"./vocab/mod.ts",
15-
"./webfinger/mod.ts",
16-
"./x/cfworkers.ts",
17-
"./x/hono.ts",
18-
"./x/sveltekit.ts",
19-
...(await Array.fromAsync(glob(`**/*.test.ts`)))
20-
.filter((f) =>
21-
!f.startsWith(`codegen${sep}`) && f !== `x${sep}denokv.test.ts`
22-
)
23-
.map((f) => f.replace(sep, "/")),
24-
],
25-
dts: true,
26-
unbundle: true,
27-
external: [/^node:/],
28-
inputOptions: {
29-
onwarn(warning, defaultHandler) {
30-
if (
31-
warning.code === "UNRESOLVED_IMPORT" &&
32-
warning.id?.endsWith(join("vocab", "vocab.test.ts")) &&
33-
warning.exporter === "@std/testing/snapshot"
34-
) {
35-
return;
36-
} else if (
37-
warning.code === "UNRESOLVED_IMPORT" &&
38-
warning.id?.endsWith(join("testing", "mod.ts")) &&
39-
warning.exporter === "bun:test"
40-
) {
41-
return;
42-
}
43-
defaultHandler(warning);
5+
export default [
6+
defineConfig({
7+
entry: [
8+
"./testing/mod.ts",
9+
...(await Array.fromAsync(glob(`**/*.test.ts`)))
10+
.filter((f) =>
11+
!f.startsWith(`codegen${sep}`) && f !== `x${sep}denokv.test.ts`
12+
)
13+
.map((f) => f.replace(sep, "/")),
14+
],
15+
dts: true,
16+
unbundle: true,
17+
external: [/^node:/],
18+
inputOptions: {
19+
onwarn(warning, defaultHandler) {
20+
if (
21+
warning.code === "UNRESOLVED_IMPORT" &&
22+
warning.id?.endsWith(join("vocab", "vocab.test.ts")) &&
23+
warning.exporter === "@std/testing/snapshot"
24+
) {
25+
return;
26+
} else if (
27+
warning.code === "UNRESOLVED_IMPORT" &&
28+
warning.id?.endsWith(join("testing", "mod.ts")) &&
29+
warning.exporter === "bun:test"
30+
) {
31+
return;
32+
}
33+
defaultHandler(warning);
34+
},
4435
},
45-
},
46-
outputOptions: {
47-
intro: `
36+
outputOptions: {
37+
intro: `
4838
import { Temporal } from "@js-temporal/polyfill";
4939
import { URLPattern } from "urlpattern-polyfill";
5040
`,
51-
},
52-
hooks: {
53-
"build:done": async (ctx) => {
54-
await cp(
55-
join("testing", "fixtures"),
56-
join(ctx.options.outDir, "testing", "fixtures"),
57-
{ recursive: true },
58-
);
59-
await cp(
60-
join("codegen", "schema.yaml"),
61-
join(ctx.options.outDir, "codegen", "schema.yaml"),
62-
{ force: true },
63-
);
64-
for await (const file of glob(`vocab/**/*.yaml`)) {
41+
},
42+
hooks: {
43+
"build:done": async (ctx) => {
44+
await cp(
45+
join("testing", "fixtures"),
46+
join(ctx.options.outDir, "testing", "fixtures"),
47+
{ recursive: true },
48+
);
6549
await cp(
66-
file,
67-
join(ctx.options.outDir, file),
50+
join("codegen", "schema.yaml"),
51+
join(ctx.options.outDir, "codegen", "schema.yaml"),
6852
{ force: true },
6953
);
70-
}
54+
for await (const file of glob(`vocab/**/*.yaml`)) {
55+
await cp(
56+
file,
57+
join(ctx.options.outDir, file),
58+
{ force: true },
59+
);
60+
}
61+
},
62+
},
63+
}),
64+
defineConfig({
65+
entry: [
66+
"./mod.ts",
67+
"./compat/mod.ts",
68+
"./federation/mod.ts",
69+
"./nodeinfo/mod.ts",
70+
"./runtime/mod.ts",
71+
"./sig/mod.ts",
72+
"./vocab/mod.ts",
73+
"./webfinger/mod.ts",
74+
"./x/cfworkers.ts",
75+
"./x/hono.ts",
76+
"./x/sveltekit.ts",
77+
],
78+
dts: true,
79+
unbundle: true,
80+
platform: "neutral",
81+
external: [/^node:/],
82+
outputOptions: {
83+
intro: `
84+
import { Temporal } from "@js-temporal/polyfill";
85+
import { URLPattern } from "urlpattern-polyfill";
86+
`,
7187
},
72-
},
73-
});
88+
}),
89+
];
7490

7591
// cSpell: ignore unbundle

0 commit comments

Comments
 (0)