-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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(dev): bind plugin context functions #14569
Conversation
b4f4b1f
to
e5023da
Compare
@sapphi-red this is ready |
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!
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 guess there's no harm to bind this
, but Rollup doesn't call bind(this)
on the plugin context either: https://github.com/rollup/rollup/blob/fac5f1c1c12dc0409ff090664e305586747dc2f7/src/utils/PluginContext.ts#L60-L114
It happens that the commonjs plugin assumes that this.load
isn't binding sensitive and it worked. So having this fixed on the commonjs plugin side would also be nice.
I looked at the functions again and i noticed that the concept is to have all functions either with bind or not binding sensitive. |
Of course it does not bind. You do not need to bind if you do not access |
Ok fair enough, |
@lukastaegert I don't mind to proceed with this PR if you intended for the plugin context to already be bound. Would you prefer we go with this then? I was thinking it's odd that you'd pass If we do go with this PR, it's not completed yet. There's still functions not bound like |
By the way, the |
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 would prefer these functions to not be bound, but given that this was already an expectation in the Rollup ecosystem, I think we could merge this PR. Later on, we could still decide to remove this feature, but do it in sync both in Rollup and Vite if there is consensus and it is justified.
Well, Rollup does not bind, it just does not use |
Ha, yes, we are on the same page, but just in case for reference I mean if it is ever decided that users can't expect By the way, all methods in the Vite dev server can also be used without being bound to the vite server, but this is an undocumented implementation detail. I hope no one is relying on this right now, maybe we'll end up having issues in the future if we ever change to a different implementation. |
Co-authored-by: Bjorn Lu <[email protected]>
rollup binds the plugin context functions to itself and plugins use that.
e.g. commonjs.
closes rollup/plugins#1603
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).