Skip to content

[metro-resolver] Import resolution package.json lookup for ESM is not Node module resolution compliant #1582

Description

@kitten

As per the algorithm: https://nodejs.org/api/esm.html#resolution-algorithm-specification

We'd expect foo-pkg/bar to be resolving package.json:exports from foo-pkg/package.json first to check for exports. However, currently, it seems that Metro prioritises foo-pkg/bar/package.json

A lot of logic relies on getPackageForModule and getPackage which look up the package.json at the given absolute path, rather than taking the package path into account (as per the spec, see: packageSubpath being separated out)

Reproduction in the form of a unit test: https://github.com/kitten/metro/tree/%40kitten/fix/metro-exports-package-json-priority

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions