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

[@rollup/plugin-node-resolve] resolving package.json exports/imports arrays #1714

Open
ChristianM18 opened this issue Apr 25, 2024 · 0 comments

Comments

@ChristianM18
Copy link

ChristianM18 commented Apr 25, 2024

⚠️ Please note that the packaged utils library in this example is available here, if needed: https://github.com/ChristianM18/build-utils

Expected Behavior

Arrays defined in package.json exports to be taken into account, with the resolution algorithm trying each item until one is successfully resolved.

  "exports": {
    "./*": ["./dist/*.js", "./dist/*/index.js"]
  },

Actual Behavior

The following error is thrown:

[!] Error: Could not load /home/projects/rollup-repro-udym2a/node_modules/utils/dist/color.js (imported by src/main.js): ENOENT: no such file or directory, open '/home/projects/rollup-repro-udym2a/node_modules/utils/dist/color.js'
ENOENT: no such file or directory, open '/home/projects/rollup-repro-udym2a/node_modules/utils/dist/color.js'

Additional Information

I expected the following statement:

import {sayFavoriteColor} from "utils/color";
console.log(sayFavoriteColor("yellow"));

to resolve to ./dist/color/index.js, as the util's library package.json contains:

  "exports": {
    "./*": ["./dist/*.js", "./dist/*/index.js"]
  },

and ./dist/color.js does not exist.
However, it seems that the fact that ./dist/color.js is missing fires an exception, making the algorithm stop.

Apparently a similar (if not same) issue has already been addressed in #670, so maybe it's just a problem on my end.

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

No branches or pull requests

1 participant