eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

rule import/no-unresolved support `exports` field in package.json

Open aladdin-add opened this issue 3 years ago • 3 comments

import '@dian/dn/serve'

the package @dian/dn has an exports like:

  "exports": {
    ".": "./dist/mod.js",
    "./actuator": "./dist/actuator/app.js",
    "./monitor": "./dist/monitor/index.js",
    "./middlewares": "./dist/middlewares/index.js",
    "./serve": "./dist/serve.js"
  },

it's working as expected, but eslint is reporting an error:

1:8  error  Unable to resolve path to module '@dian/dn/serve'  import/no-unresolved

aladdin-add avatar Jul 14 '22 08:07 aladdin-add

This plugin uses resolve, which does not yet support exports.

It's a best practice, for backwards compatibility, to have your exports LHS map to a RHS that pre-exports node would be able to resolve - doing so would make things Just Work with this plugin in the meantime.

ljharb avatar Jul 14 '22 16:07 ljharb

Possible duplicate of #2132.

ljharb avatar Jul 14 '22 16:07 ljharb

Try another resolver: https://gist.github.com/danielweck/cd63af8e9a8b3492abacc312af9f28fd

Airkro avatar Sep 08 '22 03:09 Airkro

duplicate of #1810

KubaJastrz avatar Dec 22 '22 14:12 KubaJastrz