-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(pnp): esm - use correct error code when module not found #5355
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
Could you add a test to https://github.com/yarnpkg/berry/blob/ca475757fe85cdc2c4b4441f6d65d38fdab230ad/packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts?
Added tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and the tests!
* fix(pnp): Use correct error code when module not found * test(pnp): Add tests * Commits file updates * fix(pnp): re-throw regardless of what the error is --------- Co-authored-by: Kristoffer K <merceyz@users.noreply.github.com> Co-authored-by: Maël Nison <nison.mael@gmail.com>
* fix(pnp): Use correct error code when module not found * test(pnp): Add tests * Commits file updates * fix(pnp): re-throw regardless of what the error is --------- Co-Authored-By: Kristoffer K <merceyz@users.noreply.github.com> Co-Authored-By: Maël Nison <nison.mael@gmail.com>
What's the problem this PR addresses?
This PR makes the PnP ESM loader throw with error code
ERR_MODULE_NOT_FOUND
(instead ofMODULE_NOT_FOUND
) when a request cannot be resolved.Closes #5334
How did you fix it?
The error is thrown by the PnP CJS hook, and the ESM loader just calls the CJS hook. So we can just catch the error in the ESM loader, change the error code, and rethrow.
I am not sure about the package releases. I have marked
pnp
,plugin-pnp
andcli
as patch releases since other packages doesn't seem to use the ESM loader.Checklist