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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with multiple entry points in webpack where one entry does not use react #798

Open
dan-pixels360 opened this issue Feb 2, 2024 · 0 comments

Comments

@dan-pixels360
Copy link

dan-pixels360 commented Feb 2, 2024

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch @pmmmwh/react-refresh-webpack-plugin@0.5.11 for the project I'm working on.

When using multiple entries in webpack if one bundle does not have RefreshRuntime it will throw an error and break code. Was using this with Wordpress Gutenberg where in the Wordpress admin panel Gutenberg uses react for sidebar items but in the front end we don't use react at all. Adding RefreshRuntime to the condition makes it work for both.

Here is the diff that solved my problem:

diff --git a/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js b/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js
index 825056e..30a8722 100644
--- a/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js
+++ b/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV !== 'production') {
     }
 
     // Only inject the runtime if it hasn't been injected
-    if (!safeThis[$RefreshInjected$]) {
+    if (!safeThis[$RefreshInjected$] && RefreshRuntime) {
       // Inject refresh runtime into global scope
       RefreshRuntime.injectIntoGlobalHook(safeThis);
 

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant