Skip to content

fix(cli): resolve integration import specifiers against the package exports map - #4810

Open
rubyycheung wants to merge 1 commit into
mainfrom
fix/integration-import-specifier
Open

fix(cli): resolve integration import specifiers against the package exports map#4810
rubyycheung wants to merge 1 commit into
mainfrom
fix/integration-import-specifier

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

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 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.

Behaviour change worth reviewing

An integration package that declares no matching exports subpath now gets the package root rather than a subpath it never exported. One existing assertion in component-ownership.test.mjs moves with this: the flat fixture declares no exports, so its specifier goes from @test/meta/MetaAppShell (which would not have resolved) to @test/meta.

Tests

The ownership fixture gains a package exports map and the __packageDir that a resolved integration always carries, plus three new cases:

  • a component whose directory is a shared entry point, resolving to that entry point's subpath
  • a directory that is not an exported subpath, falling back to the package root
  • a doc that states its own specifier, which is left alone

Verified locally: pnpm -F @astryxdesign/cli typecheck:strict passes clean, eslint passes 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.

…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>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Aug 7, 2026 10:46pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant