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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh not set on nested webpack require #714

Open
maraf opened this issue Jan 4, 2023 · 1 comment
Open

Refresh not set on nested webpack require #714

maraf opened this issue Jan 4, 2023 · 1 comment

Comments

@maraf
Copy link

maraf commented Jan 4, 2023

I have a sample where I build a npm package containing a react component and that I'm trying to use the package as a dependency in the target app. Repo maraf/dotnet-wasm-react and more details on the issue maraf/dotnet-wasm-react#6.

It works for production build, but it doesn't for react-scripts start.

It seems that the plugin generates an invalid code in this scenario.

image

/***/ "../qrlibrary/react/dist/index.webpack.js":
/*!************************************************!*\
  !*** ../qrlibrary/react/dist/index.webpack.js ***!
  \************************************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "QrImage": () => (/* binding */ __webpack_exports__QrImage)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../qrlibrary/react/node_modules/react/index.js");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ "./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
__nested_webpack_require_3181__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js");

The last line of code produces the error. The problem is the __nested_webpack_require_3181__, the "normal" __webpack_require__ has $Refresh$ configured correctly.

Any ideas?

@riteshjagga
Copy link

riteshjagga commented Nov 9, 2024

I get the same issue. My main project (Project A) has a dependency of Project B. Project B is not a React project but vanilla JS project. Webpack configuration of Project A have symlinks: true.

but Webpack's HMR of Project A expects __nested_webpack_require_xxxx__.$Refresh$.runtime in the bundled code.

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

2 participants