naviapps / create-nw-react-app

Create NW.js React apps with no build configuration.
MIT License
144 stars 14 forks source link

Hot reload doesn't work for two nwjs windows. #75

Open spectrator73 opened 7 months ago

spectrator73 commented 7 months ago

In an application, one nwjs window is created from another nwjs window. After the second window is created, an error occurs when trying to make changes to the data of any of the windows. Only the last created window continues to update with the new data. Updating the data in the first created window does not give any results.

Error:

Uncaught TypeError: Cannot set properties of undefined (setting './src/main/Main.jsx')
    at global.webpackHotUpdateTEST_ (jsonp chunk loading:82:1)
    at main.b1f8b61b9c1c1af6cd0d.hot-update.js:2:32

The place in the jsonp chunks loading where the error occurs.

global["webpackHotUpdateTEST_"] = (chunkId, moreModules, runtime) => {
    for(var moduleId in moreModules) {
        if(__webpack_require__.o(moreModules, moduleId)) {
            currentUpdate[moduleId] = moreModules[moduleId];                                   <<< this line
            if(currentUpdatedModulesList) currentUpdatedModulesList.push(moduleId);
        }
    }
    if(runtime) currentUpdateRuntime.push(runtime);
    if(waitingUpdateResolves[chunkId]) {
        waitingUpdateResolves[chunkId]();
        waitingUpdateResolves[chunkId] = undefined;
    }
};
{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "nw-react-scripts": "5.1.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.21.2",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "nw-react-scripts start",
    "build": "nw-react-scripts build",
    "test": "nw-react-scripts test",
    "eject": "nw-react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "nw-react-app",
      "nw-react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "main": "index.html",
  "window": {
    "title": "test",
    "toolbar": false,
    "width": 800,
    "height": 450,
    "resizable": false,
    "always_on_top": true,
    "position": "center"
  },
  "nwbuilds": {
    "//": "https://nwutils.io/nw-builder/",
    "platforms": [
      "win32",
      "win64"
    ],
    "version": "0.82.0",
    "flavor": "normal",
    "outDir": "./out",
    "cacheDir": "./cache",
    "app": {
      "name": "test",
      "icon": "./src/logo.icns"
    }
  },
  "devDependencies": {
    "eslint": "^8.54.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-import": "^2.29.0",
    "eslint-plugin-jest": "^27.6.0",
    "eslint-plugin-jsx-a11y": "^6.8.0",
    "eslint-plugin-prettier": "^5.0.1",
    "eslint-plugin-react": "^7.33.2",
    "prettier": "^3.1.0"
  }
}

OS: Window 11 x64 Node.js: v20.9.0