Skip to content

@rollup/plugin-node-resolve: Unresolved import due to nested sub-module paths in exports field #641

Closed
@carsonfarmer

Description

@carsonfarmer

Firstly, thanks for the amazing work on the @rollup/plugin-node-resolve plugin, its a life-saver. Especially happy to have the latest work on supporting package entry points! This issue relates to how the plugin handles nested paths in package entry points. In theory, the examples in the repl.it should be allowed: https://nodejs.org/api/packages.html#packages_package_entry_points

Expected Behavior

To be able to resolve packages with export fields that contain nested paths. This seems like a common scenario:

...
"exports": {
    ".": {
      "require": "./cjs/src/index.js",
      "import": "./esm/src/index.js",
      "browser": "./esm/src/browser.js"
    }
},
...

or

...
"exports": {
    ".": "./foo/nested/c.js",
    "./bar": "./bar/a.js"
  }
...

or any of the examples in https://nodejs.org/api/packages.html#packages_package_entry_points

Actual Behavior

The plugin is unable to resolve nested paths. Please see attached repl.it for a minimal reproducible example of this.

Additional Information

Metadata

Metadata

Assignees

No one assigned

    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