Skip to content

Commit 21e0177

Browse files
committed
fix(build): stop dts emit leaking @commercetools-frontend/ui-kit into published types
The compound components (Constraints, RadioInput, ViewSwitcher) emitted import("@commercetools-frontend/ui-kit").T...Props in their published .d.ts. Strict consumers installing only the granular @commercetools-uikit/* packages don't have the aggregate preset, so the reference resolved to any (TS7006). Root cause: @commercetools-frontend/ui-kit is a root devDependency (so the .visualroute/bundlespec fixtures resolve under strict pnpm), which makes the bare specifier resolvable during preconstruct's declaration emit, and TS prefers it over the in-package relative path. The build now hides that symlink for the preconstruct build step only (trap-guarded restore), forcing the correct relative specifier. No component API or source changed. Refs: commercetools/identity#757
1 parent 4ba4c5e commit 21e0177

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@commercetools-uikit/constraints": patch
3+
"@commercetools-uikit/radio-input": patch
4+
"@commercetools-uikit/view-switcher": patch
5+
---
6+
7+
fix: stop declaration emit from leaking `@commercetools-frontend/ui-kit` into published types
8+
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.

scripts/build.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@ pnpm generate-icons
66
pnpm design-tokens:build
77
pnpm compile-intl
88

9+
# --- declaration-emit leak workaround (FEC-938) ---
10+
# `@commercetools-frontend/ui-kit` (the aggregate preset) is a root
11+
# devDependency because the .visualroute/bundlespec fixtures import it. Under
12+
# strict pnpm that puts a `node_modules/@commercetools-frontend/ui-kit` symlink
13+
# in place, and preconstruct's declaration emit then prefers that resolvable
14+
# bare specifier over the in-package relative path — leaking
15+
# `import("@commercetools-frontend/ui-kit").T...Props` into the published .d.ts
16+
# of the compound components (constraints, radio-input, view-switcher). Strict
17+
# consumers can't resolve it, so those prop types collapse to `any`.
18+
#
19+
# preconstruct does not need that symlink (the fixtures aren't part of the dts
20+
# program), so we hide it during the build to force the correct relative
21+
# specifier, and restore it afterwards (and on any exit).
22+
META_SYMLINK="node_modules/@commercetools-frontend/ui-kit"
23+
META_SYMLINK_TARGET=""
24+
restore_meta_symlink() {
25+
if [ -n "$META_SYMLINK_TARGET" ] && [ ! -e "$META_SYMLINK" ]; then
26+
ln -s "$META_SYMLINK_TARGET" "$META_SYMLINK"
27+
fi
28+
}
29+
if [ -L "$META_SYMLINK" ]; then
30+
META_SYMLINK_TARGET="$(readlink "$META_SYMLINK")"
31+
trap restore_meta_symlink EXIT
32+
rm "$META_SYMLINK"
33+
fi
34+
935
pnpm preconstruct build
1036

37+
restore_meta_symlink
38+
trap - EXIT
39+
# --- end workaround ---
40+
1141
pnpm --filter @commercetools-frontend/ui-kit run copy-assets

0 commit comments

Comments
 (0)