-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
feat(commonjs): prevent rewrite require.resolve #446
Conversation
988a6ee
to
a6fee67
Compare
Could you please outline real-world use cases of Because there are many cases where it’s not clear what that |
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.
This seems like a sensible approach to me. Allowing remapping of require.resolve
expressions could be another approach.
Ideally such a function could be rewritten to import.meta.resolve
- but the work for that is still in progress and it will be a long while before browsers ship something like this.
@danielgindi @lukastaegert should we merge this one? thanks for taking a look @guybedford |
I’m not sure yet. I don’t think we have enough clarity on what happens when, or what the user expects when using these specific |
@lukastaegert please take a look when life allows. I think this one is important and don't want to let it get too stale. |
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.
I think it is a reasonable solution for now. The code itself looks sensible. Otherwise, generated code will only work in a CommonJS module in Node, but that is more than can be said for the current state where the code works nowhere. As @guybedford said, in the future there might be a native ESM equivalent, but that does not really exist yet.
So I would ship it like it is for now as it does not break anything but makes some use-cases work and is not very complicated code-wise and thus easily replaced by a better solution in the future if we find one.
Actually with this solution in place, one might easily inject a polyfill for |
Rollup Plugin Name:
commonjs
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
#406
Description
Prevent commonjs plugin rewrite Nodejs original
require
methods.