[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-import-resolver-node can't handle "exports" #1884

Closed
wojtekmaj opened this issue Aug 18, 2020 · 1 comment
Closed

eslint-import-resolver-node can't handle "exports" #1884

wojtekmaj opened this issue Aug 18, 2020 · 1 comment

Comments

@wojtekmaj
Copy link

🐛 Bug Report

"exports" field seems to be ignored by eslint-import-resolver-node, resulting with unexpected error thrown by import/no-unresolved rule even though Node is capable of resolving the paths.

https://nodejs.org/api/esm.html#esm_package_entry_points

To Reproduce

Steps to reproduce the behavior:

I have a simple utils package in my workspace, that's shaped like this:

/dist
  array.js
  … 
/src
  array.js
  …
package.json

package.json:

{
  "name": "@my-org/utils",
  "version": "1.0.0",
  "exports": {
    "./array": "./dist/array.js",
    "./boolean": "./dist/boolean.js",
    "./math": "./dist/math.js",
    "./number": "./dist/number.js",
    "./object": "./dist/object.js",
    "./promise": "./dist/promise.js",
    "./string": "./dist/string.js"
  }
}

This allows me to use it in my main project by importing utils like this:

import { min } from '@my-org/utils/math'

This works both in native ES modules environment in Node 14, and in code transpiled by Babel. But this line is flagged by import/no-unresolved.

Expected behavior

"exports" to be respected and understood by eslint-import-resolver

Link to repo

https://github.com/wojtekmaj/resolve-exports-issue

envinfo

  System:
    OS: macOS 11.0
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 14.5.0 - /usr/local/bin/node
    Yarn: 2.1.1 - /usr/local/bin/yarn
    npm: 6.14.5 - /usr/local/bin/npm
@ljharb
Copy link
Member
ljharb commented Aug 18, 2020

Duplicate of #1868.

@ljharb ljharb closed this as completed Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants