Skip to content
New issue

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

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

Already on GitHub? # to your account

import/no-unresolved triggers when importing pixi.js/advanced-blend-modes. #3088

Open
guillaumebrunerie opened this issue Oct 20, 2024 · 3 comments

Comments

@guillaumebrunerie
Copy link

With PixiJS v8, advanced blend modes are imported as follows (see for instance https://pixijs.com/8.x/examples/basic/blend-modes):

import "pixi.js/advanced-blend-modes";

However, this triggers the lint error Unable to resolve path to module 'pixi.js/advanced-blend-modes'. [import/no-unresolved].

Here is the (I think) relevant part of PixiJS's package.json (seems correct to me, but I don’t know much about those things):

{
  "exports": {
    "./advanced-blend-modes": {
      "import": {
        "default": "./lib/advanced-blend-modes/init.mjs"
      },
      "require": {
        "default": "./lib/advanced-blend-modes/init.js"
      }
    }
  }
}

Note that if I write the following:

import "pixi.js/lib/advanced-blend-modes";

then the lint error goes away, but the import itself doesn’t work anymore, I get the following error from Vite:

[plugin:vite:import-analysis] Missing "./lib/advanced-blend-modes" specifier in "pixi.js" package

I'm not sure if it’s an issue in eslint-plugin-import, in PixiJS, or if I misconfigured something? I’m using ESLint 8.57 with a .eslintrc and "type": "module" in my package.json.

@ljharb
Copy link
Member

ljharb commented Oct 20, 2024

This plugin does not yet support exports, until resolve does.

Ideally, the package would keep the LHS and RHS of "exports" the same, so that it gracefully degrades - otherwise until resolve (and thus, us) adds support for exports, you'd need to add the package to the ignored imports setting.

@guillaumebrunerie
Copy link
Author

In what way does resolve not support exports?
I tried to run require.resolve("pixi.js/advanced-blend-modes") in the node REPL in the root directory of my project, and got the expected result: [...]/node_modules/pixi.js/lib/advanced-blend-modes/init.js.

@ljharb
Copy link
Member

ljharb commented Oct 20, 2024

in any way - i'm talking about https://npmjs.com/resolve

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants