Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Apr 7, 2025

Description

Extracts common code from plugin-react and plugin-react-swc into packages/common. This package will be bundled to both plugins so the number of dependencies are still the same.

Behavior changes in each commit (due to misalignment of between plugins):

  • 707fd5d: none
  • 20d67ed
    • [plugin-react-swc] The Could not Fast Refresh error now points to https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#consistent-components-exports instead of https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports
    • [plugin-react] Properties other than injectIntoGlobalHook are removed from the default export object. I treated properties other than injectIntoGlobalHook is a internal thing, but it may treated as a breaking change.
  • c78fd21
    • [plugin-react] window.__vite_plugin_react_preamble_installed__ is removed. This should not change any behavior.
    • [plugin-react] viteReact.preambleCode is deprecated and viteReact.getPreambleCode is newly exposed reverted in 8d56222
  • 2ea890a
    • [plugin-react-swc] import.meta.hot && !inWebWorker check is added.
    • [plugin-react-swc] Cannot detect preamble error message is slightly changed.
    • [plugin-react] See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201 was removed from the cannot detect preamble error as it was stale.
  • d144462: none

@sapphi-red sapphi-red added the p1-chore 🧹 Doesn't change code behavior (priority) label Apr 7, 2025
Copy link
Member

@ArnaudBarre ArnaudBarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, this will make the new plugin so small !

Two notes for me:

  • I don't think going for the preambleCode->getPreambleCode deprecation is worth the added benefit for us or users.
  • I was happy without the import.meta.hot && !inWebWorker check in SWC because for me this checks only hide bundling issues. I'm afraid that if one day we implement HMR on webworker, we will break people that use to bundle random things in their worker. But given that most users as Babel users, it make sense to align in this direction

@sapphi-red
Copy link
Member Author

  • I don't think going for the preambleCode->getPreambleCode deprecation is worth the added benefit for us or users.

That's true. I'll remove this change.

@sapphi-red
Copy link
Member Author

I've updated 👍

@sapphi-red sapphi-red merged commit 099719f into main Apr 7, 2025
11 checks passed
@sapphi-red sapphi-red deleted the refactor/use-common-refresh-runtime branch April 7, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1-chore 🧹 Doesn't change code behavior (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants