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

esmock 1.9.1 and eslint: Unable to resolve path to module 'esmock' #106

Closed
tripodsan opened this issue Aug 2, 2022 · 7 comments · Fixed by #107
Closed

esmock 1.9.1 and eslint: Unable to resolve path to module 'esmock' #106

tripodsan opened this issue Aug 2, 2022 · 7 comments · Fixed by #107

Comments

@tripodsan
Copy link
Collaborator

tripodsan commented Aug 2, 2022

With 1.9.1 I get:

> eslint .


/test/my.test.js
  17:20  error  Unable to resolve path to module 'esmock'  import/no-unresolved

the problem are the exports added in: 96d2754

also see:
https://nodejs.org/docs/latest-v16.x/api/packages.html#package-entry-points

when I add the

  "main": "./src/esmockLoader.js",

again, it works.

@iambumblehead
Copy link
Owner

@tripodsan I apologize for breaking this. The PR you made has been published.

@aladdin-add
Copy link
Collaborator

it's just that plugin does not support exports yet.

related: import-js/eslint-plugin-import#2495

@tripodsan
Copy link
Collaborator Author

it's just that plugin does not support exports yet.

yes, but also I'm not sure that the exports are correct this way:

  "exports": {
    "types": "./src/esmock.d.ts",
    "import": "./src/esmockLoader.js"
  },

@iambumblehead , what was the intention of those? if you look at the nodejs doc, all sub-package exports usually start with a ./.
so, something like:

  "exports": {
    ".": "./src/esmockLoader.js"
    "./types": "./src/esmock.d.ts",
  },

would make more sense.

@aladdin-add
Copy link
Collaborator

I think it's working as expected, it's the same as:

  "exports": {
    ".": {
       "import": "./src/esmockLoader.js",
       "types": "./src/esmock.d.ts"
     }
  },

@tripodsan
Copy link
Collaborator Author

ah right, those are conditional exports

@iambumblehead
Copy link
Owner

The pattern was changed in order to ensure support with newer versions of typescript. I accidentally removed too many fields and, to catch issues in the future, I'll try requesting reviews.

The export pattern is seen here https://nodejs.org/api/packages.html#approach-2-isolate-state and the pattern was recommended here iambumblehead/form-urlencoded#45

The exports['.'] and exports['.'].import patterns both seem like good suggestions. When there are "issues" with form-urlencoded, they are usually reported right away and no issues have been reported since iambumblehead/form-urlencoded#45 was published

Anyway, I will need to study export patterns to learn more about them and to support them at esmock's resolver https://github.com/iambumblehead/resolvewithplus (for which the unit-tests were re-organized a day or two ago, in preparation for the unit-tests that would need to be added)

@iambumblehead
Copy link
Owner

would one of you review my PR here? iambumblehead/resolvewithplus#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants