From 1cb6ef0d20ec7211f3cf81cfed4f8a5d3b7269d5 Mon Sep 17 00:00:00 2001 From: meh Date: Wed, 30 Sep 2026 16:21:44 +0700 Subject: [PATCH] fix(layouts): list FieldErrorMessage in the layouts manifest The root index exports FieldErrorMessage but layouts.library.json omitted it, so the solid-layouts compiler refused the import in every app and sites inlined a copy. check-contracts now fails on any root export missing from the manifest instead of skipping the form directory. --- layouts.library.json | 1 + scripts/check-contracts.ts | 26 ++++++++++++++++++++++++++ tests/components/form-exports.test.ts | 10 ++++++++++ 3 files changed, 37 insertions(+) diff --git a/layouts.library.json b/layouts.library.json index 8722ab69..f70bdbad 100644 --- a/layouts.library.json +++ b/layouts.library.json @@ -91,6 +91,7 @@ "DrawerTrigger", "Dropdown", "Empty", + "FieldErrorMessage", "FieldGroup", "Fieldset", "FieldsetActions", diff --git a/scripts/check-contracts.ts b/scripts/check-contracts.ts index 49cb40e1..9863bd2b 100644 --- a/scripts/check-contracts.ts +++ b/scripts/check-contracts.ts @@ -35,6 +35,32 @@ const layoutLibrary = JSON.parse(readFileSync("layouts.library.json", "utf8")) a exports?: string[]; }; const layoutExports = new Set(layoutLibrary.exports ?? []); + +// Add a name only when a PascalCase root value export intentionally is not a layout export. +const NOT_LAYOUT_EXPORTS = new Set(); + +const rootValueExports = new Set(); +const rootSource = readFileSync("src/index.ts", "utf8"); +for (const block of rootSource.matchAll(/export\s*\{([^}]*)\}\s*from/g)) { + if (/export\s+type\s*\{/.test(block[0])) continue; + for (const raw of block[1].split(",")) { + const specifier = raw.trim(); + if (!specifier || specifier.startsWith("type ")) continue; + rootValueExports.add(specifier.split(/\s+as\s+/).pop() as string); + } +} + +for (const name of rootValueExports) { + if (!/^[A-Z][a-z]/.test(name)) continue; + if (layoutExports.has(name) || NOT_LAYOUT_EXPORTS.has(name)) continue; + fail( + name, + "layouts-manifest", + `${name} is a root export but absent from layouts.library.json exports`, + "Structure", + ); +} + for (const family of componentFamilies) { if (!layoutExports.has(family.name)) { fail( diff --git a/tests/components/form-exports.test.ts b/tests/components/form-exports.test.ts index 1442ad66..19c88cf9 100644 --- a/tests/components/form-exports.test.ts +++ b/tests/components/form-exports.test.ts @@ -58,4 +58,14 @@ describe("form field-level components are exported from the root", () => { expect(FIELD_LEVEL.filter((name) => !fromBarrel.has(name))).toEqual([]); expect(FIELD_LEVEL.filter((name) => !fromRoot.has(name))).toEqual([]); }); + + it("lists every field-level component in the layouts manifest", () => { + const manifest = JSON.parse( + readFileSync(join(import.meta.dir, "../../layouts.library.json"), "utf8"), + ) as { exports?: string[] }; + const layoutExports = new Set(manifest.exports ?? []); + + // The solid-layouts compiler refuses the consumer import when an export is missing. + expect(FIELD_LEVEL.filter((name) => !layoutExports.has(name))).toEqual([]); + }); });