diff --git a/client/ReactRefreshEntry.js b/client/ReactRefreshEntry.js index 980073bc..825056e7 100644 --- a/client/ReactRefreshEntry.js +++ b/client/ReactRefreshEntry.js @@ -1,7 +1,7 @@ /* global __react_refresh_library__ */ -const safeThis = require('core-js-pure/features/global-this.js'); -const RefreshRuntime = require('react-refresh/runtime.js'); +const safeThis = require('core-js-pure/features/global-this'); +const RefreshRuntime = require('react-refresh/runtime'); if (process.env.NODE_ENV !== 'production') { if (typeof safeThis !== 'undefined') { diff --git a/loader/index.js b/loader/index.js index 282f11b3..f94a11ae 100644 --- a/loader/index.js +++ b/loader/index.js @@ -17,7 +17,7 @@ const { const schema = require('./options.json'); const RefreshRuntimePath = require - .resolve('react-refresh/runtime.js') + .resolve('react-refresh') .replace(/\\/g, '/') .replace(/'/g, "\\'"); diff --git a/sockets/WPSSocket.js b/sockets/WPSSocket.js index 13ee8a89..69361d8d 100644 --- a/sockets/WPSSocket.js +++ b/sockets/WPSSocket.js @@ -1,5 +1,5 @@ /* global ʎɐɹɔosǝʌɹǝs */ -const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket.js'); +const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket'); /** * Initializes a socket server for HMR for webpack-plugin-serve. diff --git a/test/jest-resolver.js b/test/jest-resolver.js index 89f820d8..9e469f38 100644 --- a/test/jest-resolver.js +++ b/test/jest-resolver.js @@ -4,11 +4,11 @@ * @return {string} */ function resolver(request, options) { - // This acts as a mock for `require.resolve('react-refresh/runtime.js')`, + // This acts as a mock for `require.resolve('react-refresh')`, // since the current mocking behaviour of Jest is not symmetrical, // i.e. only `require` is mocked but not `require.resolve`. - if (request === 'react-refresh/runtime.js') { - return 'react-refresh/runtime.js'; + if (request === 'react-refresh') { + return 'react-refresh'; } return options.defaultResolver(request, options); diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index 278aaf82..7cc067f2 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -16,92 +16,92 @@ describe('loader', () => { const { execution, parsed } = compilation.module; expect(parsed).toMatchInlineSnapshot(` -"__webpack_require__.$Refresh$.runtime = require('react-refresh/runtime.js'); - -module.exports = 'Test'; - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "__webpack_require__.$Refresh$.runtime = require('react-refresh'); + + module.exports = 'Test'; + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); expect(execution).toMatchInlineSnapshot(` -"(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"main\\"],{ - -/***/ \\"./index.js\\": -/*!******************!*\\\\ - !*** ./index.js ***! - \\\\******************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh/runtime.js */ \\"../../../../node_modules/react-refresh/runtime.js\\"); - -module.exports = 'Test'; - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (true) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -} - -/***/ }) - -},[[\\"./index.js\\",\\"runtime\\",\\"vendors\\"]]]);" -`); + "(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"main\\"],{ + + /***/ \\"./index.js\\": + /*!******************!*\\\\ + !*** ./index.js ***! + \\\\******************/ + /*! no static exports found */ + /***/ (function(module, exports, __webpack_require__) { + + __webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh */ \\"../../../../node_modules/react-refresh/runtime.js\\"); + + module.exports = 'Test'; + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (true) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + } + + /***/ }) + + },[[\\"./index.js\\",\\"runtime\\",\\"vendors\\"]]]);" + `); expect(compilation.errors).toStrictEqual([]); expect(compilation.warnings).toStrictEqual([]); @@ -112,94 +112,94 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr const { execution, parsed } = compilation.module; expect(parsed).toMatchInlineSnapshot(` -"__webpack_require__.$Refresh$.runtime = require('react-refresh/runtime.js'); - -export default 'Test'; - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "__webpack_require__.$Refresh$.runtime = require('react-refresh'); + + export default 'Test'; + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); expect(execution).toMatchInlineSnapshot(` -"(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"main\\"],{ - -/***/ \\"./index.js\\": -/*!******************!*\\\\ - !*** ./index.js ***! - \\\\******************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -\\"use strict\\"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh/runtime.js */ \\"../../../../node_modules/react-refresh/runtime.js\\"); - -/* harmony default export */ __webpack_exports__[\\"default\\"] = ('Test'); - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (true) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -} - -/***/ }) - -},[[\\"./index.js\\",\\"runtime\\",\\"vendors\\"]]]);" -`); + "(window[\\"webpackJsonp\\"] = window[\\"webpackJsonp\\"] || []).push([[\\"main\\"],{ + + /***/ \\"./index.js\\": + /*!******************!*\\\\ + !*** ./index.js ***! + \\\\******************/ + /*! exports provided: default */ + /***/ (function(module, __webpack_exports__, __webpack_require__) { + + \\"use strict\\"; + __webpack_require__.r(__webpack_exports__); + __webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh */ \\"../../../../node_modules/react-refresh/runtime.js\\"); + + /* harmony default export */ __webpack_exports__[\\"default\\"] = ('Test'); + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (true) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + } + + /***/ }) + + },[[\\"./index.js\\",\\"runtime\\",\\"vendors\\"]]]);" + `); expect(compilation.errors).toStrictEqual([]); expect(compilation.warnings).toStrictEqual([]); @@ -236,7 +236,7 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr const { execution, parsed } = compilation.module; expect(parsed).toMatchInlineSnapshot(` - "__webpack_require__.$Refresh$.runtime = require('react-refresh/runtime.js'); + "__webpack_require__.$Refresh$.runtime = require('react-refresh'); module.exports = 'Test'; @@ -273,60 +273,60 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr }" `); expect(execution).toMatchInlineSnapshot(` -"(self[\\"webpackChunkcjs\\"] = self[\\"webpackChunkcjs\\"] || []).push([[\\"main\\"],{ - -/***/ \\"./index.js\\": -/*!******************!*\\\\ - !*** ./index.js ***! - \\\\******************/ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh/runtime.js */ \\"../../../../node_modules/react-refresh/runtime.js\\"); - -module.exports = 'Test'; - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (true) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -} - -/***/ }) - -}, -/******/ __webpack_require__ => { // webpackRuntimeModules -/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) -/******/ __webpack_require__.O(0, [\\"defaultVendors\\"], () => (__webpack_exec__(\\"./index.js\\"))); -/******/ var __webpack_exports__ = __webpack_require__.O(); -/******/ } -]);" -`); + "(self[\\"webpackChunkcjs\\"] = self[\\"webpackChunkcjs\\"] || []).push([[\\"main\\"],{ + + /***/ \\"./index.js\\": + /*!******************!*\\\\ + !*** ./index.js ***! + \\\\******************/ + /***/ ((module, __unused_webpack_exports, __webpack_require__) => { + + __webpack_require__.$Refresh$.runtime = __webpack_require__(/*! react-refresh */ \\"../../../../node_modules/react-refresh/runtime.js\\"); + + module.exports = 'Test'; + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (true) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + } + + /***/ }) + + }, + /******/ __webpack_require__ => { // webpackRuntimeModules + /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) + /******/ __webpack_require__.O(0, [\\"defaultVendors\\"], () => (__webpack_exec__(\\"./index.js\\"))); + /******/ var __webpack_exports__ = __webpack_require__.O(); + /******/ } + ]);" + `); expect(compilation.errors).toStrictEqual([]); expect(compilation.warnings).toStrictEqual([]); @@ -337,101 +337,101 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr const { execution, parsed } = compilation.module; expect(parsed).toMatchInlineSnapshot(` -"__webpack_require__.$Refresh$.runtime = require('react-refresh/runtime.js'); - -export default 'Test'; - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "__webpack_require__.$Refresh$.runtime = require('react-refresh'); + + export default 'Test'; + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); expect(execution).toMatchInlineSnapshot(` -"\\"use strict\\"; -(self[\\"webpackChunkesm\\"] = self[\\"webpackChunkesm\\"] || []).push([[\\"main\\"],{ - -/***/ \\"./index.js\\": -/*!******************!*\\\\ - !*** ./index.js ***! - \\\\******************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ \\"default\\": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -__webpack_require__.$Refresh$.runtime = require('react-refresh/runtime.js'); - -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ('Test'); - - -var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -} - -/***/ }) - -}, -/******/ __webpack_require__ => { // webpackRuntimeModules -/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) -/******/ var __webpack_exports__ = (__webpack_exec__(\\"./index.js\\")); -/******/ } -]);" -`); + "\\"use strict\\"; + (self[\\"webpackChunkesm\\"] = self[\\"webpackChunkesm\\"] || []).push([[\\"main\\"],{ + + /***/ \\"./index.js\\": + /*!******************!*\\\\ + !*** ./index.js ***! + \\\\******************/ + /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + + __webpack_require__.r(__webpack_exports__); + /* harmony export */ __webpack_require__.d(__webpack_exports__, { + /* harmony export */ \\"default\\": () => (__WEBPACK_DEFAULT_EXPORT__) + /* harmony export */ }); + __webpack_require__.$Refresh$.runtime = require('react-refresh'); + + /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ('Test'); + + + var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + } + + /***/ }) + + }, + /******/ __webpack_require__ => { // webpackRuntimeModules + /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) + /******/ var __webpack_exports__ = (__webpack_exec__(\\"./index.js\\")); + /******/ } + ]);" + `); expect(compilation.errors).toStrictEqual([]); expect(compilation.warnings).toStrictEqual([]); @@ -442,20 +442,20 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr const { execution, sourceMap } = compilation.module; expect(sourceMap).toMatchInlineSnapshot(` -"{ - \\"version\\": 3, - \\"file\\": \\"main.js\\", - \\"mappings\\": \\";;;;;;;;;;AAAA\\", - \\"sources\\": [ - \\"webpack://cjs/./index.js\\" - ], - \\"sourcesContent\\": [ - \\"module.exports = 'Test';\\\\n\\" - ], - \\"names\\": [], - \\"sourceRoot\\": \\"\\" -}" -`); + "{ + \\"version\\": 3, + \\"file\\": \\"main.js\\", + \\"mappings\\": \\";;;;;;;;;;AAAA\\", + \\"sources\\": [ + \\"webpack://cjs/./index.js\\" + ], + \\"sourcesContent\\": [ + \\"module.exports = 'Test';\\\\n\\" + ], + \\"names\\": [], + \\"sourceRoot\\": \\"\\" + }" + `); expect(() => { validate(execution, sourceMap); }).not.toThrow(); diff --git a/test/loader/unit/getRefreshModuleRuntime.test.js b/test/loader/unit/getRefreshModuleRuntime.test.js index e9a783e0..c704c44f 100644 --- a/test/loader/unit/getRefreshModuleRuntime.test.js +++ b/test/loader/unit/getRefreshModuleRuntime.test.js @@ -14,37 +14,37 @@ describe('getRefreshModuleRuntime', () => { expect(refreshModuleRuntime.indexOf('module.hot')).not.toBe(-1); expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).toBe(-1); expect(refreshModuleRuntime).toMatchInlineSnapshot(` -"var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); }); it('should return working refresh module runtime with const using CommonJS', () => { @@ -59,37 +59,37 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr expect(refreshModuleRuntime.indexOf('module.hot')).not.toBe(-1); expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).toBe(-1); expect(refreshModuleRuntime).toMatchInlineSnapshot(` -"const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (module.hot) { - let errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - let testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - module.hot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (module.hot) { + let errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + let testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + module.hot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); }); it('should return working refresh module runtime without const using ES Modules', () => { @@ -104,37 +104,37 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr expect(refreshModuleRuntime.indexOf('module.hot')).toBe(-1); expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).not.toBe(-1); expect(refreshModuleRuntime).toMatchInlineSnapshot(` -"var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (import.meta.webpackHot) { - var errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - var testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - import.meta.webpackHot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (import.meta.webpackHot) { + var errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + var testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + import.meta.webpackHot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); }); it('should return working refresh module runtime with const using ES Modules', () => { @@ -149,36 +149,36 @@ if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Pr expect(refreshModuleRuntime.indexOf('module.hot')).toBe(-1); expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).not.toBe(-1); expect(refreshModuleRuntime).toMatchInlineSnapshot(` -"const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; -const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( - $ReactRefreshModuleId$ -); - -function $ReactRefreshModuleRuntime$(exports) { - if (import.meta.webpackHot) { - let errorOverlay; - if (typeof __react_refresh_error_overlay__ !== 'undefined') { - errorOverlay = __react_refresh_error_overlay__; - } - let testMode; - if (typeof __react_refresh_test__ !== 'undefined') { - testMode = __react_refresh_test__; - } - return __react_refresh_utils__.executeRuntime( - exports, - $ReactRefreshModuleId$, - import.meta.webpackHot, - errorOverlay, - testMode - ); - } -} - -if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { - $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); -} else { - $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); -}" -`); + "const $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; + const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( + $ReactRefreshModuleId$ + ); + + function $ReactRefreshModuleRuntime$(exports) { + if (import.meta.webpackHot) { + let errorOverlay; + if (typeof __react_refresh_error_overlay__ !== 'undefined') { + errorOverlay = __react_refresh_error_overlay__; + } + let testMode; + if (typeof __react_refresh_test__ !== 'undefined') { + testMode = __react_refresh_test__; + } + return __react_refresh_utils__.executeRuntime( + exports, + $ReactRefreshModuleId$, + import.meta.webpackHot, + errorOverlay, + testMode + ); + } + } + + if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { + $ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); + } else { + $ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); + }" + `); }); }); diff --git a/test/unit/getRefreshGlobal.test.js b/test/unit/getRefreshGlobal.test.js index f64f6128..d2ef158e 100644 --- a/test/unit/getRefreshGlobal.test.js +++ b/test/unit/getRefreshGlobal.test.js @@ -13,39 +13,39 @@ describe('getRefreshGlobal', () => { it('should return working refresh global without providing runtime template', () => { const refreshGlobalTemplate = getRefreshGlobal(Template); expect(refreshGlobalTemplate).toMatchInlineSnapshot(` -"__webpack_require__.$Refresh$ = { - register: function() { return undefined; }, - signature: function() { return function(type) { return type; }; }, - runtime: { - createSignatureFunctionForTransform: function() { return function(type) { return type; }; }, - register: function() { return undefined; } - }, - setup: function(currentModuleId) { - var prevModuleId = __webpack_require__.$Refresh$.moduleId; - var prevRegister = __webpack_require__.$Refresh$.register; - var prevSignature = __webpack_require__.$Refresh$.signature; - var prevCleanup = __webpack_require__.$Refresh$.cleanup; + "__webpack_require__.$Refresh$ = { + register: function() { return undefined; }, + signature: function() { return function(type) { return type; }; }, + runtime: { + createSignatureFunctionForTransform: function() { return function(type) { return type; }; }, + register: function() { return undefined; } + }, + setup: function(currentModuleId) { + var prevModuleId = __webpack_require__.$Refresh$.moduleId; + var prevRegister = __webpack_require__.$Refresh$.register; + var prevSignature = __webpack_require__.$Refresh$.signature; + var prevCleanup = __webpack_require__.$Refresh$.cleanup; - __webpack_require__.$Refresh$.moduleId = currentModuleId; + __webpack_require__.$Refresh$.moduleId = currentModuleId; - __webpack_require__.$Refresh$.register = function(type, id) { - var typeId = currentModuleId + \\" \\" + id; - __webpack_require__.$Refresh$.runtime.register(type, typeId); - } + __webpack_require__.$Refresh$.register = function(type, id) { + var typeId = currentModuleId + \\" \\" + id; + __webpack_require__.$Refresh$.runtime.register(type, typeId); + } - __webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); }; + __webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); }; - __webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) { - if (currentModuleId === cleanupModuleId) { - __webpack_require__.$Refresh$.moduleId = prevModuleId; - __webpack_require__.$Refresh$.register = prevRegister; - __webpack_require__.$Refresh$.signature = prevSignature; - __webpack_require__.$Refresh$.cleanup = prevCleanup; - } - } - } -};" -`); + __webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) { + if (currentModuleId === cleanupModuleId) { + __webpack_require__.$Refresh$.moduleId = prevModuleId; + __webpack_require__.$Refresh$.register = prevRegister; + __webpack_require__.$Refresh$.signature = prevSignature; + __webpack_require__.$Refresh$.cleanup = prevCleanup; + } + } + } + };" + `); expect(() => { eval(refreshGlobalTemplate); }).not.toThrow(); @@ -74,39 +74,39 @@ describe('getRefreshGlobal', () => { new RuntimeTemplate({}, { environment: { arrowFunction: true, const: true } }, (i) => i) ); expect(refreshGlobalTemplate).toMatchInlineSnapshot(` -"__webpack_require__.$Refresh$ = { - register: () => (undefined), - signature: () => ((type) => (type)), - runtime: { - createSignatureFunctionForTransform: () => ((type) => (type)), - register: () => (undefined) - }, - setup: (currentModuleId) => { - const prevModuleId = __webpack_require__.$Refresh$.moduleId; - const prevRegister = __webpack_require__.$Refresh$.register; - const prevSignature = __webpack_require__.$Refresh$.signature; - const prevCleanup = __webpack_require__.$Refresh$.cleanup; + "__webpack_require__.$Refresh$ = { + register: () => (undefined), + signature: () => ((type) => (type)), + runtime: { + createSignatureFunctionForTransform: () => ((type) => (type)), + register: () => (undefined) + }, + setup: (currentModuleId) => { + const prevModuleId = __webpack_require__.$Refresh$.moduleId; + const prevRegister = __webpack_require__.$Refresh$.register; + const prevSignature = __webpack_require__.$Refresh$.signature; + const prevCleanup = __webpack_require__.$Refresh$.cleanup; - __webpack_require__.$Refresh$.moduleId = currentModuleId; + __webpack_require__.$Refresh$.moduleId = currentModuleId; - __webpack_require__.$Refresh$.register = (type, id) => { - const typeId = currentModuleId + \\" \\" + id; - __webpack_require__.$Refresh$.runtime.register(type, typeId); - } + __webpack_require__.$Refresh$.register = (type, id) => { + const typeId = currentModuleId + \\" \\" + id; + __webpack_require__.$Refresh$.runtime.register(type, typeId); + } - __webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform()); + __webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform()); - __webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => { - if (currentModuleId === cleanupModuleId) { - __webpack_require__.$Refresh$.moduleId = prevModuleId; - __webpack_require__.$Refresh$.register = prevRegister; - __webpack_require__.$Refresh$.signature = prevSignature; - __webpack_require__.$Refresh$.cleanup = prevCleanup; - } - } - } -};" -`); + __webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => { + if (currentModuleId === cleanupModuleId) { + __webpack_require__.$Refresh$.moduleId = prevModuleId; + __webpack_require__.$Refresh$.register = prevRegister; + __webpack_require__.$Refresh$.signature = prevSignature; + __webpack_require__.$Refresh$.cleanup = prevCleanup; + } + } + } + };" + `); expect(() => { eval(refreshGlobalTemplate); }).not.toThrow(); diff --git a/test/unit/makeRefreshRuntimeModule.test.js b/test/unit/makeRefreshRuntimeModule.test.js index 07f888ba..96fdfecd 100644 --- a/test/unit/makeRefreshRuntimeModule.test.js +++ b/test/unit/makeRefreshRuntimeModule.test.js @@ -38,64 +38,64 @@ describe.skipIf(WEBPACK_VERSION !== 5, 'makeRefreshRuntimeModule', () => { const runtime = instance.generate(); expect(runtime).toMatchInlineSnapshot(` -"__webpack_require__.i.push(function(options) { - var originalFactory = options.factory; - options.factory = function (moduleObject, moduleExports, webpackRequire) { - __webpack_require__.$Refresh$.setup(options.id); - try { - originalFactory.call(this, moduleObject, moduleExports, webpackRequire); - } finally { - if (typeof Promise !== 'undefined' && moduleObject.exports instanceof Promise) { - options.module.exports = options.module.exports.then( - function(result) { - __webpack_require__.$Refresh$.cleanup(options.id); - return result; - }, - function(reason) { - __webpack_require__.$Refresh$.cleanup(options.id); - return Promise.reject(reason); - } - ); - } else { - __webpack_require__.$Refresh$.cleanup(options.id) - } - } - }; -}) - -__webpack_require__.$Refresh$ = { - register: function() { return undefined; }, - signature: function() { return function(type) { return type; }; }, - runtime: { - createSignatureFunctionForTransform: function() { return function(type) { return type; }; }, - register: function() { return undefined; } - }, - setup: function(currentModuleId) { - var prevModuleId = __webpack_require__.$Refresh$.moduleId; - var prevRegister = __webpack_require__.$Refresh$.register; - var prevSignature = __webpack_require__.$Refresh$.signature; - var prevCleanup = __webpack_require__.$Refresh$.cleanup; - - __webpack_require__.$Refresh$.moduleId = currentModuleId; - - __webpack_require__.$Refresh$.register = function(type, id) { - var typeId = currentModuleId + \\" \\" + id; - __webpack_require__.$Refresh$.runtime.register(type, typeId); - } - - __webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); }; - - __webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) { - if (currentModuleId === cleanupModuleId) { - __webpack_require__.$Refresh$.moduleId = prevModuleId; - __webpack_require__.$Refresh$.register = prevRegister; - __webpack_require__.$Refresh$.signature = prevSignature; - __webpack_require__.$Refresh$.cleanup = prevCleanup; - } - } - } -};" -`); + "__webpack_require__.i.push(function(options) { + var originalFactory = options.factory; + options.factory = function (moduleObject, moduleExports, webpackRequire) { + __webpack_require__.$Refresh$.setup(options.id); + try { + originalFactory.call(this, moduleObject, moduleExports, webpackRequire); + } finally { + if (typeof Promise !== 'undefined' && moduleObject.exports instanceof Promise) { + options.module.exports = options.module.exports.then( + function(result) { + __webpack_require__.$Refresh$.cleanup(options.id); + return result; + }, + function(reason) { + __webpack_require__.$Refresh$.cleanup(options.id); + return Promise.reject(reason); + } + ); + } else { + __webpack_require__.$Refresh$.cleanup(options.id) + } + } + }; + }) + + __webpack_require__.$Refresh$ = { + register: function() { return undefined; }, + signature: function() { return function(type) { return type; }; }, + runtime: { + createSignatureFunctionForTransform: function() { return function(type) { return type; }; }, + register: function() { return undefined; } + }, + setup: function(currentModuleId) { + var prevModuleId = __webpack_require__.$Refresh$.moduleId; + var prevRegister = __webpack_require__.$Refresh$.register; + var prevSignature = __webpack_require__.$Refresh$.signature; + var prevCleanup = __webpack_require__.$Refresh$.cleanup; + + __webpack_require__.$Refresh$.moduleId = currentModuleId; + + __webpack_require__.$Refresh$.register = function(type, id) { + var typeId = currentModuleId + \\" \\" + id; + __webpack_require__.$Refresh$.runtime.register(type, typeId); + } + + __webpack_require__.$Refresh$.signature = function() { return __webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform(); }; + + __webpack_require__.$Refresh$.cleanup = function(cleanupModuleId) { + if (currentModuleId === cleanupModuleId) { + __webpack_require__.$Refresh$.moduleId = prevModuleId; + __webpack_require__.$Refresh$.register = prevRegister; + __webpack_require__.$Refresh$.signature = prevSignature; + __webpack_require__.$Refresh$.cleanup = prevCleanup; + } + } + } + };" + `); expect(() => { eval(runtime); }).not.toThrow(); @@ -117,64 +117,64 @@ __webpack_require__.$Refresh$ = { const runtime = instance.generate(); expect(runtime).toMatchInlineSnapshot(` -"__webpack_require__.i.push((options) => { - const originalFactory = options.factory; - options.factory = function (moduleObject, moduleExports, webpackRequire) { - __webpack_require__.$Refresh$.setup(options.id); - try { - originalFactory.call(this, moduleObject, moduleExports, webpackRequire); - } finally { - if (typeof Promise !== 'undefined' && moduleObject.exports instanceof Promise) { - options.module.exports = options.module.exports.then( - (result) => { - __webpack_require__.$Refresh$.cleanup(options.id); - return result; - }, - (reason) => { - __webpack_require__.$Refresh$.cleanup(options.id); - return Promise.reject(reason); - } - ); - } else { - __webpack_require__.$Refresh$.cleanup(options.id) - } - } - }; -}) - -__webpack_require__.$Refresh$ = { - register: () => (undefined), - signature: () => ((type) => (type)), - runtime: { - createSignatureFunctionForTransform: () => ((type) => (type)), - register: () => (undefined) - }, - setup: (currentModuleId) => { - const prevModuleId = __webpack_require__.$Refresh$.moduleId; - const prevRegister = __webpack_require__.$Refresh$.register; - const prevSignature = __webpack_require__.$Refresh$.signature; - const prevCleanup = __webpack_require__.$Refresh$.cleanup; - - __webpack_require__.$Refresh$.moduleId = currentModuleId; - - __webpack_require__.$Refresh$.register = (type, id) => { - const typeId = currentModuleId + \\" \\" + id; - __webpack_require__.$Refresh$.runtime.register(type, typeId); - } - - __webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform()); - - __webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => { - if (currentModuleId === cleanupModuleId) { - __webpack_require__.$Refresh$.moduleId = prevModuleId; - __webpack_require__.$Refresh$.register = prevRegister; - __webpack_require__.$Refresh$.signature = prevSignature; - __webpack_require__.$Refresh$.cleanup = prevCleanup; - } - } - } -};" -`); + "__webpack_require__.i.push((options) => { + const originalFactory = options.factory; + options.factory = function (moduleObject, moduleExports, webpackRequire) { + __webpack_require__.$Refresh$.setup(options.id); + try { + originalFactory.call(this, moduleObject, moduleExports, webpackRequire); + } finally { + if (typeof Promise !== 'undefined' && moduleObject.exports instanceof Promise) { + options.module.exports = options.module.exports.then( + (result) => { + __webpack_require__.$Refresh$.cleanup(options.id); + return result; + }, + (reason) => { + __webpack_require__.$Refresh$.cleanup(options.id); + return Promise.reject(reason); + } + ); + } else { + __webpack_require__.$Refresh$.cleanup(options.id) + } + } + }; + }) + + __webpack_require__.$Refresh$ = { + register: () => (undefined), + signature: () => ((type) => (type)), + runtime: { + createSignatureFunctionForTransform: () => ((type) => (type)), + register: () => (undefined) + }, + setup: (currentModuleId) => { + const prevModuleId = __webpack_require__.$Refresh$.moduleId; + const prevRegister = __webpack_require__.$Refresh$.register; + const prevSignature = __webpack_require__.$Refresh$.signature; + const prevCleanup = __webpack_require__.$Refresh$.cleanup; + + __webpack_require__.$Refresh$.moduleId = currentModuleId; + + __webpack_require__.$Refresh$.register = (type, id) => { + const typeId = currentModuleId + \\" \\" + id; + __webpack_require__.$Refresh$.runtime.register(type, typeId); + } + + __webpack_require__.$Refresh$.signature = () => (__webpack_require__.$Refresh$.runtime.createSignatureFunctionForTransform()); + + __webpack_require__.$Refresh$.cleanup = (cleanupModuleId) => { + if (currentModuleId === cleanupModuleId) { + __webpack_require__.$Refresh$.moduleId = prevModuleId; + __webpack_require__.$Refresh$.register = prevRegister; + __webpack_require__.$Refresh$.signature = prevSignature; + __webpack_require__.$Refresh$.cleanup = prevCleanup; + } + } + } + };" + `); expect(() => { eval(runtime); }).not.toThrow();