-
Notifications
You must be signed in to change notification settings - Fork 30
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
resolve
#58
Comments
|
I don't think we can just suggest this one to be replaced. Sometimes you can, but very often projects are using APIs from |
fwiw you can replace I think Sadly |
Yes, unfortunately it's nowhere near robust enough (also one of the many reasons why I believe ESM is not prime-time yet, but that's another debate). We probably need to push for a proposal like nodejs/node#51855, which would also help with many of the hacks that https://github.com/nodejs/import-in-the-middle and https://github.com/vercel/nft/ have to do. thanks for the advice @ljharb!
This feels reasonable, I'll close this then! And see if I can get anyone excited about helping expose some stuff in Node.js directly 😄. |
We can replace
resolve
with built-ins starting Node8.9.0
and above.It pulls in a bunch of deps, and doesn’t support exports field and custom conditions (which is very common in modern JS apps).
For CJS you can use
require.resolve
. ESM is more tricky, you prob need https://www.npmjs.com/package/resolve.exports, but there isimport.meta.resolve
that was introduced with Node20.6.0
Here's an example PR I opened up with rollup that does the ESM thing: rollup/plugins#1742 (I may have to change this to make it work with ESM, need more testing)Here's an example PR (that tbh should be merged in to
require-in-the-middle
) that does the CJS port: elastic/require-in-the-middle#25The text was updated successfully, but these errors were encountered: