Skip to content

[FEATURE]: support npm subpath imports for custom provider npm entries #16586

Description

@zenyr
  • I have verified this feature I'm about to request hasn't been suggested before.

TL;DR

Please support npm subpath imports in custom provider npm entries.

Wanted behavior:

  • install package root
  • import full requested specifier

Example:

  • pkg -> install pkg, import pkg
  • pkg/subpath -> install pkg, import pkg/subpath
  • @scope/pkg/subpath -> install @scope/pkg, import @scope/pkg/subpath

Describe the enhancement you want to request

Custom provider npm values currently seem to work well for plain package specifiers such as pkg and @scope/pkg, but not for standard npm subpath imports such as pkg/subpath and @scope/pkg/subpath.

This matters because a provider package may reasonably want to expose multiple entrypoints while keeping its root export unchanged. For example:

  • a root entry for general usage
  • a subpath export for a more specialized integration surface, such as OpenCode-specific optimization or API/subscription path branching

Expected behavior for non-file:// specifiers:

  • parse configured npm as an import specifier
  • install only the root package
  • import the full requested specifier

This keeps plain package behavior unchanged while adding support for normal npm subpath exports.

Suggested tests:

  • plain package custom provider still loads
  • scoped plain package custom provider still loads
  • package subpath custom provider loads
  • scoped package subpath custom provider loads
  • invalid subpath fails cleanly
  • pkg and pkg/subpath do not collide in cache or loader state

Note: I used AI assistance during investigation and English drafting because English is not my first language.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions