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

[3.1.0] this inside plugin hooks no loger points to the plugin object #10031

Closed
7 tasks done
csr632 opened this issue Sep 7, 2022 · 1 comment · Fixed by brillout/vite-plugin-mdx#52
Closed
7 tasks done

Comments

@csr632
Copy link
Member

csr632 commented Sep 7, 2022

Describe the bug

In this PR that just published: https://github.com/vitejs/vite/pull/9634/files#r965058188
If plugin authors use this in their plugin hooks to refer to the plugin object, like this:
https://github.com/brillout/vite-plugin-mdx/blob/ee4a732f19bd8ee072dc5257b96c3012f2cd6d75/src/index.ts#L52

After upgrading to vite@3.1.0, we get error when running vite serve:

TypeError: Cannot set properties of undefined (setting 'transform')
    at configResolved (/.../vite-plugin-mdx/dist/index.js:47:28)

stackblitz demo: https://stackblitz.com/edit/vitejs-vite-8xpzra?file=package.json&terminal=dev

Previous version works: vite@3.0.9.

Reproduction

https://stackblitz.com/edit/vitejs-vite-8xpzra?file=package.json&terminal=dev

System Info

vite@3.1.0

Used Package Manager

npm

Logs

No response

Validations

@antfu
Copy link
Member

antfu commented Sep 7, 2022

This is expected, plugins should not rely on hook's this to access the plugin object. #9885

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2022
csr632 added a commit to csr632/vite-plugin-mdx-1 that referenced this issue Sep 7, 2022
csr632 added a commit to csr632/vite-plugin-mdx-1 that referenced this issue Sep 7, 2022
brillout pushed a commit to brillout/vite-plugin-mdx that referenced this issue Sep 7, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants