fix(AG-17604): add missing subpath exports for tsgo compatibility#1315
fix(AG-17604): add missing subpath exports for tsgo compatibility#1315amir-zahedi merged 1 commit intomainfrom
Conversation
…go compatibility The tree-shaking exports change in 4.53.0 (AG-18132) introduced an exports field that strict TypeScript resolvers (tsgo / @typescript/native-preview 7.0) enforce. Several symbols used by MFE consumers were not re-exported from component indexes, and the ./dist/* catch-all lacked a types condition. Component index additions: - Positioner: EAlignment (alongside EPositionerAlignment) - Radio: useRadioContext - Badge: BadgeProps type - Columns: SprinklesColumnWidth type - OverdriveProvider: ProviderProps type New public component: - HintText: re-export from private/InputBase/HintText Exports field additions: - ./themes and ./utils barrel exports - ./themes/base, ./themes/flat_red, ./themes/neutral directory exports - ./package.json self-reference - types condition on ./dist/* catch-all Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 4a08f08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR fixes TypeScript strict-resolver (tsgo / @typescript/native-preview) compatibility issues introduced by the package.json#exports field, primarily by restoring missing public entrypoints/types and adding explicit subpath exports for themes/utils.
Changes:
- Adds missing named exports/type exports to several component
index.tsfiles (e.g.useRadioContext,EAlignment, and various prop/types). - Introduces a new public
HintTextbarrel export re-exported from a previously private path. - Updates
package.json#exportsto add./themes,./utils, explicit theme directory exports,./package.json, and atypescondition for the./dist/*catch-all.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Expands exports map with themes/utils barrels, explicit theme dirs, ./package.json, and adjusts ./dist/* to include types. |
| lib/components/Radio/index.ts | Re-exports useRadioContext from RadioGroup. |
| lib/components/Positioner/index.ts | Re-exports EAlignment alongside the existing alias EPositionerAlignment. |
| lib/components/OverdriveProvider/index.ts | Re-exports ProviderProps type. |
| lib/components/HintText/index.ts | Adds new public HintText/HintTextProps re-export. |
| lib/components/Columns/index.ts | Re-exports SprinklesColumnWidth type. |
| lib/components/Badge/index.ts | Re-exports BadgeProps type. |
| .changeset/fix-exports-compatibility.md | Adds a changeset describing the compatibility fix. |
| @@ -1,2 +1,2 @@ | |||
| export { Radio } from './Radio'; | |||
| export { RadioGroup } from './RadioGroup'; | |||
| export { RadioGroup, useRadioContext } from './RadioGroup'; | |||
There was a problem hiding this comment.
Now that useRadioContext is being exported from the public Radio entrypoint, its current implementation (useContext(RadioContext)!) will throw an unhelpful runtime error if used outside a RadioGroup. Consider changing useRadioContext to validate the context and throw an invariant with a clear message (or return RadioGroupContext | null), similar to other public context hooks like useTableContext / useToast.
| export { RadioGroup, useRadioContext } from './RadioGroup'; | |
| export { RadioGroup } from './RadioGroup'; |
| export { HintText } from '../private/InputBase/HintText'; | ||
| export type { HintTextProps } from '../private/InputBase/HintText'; |
There was a problem hiding this comment.
HintText is being added as a public component export, but the underlying component (private/InputBase/HintText) does not set a displayName (many components in this repo do). To keep component naming consistent in React DevTools and tests, consider adding HintText.displayName = 'HintText' in the component definition file now that it’s part of the public API surface.
| export { HintText } from '../private/InputBase/HintText'; | |
| export type { HintTextProps } from '../private/InputBase/HintText'; | |
| import type { FC } from 'react'; | |
| import { HintText as PrivateHintText } from '../private/InputBase/HintText'; | |
| import type { HintTextProps as PrivateHintTextProps } from '../private/InputBase/HintText'; | |
| export type HintTextProps = PrivateHintTextProps; | |
| /** | |
| * Public HintText component wrapper. | |
| * | |
| * Ensures a stable displayName for React DevTools and tests | |
| * while delegating all rendering to the internal implementation. | |
| */ | |
| export const HintText: FC<HintTextProps> = (props) => <PrivateHintText {...props} />; | |
| HintText.displayName = 'HintText'; |
| }, | ||
| "./dist/*": "./dist/*" | ||
| "./dist/*": { | ||
| "types": "./dist/*.d.ts", |
There was a problem hiding this comment.
./dist/* export's types mapping (./dist/*.d.ts) will produce incorrect paths for common subpaths, e.g. an import like @autoguru/overdrive/dist/index.js would resolve types to ./dist/index.js.d.ts (non-existent). Consider switching the types target to ./dist/* (letting TS resolve .d.ts / index.d.ts), or adding a more specific ./dist/*.js export pattern mapping to ./dist/*.d.ts and leaving ./dist/* as a fallback.
| "types": "./dist/*.d.ts", | |
| "types": "./dist/*", |
Summary
The tree-shaking exports change in 4.53.0 (AG-18132) introduced a
package.jsonexportsfield. Strict TypeScript resolvers (tsgo/@typescript/native-preview7.0) enforce this field, causing TS2307 errors in MFE consumers because:export *was replaced with named exports./dist/*catch-all lacked atypescondition./themesand./utilsbarrel exports were missing (unlike./hooksand./styles)themes/base,themes/flat_red,themes/neutral) didn't resolve through the./themes/*wildcard (it maps to*.jsnot*/index.js)Component index additions
PositionerEAlignment(alongside existingEPositionerAlignment)RadiouseRadioContextBadgetype BadgePropsColumnstype SprinklesColumnWidthOverdriveProvidertype ProviderPropsNew public component
HintText— re-exported fromprivate/InputBase/HintTextvia newcomponents/HintText/index.ts. Used by 8 MFE files. Covered by the existing./components/*wildcard export.Exports field changes
./themesbarrel export (matches existing./hooks,./stylespattern)./utilsbarrel export./themes/base,./themes/flat_red,./themes/neutralexplicit directory exports (placed before./themes/*wildcard for correct precedence)./package.jsonself-reference (tooling compatibility — Vite dep pre-bundling)./dist/*from bare string to object withtypescondition (transitional safety net for strict resolvers)Tree-shaking impact
All additions are targeted named exports — no
export *patterns introduced. The./dist/*catch-all is retained as a transitional safety net and should be tracked for removal in a future release once MFE migration is validated.Test plan
yarn buildpassesyarn lint:tscpassesyarn overdrive:local+yarn lintpasses with corresponding MFE import migrationdist/components/HintText/index.d.tsgenerated after build