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

Bug: import-target mutes resolution errors #182

Closed
scagood opened this issue Feb 7, 2024 · 0 comments · Fixed by #264
Closed

Bug: import-target mutes resolution errors #182

scagood opened this issue Feb 7, 2024 · 0 comments · Fixed by #264
Assignees
Milestone

Comments

@scagood
Copy link

scagood commented Feb 7, 2024

Currently in lib/util/import-target.js:273 we skip all errors as if it errors the package is not found.
However, we need to be able to display some of the errors as not all not found errors are equal!


An example:

My file:

// index.js
import 'missing';
import 'misconfigured';
{
  "name": "demo",
  "type": "module",
  "dependencies": {
    "misconfigured": "*"
  }
}

When resolving missing the error is:

Can't resolve 'soup' in '/home/scagood/issue-demo'

When resolving misconfigured the error is:

Default condition should be last one

In node_modules/misconfigured/package.json the following mistake was made:

{
  "name": "misconfigured",
  "exports": {
    ".": {
      "default": "./build/index.js",
      "types": "./src/index.ts"
    }
  },
  ...
}

In order to resolve this, the exports should become:

{
  "name": "misconfigured",
  "exports": {
    ".": {
      "types": "./src/index.ts",
      "default": "./build/index.js"
    }
  },
  ...
}

This is because enhanced-resolve explicitly throws an error here:
https://github.com/webpack/enhanced-resolve/blob/main/lib/util/entrypoints.js#L475

I am not 100% sure why... but it is an error that we need to be able to display!

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