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

Problem with exports #313

Open
pauldraper opened this issue Oct 20, 2021 · 5 comments
Open

Problem with exports #313

pauldraper opened this issue Oct 20, 2021 · 5 comments

Comments

@pauldraper
Copy link

pauldraper commented Oct 20, 2021

I'm not sure what the nature of the problem is, but the @rollup/pluginutils package won't resolve.

npm init
npm i @rollup/pluginutils@3.1.0

Node.js succeeds:

require.resolve('@rollup/pluginutils');

.../node_modules/@rollup/pluginutils/dist/cjs/index.js

enhanced-require fails:

require('enhanced-resolve').sync(process.cwd(), '@rollup/pluginutils');

Error: Package path . is not exported from package .../node_modules/@rollup/pluginutils (see exports field in .../node_modules/@rollup/pluginutils/package.json)

@alexander-akait
Copy link
Member

@pauldraper
Copy link
Author

See install command; version is 3.1.0.

https://github.com/rollup/plugins/blob/master/packages/pluginutils/package.json

(And enhanced-resolve version is 5.8.3.)

@alexander-akait
Copy link
Member

alexander-akait commented Oct 20, 2021

Oh, by default enhanced-resolve is loading only default or node conditionals (because we don't know nothing about esm/commonjs, because it is programmatic usage), but no default and no node in package.json, we strongly recommend always add default (but maybe out of scope your abilities), you can use:

require('enhanced-resolve').create.sync({ conditionNames: ["require", "node"] })(process.cwd(), '@rollup/pluginutils');

@pauldraper
Copy link
Author

pauldraper commented Oct 20, 2021

Excellent that worked. Thanks for the fast help!

I don't know enough to say what is "at fault" but for my case, I am looking to match Node.js require.resolve (I'm not bundling for a browser or anything).

@alexander-akait
Copy link
Member

The main problem when you use require.resolve Node.js known that you in commonjs, so can use require, but when you use programmatic API we don't known about it

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

2 participants