Skip to content

Order of paths in exports object shouldn't matter #7

Closed
@bgotink

Description

@bgotink

The following two exports objects are equivalent for Node, but resolve.exports only works correctly for the first. This can be verified by swapping lines 401 and 402 in test/resolve.js

{
  "./data/*": "./data/*.json",
  "./": "./"
}

{
  "./": "./",
  "./data/*": "./data/*.json"
}

Looking at the ESM resolution algorithm in node's documentation (PACKAGE_IMPORTS_EXPORTS_RESOLVE here), node sorts the keys by key length before looking for a match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions