Skip to content

Commit ff21dad

Browse files
committed
Fixed build/test error
1 parent a3fff38 commit ff21dad

11 files changed

Lines changed: 132 additions & 78 deletions

File tree

packages/fixture/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"types": "./dist/mod.d.ts",
1616
"exports": {
1717
".": {
18+
"types": {
19+
"import": "./dist/mod.d.ts",
20+
"require": "./dist/mod.d.cts",
21+
"default": "./dist/mod.d.ts"
22+
},
1823
"import": "./dist/mod.js",
1924
"require": "./dist/mod.cjs",
2025
"default": "./dist/mod.js"
@@ -42,7 +47,7 @@
4247
"build": "tsdown",
4348
"prepack": "tsdown",
4449
"prepublish": "tsdown",
45-
"test": "node --experimental-transform-types --test"
50+
"test": "tsdown && cd dist/ && node --test"
4651
},
4752
"private": true
4853
}

packages/fixture/tsdown.config.ts

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,35 @@ 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-
"src/mod.ts",
8-
...(await Array.fromAsync(glob(`src/**/*.test.ts`)))
9-
.map((f) => f.replace(sep, "/")),
10-
],
11-
dts: true,
12-
format: ["esm"],
13-
platform: "neutral",
14-
external: [/^node:/],
15-
inputOptions: {
16-
onwarn(warning, defaultHandler) {
17-
if (
18-
warning.code === "UNRESOLVED_IMPORT" &&
19-
warning.id?.endsWith(join("mod.ts")) &&
20-
warning.exporter === "bun:test"
21-
) {
22-
return;
23-
}
24-
defaultHandler(warning);
25-
},
26-
},
27-
outputOptions: {
28-
intro: `
29-
import { Temporal } from "@js-temporal/polyfill";
30-
import { URLPattern } from "urlpattern-polyfill";
31-
globalThis.addEventListener = () => {};
32-
`,
33-
},
34-
hooks: {
35-
"build:done": async (ctx) => {
36-
await cp(
37-
join("src", "fixtures"),
38-
join(ctx.options.outDir, "fixtures"),
39-
{ recursive: true },
40-
);
5+
export default [
6+
defineConfig({
7+
entry: ["src/mod.ts"],
8+
dts: true,
9+
format: ["esm", "cjs"],
10+
platform: "neutral",
11+
external: [/^node:/],
12+
hooks: {
13+
"build:done": async (ctx) => {
14+
for await (const file of glob("src/fixtures/**/*.json")) {
15+
await cp(
16+
file,
17+
join(ctx.options.outDir, file.replace(`src${sep}`, "")),
18+
{ force: true },
19+
);
20+
}
21+
},
4122
},
42-
},
43-
});
23+
}),
24+
defineConfig({
25+
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
26+
.map((f) => f.replace(sep, "/")),
27+
format: ["esm", "cjs"],
28+
platform: "node",
29+
external: [
30+
/^node:/,
31+
"@fedify/vocab-runtime",
32+
],
33+
}),
34+
];
4435

4536
// cSpell: ignore onwarn

packages/postgres/src/mq.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { PostgresMessageQueue } from "@fedify/postgres/mq";
22
import * as temporal from "@js-temporal/polyfill";
33
import { delay } from "@std/async/delay";
4-
import process from "node:process";
54
import assert from "node:assert/strict";
5+
import process from "node:process";
66
import { test } from "node:test";
77
import postgres from "postgres";
88

packages/vocab-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"build": "tsdown",
4242
"prepack": "tsdown",
4343
"prepublish": "tsdown",
44-
"test": "node --experimental-transform-types --test"
44+
"test": "tsdown && cd dist/ && node --test"
4545
},
4646
"keywords": [
4747
"Fedify",
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
import { glob } from "node:fs/promises";
2+
import { sep } from "node:path";
13
import { defineConfig } from "tsdown";
24

3-
export default defineConfig({
4-
entry: ["src/mod.ts"],
5-
dts: true,
6-
format: ["esm", "cjs"],
7-
platform: "node",
8-
external: [/^node:/],
9-
});
5+
export default [
6+
defineConfig({
7+
entry: ["src/mod.ts"],
8+
dts: true,
9+
format: ["esm", "cjs"],
10+
platform: "neutral",
11+
external: [/^node:/],
12+
}),
13+
defineConfig({
14+
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
15+
.map((f) => f.replace(sep, "/")),
16+
format: ["esm", "cjs"],
17+
platform: "node",
18+
external: [/^node:/],
19+
}),
20+
];

packages/vocab-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"build": "tsdown",
4242
"prepack": "tsdown",
4343
"prepublish": "tsdown",
44-
"test": "node --experimental-transform-types --test"
44+
"test": "tsdown && cd dist/ && node --test"
4545
},
4646
"keywords": [
4747
"Fedify",

packages/vocab-tools/src/class.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { deepStrictEqual } from "node:assert";
2-
import { basename, dirname, join } from "node:path";
2+
import { basename, dirname, extname, join } from "node:path";
33
import { test } from "node:test";
44
import metadata from "../deno.json" with { type: "json" };
55
import { generateClasses, sortTopologically } from "./class.ts";
@@ -106,7 +106,7 @@ async function changeNodeSnapshotPath() {
106106
return join(
107107
dirname(path),
108108
"__snapshots__",
109-
basename(path) + ".node.snap",
109+
basename(path.replace(extname(path), ".ts")) + ".node.snap",
110110
);
111111
},
112112
);
Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,55 @@
1-
import { cp } from "node:fs/promises";
2-
import { join } from "node:path";
1+
import { cp, glob } from "node:fs/promises";
2+
import { join, sep } from "node:path";
33
import { defineConfig } from "tsdown";
44

5-
export default defineConfig({
6-
entry: ["src/mod.ts"],
7-
dts: true,
8-
format: ["esm", "cjs"],
9-
platform: "node",
10-
external: [/^node:/],
11-
hooks: {
12-
"build:done": async (ctx) => {
13-
await cp(
14-
join("src", "schema.yaml"),
15-
join(ctx.options.outDir, "schema.yaml"),
16-
{ force: true },
17-
);
5+
export default [
6+
defineConfig({
7+
entry: ["src/mod.ts"],
8+
dts: true,
9+
format: ["esm", "cjs"],
10+
platform: "neutral",
11+
external: [/^node:/],
12+
hooks: {
13+
"build:done": async (ctx) => {
14+
await cp(
15+
join("src", "schema.yaml"),
16+
join(ctx.options.outDir, "schema.yaml"),
17+
{ force: true },
18+
);
19+
},
1820
},
19-
},
20-
});
21+
}),
22+
defineConfig({
23+
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
24+
.map((f) => f.replace(sep, "/")),
25+
format: ["esm"],
26+
platform: "node",
27+
external: [
28+
/^node:/,
29+
/^bun:/,
30+
],
31+
inputOptions: {
32+
onwarn(warning, defaultHandler) {
33+
if (
34+
warning.code === "UNRESOLVED_IMPORT" &&
35+
warning.id?.endsWith(".test.ts") &&
36+
warning.exporter &&
37+
["bun:test", "@std/testing/snapshot"].includes(warning.exporter)
38+
) {
39+
return;
40+
}
41+
defaultHandler(warning);
42+
},
43+
},
44+
hooks: {
45+
"build:done": async (ctx) => {
46+
await cp(
47+
join("src", "__snapshots__"),
48+
join(ctx.options.outDir, "__snapshots__"),
49+
{ recursive: true },
50+
);
51+
},
52+
},
53+
}),
54+
];
55+
// cSpell: ignore onwarn

packages/vocab/tsdown.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export default [
3333
onwarn(warning, defaultHandler) {
3434
if (
3535
warning.code === "UNRESOLVED_IMPORT" &&
36-
warning.id?.endsWith(join("vocab", "vocab.test.ts")) &&
36+
warning.id?.endsWith("vocab.test.ts") &&
37+
warning.exporter &&
3738
warning.exporter === "@std/testing/snapshot"
3839
) {
3940
return;
@@ -52,7 +53,7 @@ export default [
5253
for await (const file of glob("src/**/*.yaml")) {
5354
await cp(
5455
file,
55-
join(ctx.options.outDir, file),
56+
join(ctx.options.outDir, file.replace(`src${sep}`, "")),
5657
{ force: true },
5758
);
5859
}

packages/webfinger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"build": "tsdown",
4242
"prepack": "tsdown",
4343
"prepublish": "tsdown",
44-
"test": "node --experimental-transform-types --test"
44+
"test": "tsdown && cd dist/ && node --test"
4545
},
4646
"keywords": [
4747
"Fedify",

0 commit comments

Comments
 (0)