fix(build): let top-level this refer to globalThis#5312
fix(build): let top-level this refer to globalThis#5312patak-cat merged 2 commits intovitejs:mainfrom
this refer to globalThis#5312Conversation
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 <[email protected]>
this refer to windowthis refer to globalThis
this refer to globalThisthis 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_UNDEFINEDwarning from Rollup when@babel/plugin-transform-react-jsxemitsjsxcalls that passthisinside an arrow function component, which in turn leads toSOURCEMAP_ERRORwarnings, because thethisreference 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.onwarnto handle it manually.What is the purpose of this pull request?