Skip to content

fix(plugin): support subpath imports in plugin specifiers#16791

Open
oritwoen wants to merge 4 commits intoanomalyco:devfrom
oritwoen:fix/plugin-subpath-imports
Open

fix(plugin): support subpath imports in plugin specifiers#16791
oritwoen wants to merge 4 commits intoanomalyco:devfrom
oritwoen:fix/plugin-subpath-imports

Conversation

@oritwoen
Copy link

@oritwoen oritwoen commented Mar 9, 2026

Issue for this PR

Closes #16792

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The plugin loader passes the full specifier string to BunProc.install(). For "websxa/opencode", that means it tries to install a package literally called websxa/opencode, which doesn't exist. The actual package is websxa with a ./opencode subpath export.

This adds a parsePluginSpecifier() function that splits the specifier into package name, subpath, and version. After installing the base package, the subpath gets resolved through the package's exports map in package.json. Falls back to direct path join for packages without an exports map.

Handles all specifier shapes: pkg, pkg/sub, pkg@1.0.0, pkg/sub@1.0.0, @scope/pkg/sub, @scope/pkg/sub@1.0.0.

Fully backward compatible since specifiers without subpaths parse to the same values as before.

How did you verify your code works?

Tested parsing logic against all specifier formats (unscoped, scoped, versioned, deep subpaths). Tested exports map resolution against a real package.json with nested export conditions (import, default). Verified existing specifiers without subpaths still resolve correctly.

Screenshots / recordings

N/A, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@oritwoen oritwoen requested a review from adamdotdevin as a code owner March 9, 2026 17:49
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Plugins can now use subpath exports (e.g. "websxa/opencode") instead of
requiring a dedicated wrapper package. The specifier is parsed into package
name and subpath, installed via BunProc.install, then the subpath is resolved
through the package's exports map.

Handles unscoped ("pkg/sub"), scoped ("@scope/pkg/sub"), and versioned
("pkg/sub@1.0.0") specifiers. Falls back to direct path when no exports
map exists. Fully backward compatible with existing specifier formats.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Support subpath exports in plugin specifiers

1 participant