fix(cli): resolve integration import specifiers against the package exports map - #4810
Open
rubyycheung wants to merge 1 commit into
Open
fix(cli): resolve integration import specifiers against the package exports map#4810rubyycheung wants to merge 1 commit into
rubyycheung wants to merge 1 commit into
Conversation
…xports map
Component lookups for integration packages built their import specifier by
concatenating the package name and the component name:
`${owner.package}/${componentName}`
That assumes every component is exported from a subpath named after itself. It
usually is not: several components are commonly exported from one entry point
named after the concept rather than the component, so the specifier points at a
subpath the package does not export and the suggested import does not resolve.
Resolve it against the owning package's `exports` map instead, keyed on the
directory the component's doc file sits in, falling back to the package root
when that directory is not an exported subpath. This mirrors
`resolveImportPathForPkg` in apps/docsite/scripts/generate-data.mjs, which
already does exactly this.
Also stop overwriting a specifier a doc file states for itself. `import` was
assigned after the `...docs` spread, so an authored value was always discarded —
including the correct one, when a package had worked around this by writing the
specifier out by hand.
Core resolution is unchanged.
The ownership fixture gains a package `exports` map and the `__packageDir` a
resolved integration always carries, plus three cases: a component whose
directory is a shared entry point, a directory that is not an exported subpath,
and a doc that states its own specifier. One existing assertion moves with the
behaviour — a fixture declaring no `exports` now yields the package root rather
than a subpath it never exported.
Co-authored-by: Cursor <cursoragent@cursor.com>
rubyycheung
requested review from
cixzhang,
imdreamrunner and
josephfarina
as code owners
August 7, 2026 22:46
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Component lookups for integration packages built their import specifier by concatenating the package name and the component name:
`${owner.package}/${componentName}`That assumes every component is exported from a subpath named after itself. It usually is not — several components are commonly exported from one entry point named after the concept rather than the component. When that happens the specifier points at a subpath the package does not export, and the import the CLI suggests does not resolve.
The change
Resolve the specifier against the owning package's
exportsmap instead, keyed on the directory the component's doc file sits in, falling back to the package root when that directory is not an exported subpath. This mirrorsresolveImportPathForPkginapps/docsite/scripts/generate-data.mjs, which already does exactly this.Also stop overwriting a specifier a doc file states for itself.
importwas assigned after the...docsspread, so an authored value was always discarded — including the correct one, when a package had worked around this by writing the specifier out by hand.Core resolution is unchanged.
Behaviour change worth reviewing
An integration package that declares no matching
exportssubpath now gets the package root rather than a subpath it never exported. One existing assertion incomponent-ownership.test.mjsmoves with this: the flat fixture declares noexports, so its specifier goes from@test/meta/MetaAppShell(which would not have resolved) to@test/meta.Tests
The ownership fixture gains a package
exportsmap and the__packageDirthat a resolved integration always carries, plus three new cases:Verified locally:
pnpm -F @astryxdesign/cli typecheck:strictpasses clean,eslintpasses on both changed files, and the CLI suite goes from 2574 to 2577 passing with no new failures. Nine failures are present both with and without this change — they come from an unbuilt workspace in a local checkout, not from this diff.