Skip to content

Commit a020557

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

2 files changed

Lines changed: 77 additions & 61 deletions

File tree

fedify/codegen/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export async function loadSchemaFiles(
275275
const errors: SchemaError[] = [];
276276
for await (const relPath of readDirRecursive(dir)) {
277277
if (!relPath.match(/\.ya?ml$/i)) continue;
278+
if (relPath.match(/(^|[/\\])schema.yaml$/i)) continue;
278279
const path = join(dir, relPath);
279280
let schema: TypeSchema;
280281
try {

fedify/tsdown.config.ts

Lines changed: 76 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,89 @@ 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+
"./mod.ts",
9+
"./compat/mod.ts",
10+
"./federation/mod.ts",
11+
"./nodeinfo/mod.ts",
12+
"./runtime/mod.ts",
13+
"./sig/mod.ts",
14+
"./vocab/mod.ts",
15+
"./webfinger/mod.ts",
16+
"./x/cfworkers.ts",
17+
"./x/hono.ts",
18+
"./x/sveltekit.ts",
19+
],
20+
dts: true,
21+
platform: "neutral",
22+
external: [/^node:/],
23+
outputOptions: {
24+
intro: `
25+
import { Temporal } from "@js-temporal/polyfill";
26+
import { URLPattern } from "urlpattern-polyfill";
27+
`,
28+
},
29+
}),
30+
defineConfig({
31+
entry: [
32+
"./testing/mod.ts",
33+
...(await Array.fromAsync(glob(`**/*.test.ts`)))
34+
.filter((f) =>
35+
!f.startsWith(`codegen${sep}`) && f !== `x${sep}denokv.test.ts`
36+
)
37+
.map((f) => f.replace(sep, "/")),
38+
],
39+
dts: true,
40+
external: [/^node:/],
41+
inputOptions: {
42+
onwarn(warning, defaultHandler) {
43+
if (
44+
warning.code === "UNRESOLVED_IMPORT" &&
45+
warning.id?.endsWith(join("vocab", "vocab.test.ts")) &&
46+
warning.exporter === "@std/testing/snapshot"
47+
) {
48+
return;
49+
} else if (
50+
warning.code === "UNRESOLVED_IMPORT" &&
51+
warning.id?.endsWith(join("testing", "mod.ts")) &&
52+
warning.exporter === "bun:test"
53+
) {
54+
return;
55+
}
56+
defaultHandler(warning);
57+
},
4458
},
45-
},
46-
outputOptions: {
47-
intro: `
59+
outputOptions: {
60+
intro: `
4861
import { Temporal } from "@js-temporal/polyfill";
4962
import { URLPattern } from "urlpattern-polyfill";
63+
globalThis.addEventListener = () => {};
5064
`,
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`)) {
65+
},
66+
hooks: {
67+
"build:done": async (ctx) => {
68+
await cp(
69+
join("testing", "fixtures"),
70+
join(ctx.options.outDir, "fixtures"),
71+
{ recursive: true },
72+
);
6573
await cp(
66-
file,
67-
join(ctx.options.outDir, file),
74+
join("codegen", "schema.yaml"),
75+
join(ctx.options.outDir, "vocab", "schema.yaml"),
6876
{ force: true },
6977
);
70-
}
78+
for await (const file of glob(`vocab/**/*.yaml`)) {
79+
await cp(
80+
file,
81+
join(ctx.options.outDir, file),
82+
{ force: true },
83+
);
84+
}
85+
},
7186
},
72-
},
73-
});
87+
}),
88+
];
7489

7590
// cSpell: ignore unbundle

0 commit comments

Comments
 (0)