Skip to content

Commit e43ca81

Browse files
committed
Cover Astro package entrypoints
Extend the Astro package regression test to assert that the JavaScript and declaration entrypoints declared in package.json exist on disk. This keeps the test aligned with the original packaging regression so missing type outputs are caught before publication.
1 parent 7d91670 commit e43ca81

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

packages/astro/src/package.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { deepStrictEqual, strictEqual } from "node:assert/strict";
2+
import { access, readFile } from "node:fs/promises";
23
import { createRequire } from "node:module";
4+
import { dirname, resolve } from "node:path";
35
import test from "node:test";
6+
import { fileURLToPath } from "node:url";
47
import type {
58
Federation,
69
FederationFetchOptions,
710
} from "@fedify/fedify/federation";
811
import type { APIContext } from "astro";
912

1013
const require = createRequire(import.meta.url);
14+
const packageDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
1115

1216
type MockFederation<TContextData> = Pick<Federation<TContextData>, "fetch">;
1317

@@ -28,6 +32,10 @@ function expectResponse(response: void | Response): Response {
2832
return response;
2933
}
3034

35+
async function assertTargetExists(path: string): Promise<void> {
36+
await access(resolve(packageDir, path));
37+
}
38+
3139
test("self-reference ESM import exposes working Astro integration API", async () => {
3240
const mod = await import("@fedify/astro");
3341

@@ -92,6 +100,24 @@ test(
92100
"self-reference CommonJS require exposes working Astro middleware API",
93101
{ skip: "Deno" in globalThis },
94102
async () => {
103+
const packageJson = JSON.parse(
104+
await readFile(resolve(packageDir, "package.json"), "utf8"),
105+
);
106+
const exportMap = packageJson.exports["."];
107+
const targets = [
108+
packageJson.main,
109+
packageJson.module,
110+
packageJson.types,
111+
exportMap.require.types,
112+
exportMap.require.default,
113+
exportMap.import.types,
114+
exportMap.import.default,
115+
] as string[];
116+
117+
for (const target of new Set(targets)) {
118+
await assertTargetExists(target);
119+
}
120+
95121
const mod = require("@fedify/astro") as typeof import("@fedify/astro");
96122

97123
strictEqual(typeof mod.fedifyIntegration, "function");

0 commit comments

Comments
 (0)