Skip to content

Package subpath resolution fails when package.json has no exports field #893

@shulaoda

Description

@shulaoda

Problem Description

When resolving b/c/d from fixtures/abc/node_modules/a/index.js:

  1. Expected: Should resolve to fixtures/abc/node_modules/b/c/d.js
  2. Actual: Returns Err(NotFound("b/c/d"))

Directory Structure

fixtures/abc/node_modules/
├── a/
│   └── index.js          # import x from 'b/c/d'
└── b/
    ├── package.json      # { "name": "b", "main": "index.js" }
    └── c/
        ├── d.js          # expected resolution target
        └── d/
            └── e.js

Analysis

This is a subpath resolution issue. When resolving b/c/d:

  • b is the package name, should locate node_modules/b first
  • c/d is the subpath within the package, should resolve to b/c/d.js

The resolver fails to correctly resolve package subpaths (e.g., package-name/path/to/file) when there is no exports field in package.json. It should fall back to filesystem-based resolution within the package directory, but currently returns NotFound.

Metadata

Metadata

Assignees

Labels

p-highPriority - High

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions