-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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(build): let top-level this
refer to globalThis
#5312
Conversation
This prevents THIS_IS_UNDEFINED warning from Rollup when @babel/plugin-transform-react-jsx emits `jsx` calls that pass `this` inside an arrow function component, which in turn leads to SOURCEMAP_ERROR warnings, because the `this` reference doesn't exist in the original code.
Hmm, I wonder if we should use "globalThis" in SSR env? @patak-js |
@aleclarson I think we should use |
Is there a way to silence this whilst waiting on this PR merge ? This is spamming my build logs with thousands of lines ahah |
@jordanamr Set |
I would vote for |
Co-authored-by: patak <matias.capeletto@gmail.com>
this
refer to window
this
refer to globalThis
this
refer to globalThis
this
refer to globalThis
this fix cause anthoer issue, will convert |
Could you open a new issue so this csn be properly tracked? |
sorry, comment metioned issue root casue is nuxt/bridge#204 |
If you think there is something to fix in Vite, please open an issue here |
@genffy That issue is unrelated to this PR. |
Description
This prevents
THIS_IS_UNDEFINED
warning from Rollup when@babel/plugin-transform-react-jsx
emitsjsx
calls that passthis
inside an arrow function component, which in turn leads toSOURCEMAP_ERROR
warnings, because thethis
reference doesn't exist in the original code.An example Rollup warning message for
SOURCEMAP_ERROR
:How code output is changed
This PR is especially important for
@vitejs/plugin-react
.…becomes…
Workaround
Ignore the warning, or set
rollupOptions.onwarn
to handle it manually.What is the purpose of this pull request?