diff --git a/crates/rspack_plugin_runtime/src/runtime_module/runtime/javascript_hot_module_replacement.js b/crates/rspack_plugin_runtime/src/runtime_module/runtime/javascript_hot_module_replacement.js index c2e145f8fa61..374e41b5b672 100644 --- a/crates/rspack_plugin_runtime/src/runtime_module/runtime/javascript_hot_module_replacement.js +++ b/crates/rspack_plugin_runtime/src/runtime_module/runtime/javascript_hot_module_replacement.js @@ -98,6 +98,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) { diff --git a/tests/rspack-test/hotCases/chunks/update-chunk-loading-runtime/__snapshots__/web/1.snap.txt b/tests/rspack-test/hotCases/chunks/update-chunk-loading-runtime/__snapshots__/web/1.snap.txt index 5d04419703a2..6ad3f9c734df 100644 --- a/tests/rspack-test/hotCases/chunks/update-chunk-loading-runtime/__snapshots__/web/1.snap.txt +++ b/tests/rspack-test/hotCases/chunks/update-chunk-loading-runtime/__snapshots__/web/1.snap.txt @@ -11,7 +11,7 @@ - Bundle: vendors-node_modules_vendor_js.js - Manifest: runtime~main.LAST_HASH.hot-update.json, size: 76 - Update: main.LAST_HASH.hot-update.js, size: 714 -- Update: runtime~main.LAST_HASH.hot-update.js, size: 18966 +- Update: runtime~main.LAST_HASH.hot-update.js, size: 19038 - Update: vendors-node_modules_vendor_js.LAST_HASH.hot-update.js, size: 513 ## Manifest @@ -309,6 +309,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) { diff --git a/tests/rspack-test/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt b/tests/rspack-test/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt index b0fe00a35440..acfd3dd6e971 100644 --- a/tests/rspack-test/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt +++ b/tests/rspack-test/hotCases/disposing/remove-chunk-with-shared-in-other-runtime/__snapshots__/web/1.snap.txt @@ -8,7 +8,7 @@ - Bundle: chunk1_js.chunk.CURRENT_HASH.js - Manifest: [runtime of chunk2_js].LAST_HASH.hot-update.json, size: 60 - Manifest: main.LAST_HASH.hot-update.json, size: 41 -- Update: main.LAST_HASH.hot-update.js, size: 18468 +- Update: main.LAST_HASH.hot-update.js, size: 18540 ## Manifest @@ -267,6 +267,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) { diff --git a/tests/rspack-test/hotCases/disposing/runtime-independent-filename/__snapshots__/web/1.snap.txt b/tests/rspack-test/hotCases/disposing/runtime-independent-filename/__snapshots__/web/1.snap.txt index ce348f80e785..50cbabe0abc2 100644 --- a/tests/rspack-test/hotCases/disposing/runtime-independent-filename/__snapshots__/web/1.snap.txt +++ b/tests/rspack-test/hotCases/disposing/runtime-independent-filename/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Bundle: chunk1_js.chunk.CURRENT_HASH.js -- Update: main.LAST_HASH.hot-update.js, size: 18468 +- Update: main.LAST_HASH.hot-update.js, size: 18540 ## Manifest @@ -251,6 +251,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) { diff --git a/tests/rspack-test/hotCases/module/access-dropped-module/__snapshots__/web/1.snap.txt b/tests/rspack-test/hotCases/module/access-dropped-module/__snapshots__/web/1.snap.txt index 408dea270321..fc1808de632d 100644 --- a/tests/rspack-test/hotCases/module/access-dropped-module/__snapshots__/web/1.snap.txt +++ b/tests/rspack-test/hotCases/module/access-dropped-module/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 42 -- Update: main.LAST_HASH.hot-update.js, size: 15415 +- Update: main.LAST_HASH.hot-update.js, size: 15487 ## Manifest @@ -201,6 +201,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) { diff --git a/tests/rspack-test/hotCases/runtime/require-disposed-module-warning/index.js b/tests/rspack-test/hotCases/runtime/require-disposed-module-warning/index.js index 5f903f672a4f..1826a5b54faa 100644 --- a/tests/rspack-test/hotCases/runtime/require-disposed-module-warning/index.js +++ b/tests/rspack-test/hotCases/runtime/require-disposed-module-warning/index.js @@ -3,7 +3,7 @@ const getInner = require("./module"); it("should print correct warning messages when a disposed module is required", async () => { await NEXT_HMR(); - getInner(); + try { getInner(); } catch (e) { } expectWarning( /^\[HMR] unexpected require\(\.\/a.js\) from disposed module \.\/module\.js$/, /^\[HMR] unexpected require\(\.\/a.js\) to disposed module$/ diff --git a/tests/rspack-test/hotCases/sharing/share-plugin/__snapshots__/web/1.snap.txt b/tests/rspack-test/hotCases/sharing/share-plugin/__snapshots__/web/1.snap.txt index ed68b7d677d6..ccd28770d8da 100644 --- a/tests/rspack-test/hotCases/sharing/share-plugin/__snapshots__/web/1.snap.txt +++ b/tests/rspack-test/hotCases/sharing/share-plugin/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ - Bundle: bundle.js - Bundle: common_js_2.chunk.CURRENT_HASH.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 42484 +- Update: main.LAST_HASH.hot-update.js, size: 42556 ## Manifest @@ -878,6 +878,7 @@ function applyHandler(options) { console.warn( "[HMR] unexpected require(" + module.id + ") to disposed module" ); + throw Error("RuntimeError: factory is undefined(" + module.id + ")"); }; for (var moduleId in currentUpdate) {