From 31445a35bb35c66f886a30ea1e3219e6943bad76 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Thu, 30 Jul 2026 12:18:01 +0000 Subject: [PATCH] build: generate compatibility types after production build --- package.json | 1 + test/type-resolution-compat/generator.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/package.json b/package.json index da6db863..44be4e4e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "prettyCheck": "npm run prettyNoWrite -- --check", "prettyNoWrite": "prettier --config ./.prettierrc.mjs \"**/*.js\" \"**/*.ts\" \"**/*.json\" ", "postinstall": "npm run generate:type-resolution-compat", + "postbuild": "npm run generate:type-resolution-compat", "precheck:compatibility": "npm run build", "check:compatibility": "node utils/check-compatibility.js --file main.js --ios 15", "check": "npm run tsc-check && npm run tsc-check:apps && npm run lint && npm run lint:community -- --quiet && npm run lint:community:tools && npm run svelte-check && npm run check:compatibility", diff --git a/test/type-resolution-compat/generator.test.ts b/test/type-resolution-compat/generator.test.ts index b07e8492..bc819771 100644 --- a/test/type-resolution-compat/generator.test.ts +++ b/test/type-resolution-compat/generator.test.ts @@ -122,6 +122,17 @@ function validSyntheticExports(): Record { }; } +Deno.test("root postbuild generates the type-resolution compatibility mirror", async () => { + const repositoryRoot = await Deno.realPath(new URL("../../", import.meta.url)); + const packageJson = JSON.parse(await Deno.readTextFile(`${repositoryRoot}/package.json`)) as { + scripts?: Record; + }; + assert( + packageJson.scripts?.postbuild === "npm run generate:type-resolution-compat", + "root postbuild does not invoke the compatibility generator" + ); +}); + Deno.test("generator covers the installed package export maps deterministically", async () => { const repositoryRoot = await Deno.realPath(new URL("../../", import.meta.url)); const temporaryDirectory = await Deno.makeTempDir({ prefix: "livesync-type-generator-" });