react-refresh-webpack-plugin icon indicating copy to clipboard operation
react-refresh-webpack-plugin copied to clipboard

Refresh not set on nested webpack require

Open maraf opened this issue 2 years ago • 0 comments

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 https://github.com/maraf/dotnet-wasm-react/issues/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?

maraf avatar Jan 04 '23 10:01 maraf