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

Unresolved dependencies when "exports" field property's value contains directory match before the correct literal match #672

Closed
ChrisKuBa opened this issue Dec 1, 2020 · 2 comments

Comments

@ChrisKuBa
Copy link

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 11
  • Rollup Version: 2.34.0
  • Operating System (or Browser): Windows 10 x64
  • Node Version: v14.15.0
  • Link to reproduction (⚠️ read below): https://repl.it/@chrku/rollup-plugin-repro

Expected Behavior

Successful bundle for packages whose "exports" field in package.json like below:

"exports": {
    "./helpers/": "./helpers/",
    "./helpers/typeof": "./helpers/typeof.js",
    "./helpers/jsx": "./helpers/jsx.js",
    "./helpers/asyncIterator": "./helpers/asyncIterator.js",
    "./helpers/AwaitValue": "./helpers/AwaitValue.js",
...
    "./helpers/objectWithoutPropertiesLoose": "./helpers/objectWithoutPropertiesLoose.js",
...
    "./helpers/esm/extends": "./helpers/esm/extends.js",
...
}

Actual Behavior

Unable to bundle, output like this:

[!] Error: Could not load C:\project\node_modules\react-redux\node_modules\@babel\runtime\helpers\esm\objectWithoutPropertiesLoose (imported by node_modules\react-redux\es\connect\connect.js): ENOENT: no such file or directory, open 'C:\C:\project\node_modules\react-redux\node_modules\@babel\runtime\helpers\esm\objectWithoutPropertiesLoose'

Additional Information

Directory match is preferred over direct file/subpath match, if directory match is configured before subpath match in exports.
This should be a fallback, if no subpatch match exists.

Hint: After removing line 27 - 30 the build was successfully.

if (key.endsWith('/') && subPath.startsWith(key)) {
// directory match (deprecated by node): "./foo/": "./foo/.js"
return key;
}
if (key === subPath) {
// literal match
return key;
}

@LarsDenBakker
Copy link
Contributor

Looking into this one

@shellscape
Copy link
Collaborator

Resolved by #675

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

3 participants