Skip to content

Commit 7f3ccdf

Browse files
misama-ctvaloriecarli
authored andcommitted
build: assert no aggregate-preset leak in emitted declarations
Add a post-emit regression guard to scripts/build.sh that fails the build if any granular package's published declarations reference the aggregate @commercetools-frontend/ui-kit preset by its bare specifier. Future-proofs the FEC-938 declaration-emit workaround against being dropped, preconstruct changing resolution, or a new compound component reintroducing the pattern. Also reword the changeset to be consumer-facing.
1 parent 1f4dd50 commit 7f3ccdf

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

.changeset/dts-emit-meta-package-leak.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
"@commercetools-uikit/view-switcher": patch
55
---
66

7-
fix: stop declaration emit from leaking `@commercetools-frontend/ui-kit` into published types
7+
fix: correct leaked type references in `Constraints`, `RadioInput`, and `ViewSwitcher` declarations
88

9-
The compound components (`Constraints`, `RadioInput`, `ViewSwitcher`) emitted
10-
`import("@commercetools-frontend/ui-kit").T...Props` in their published `.d.ts`.
11-
Strict consumers that install only the granular `@commercetools-uikit/*`
12-
packages don't have the aggregate preset, so the reference resolved to `any`
13-
collapsing event-handler prop types and producing `TS7006` on a minor upgrade.
14-
15-
The leak was triggered by `@commercetools-frontend/ui-kit` becoming a root
16-
`devDependency` (so the `.visualroute`/`bundlespec` fixtures resolve under
17-
strict pnpm), which made the bare specifier resolvable during preconstruct's
18-
declaration emit. The build now hides that symlink for the emit step only, so
19-
the correct in-package relative specifier is used. No component API changed.
9+
Their published `.d.ts` referenced the aggregate `@commercetools-frontend/ui-kit`
10+
package, which isn't installed when you depend only on the granular
11+
`@commercetools-uikit/*` packages. That unresolved reference collapsed the
12+
affected prop types to `any`, surfacing as `TS7006` errors in strict
13+
TypeScript setups. The declarations now use in-package relative references, so
14+
the prop types resolve correctly. No component API or runtime behavior changed.

scripts/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ pnpm preconstruct build
3636

3737
restore_meta_symlink
3838
trap - EXIT
39+
40+
# Regression guard: assert the leak stays gone. No granular package's emitted
41+
# declarations should reference the aggregate `@commercetools-frontend/ui-kit`
42+
# preset by its bare specifier — strict consumers can't resolve it (see above).
43+
# Catches a future reintroduction (workaround dropped, preconstruct resolution
44+
# change, a new compound component). Excludes the preset's own dist.
45+
leaks="$(find packages -type d -name declarations -path '*/dist/*' -prune -exec grep -rl 'import("@commercetools-frontend/ui-kit")' {} + 2>/dev/null || true)"
46+
if [ -n "$leaks" ]; then
47+
echo "ERROR: published declarations leak the @commercetools-frontend/ui-kit aggregate preset:" >&2
48+
echo "$leaks" | sed 's/^/ - /' >&2
49+
echo "See the FEC-938 declaration-emit workaround above in scripts/build.sh." >&2
50+
exit 1
51+
fi
3952
# --- end workaround ---
4053

4154
pnpm --filter @commercetools-frontend/ui-kit run copy-assets

0 commit comments

Comments
 (0)