From b9229fa0a774862436b7297c6e1074470c5974c7 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 7 Jun 2018 10:00:31 +0200 Subject: [PATCH] add parents correctly when creating namespace objects fixes #7477 --- lib/HotModuleReplacement.runtime.js | 7 ++++++- test/hotCases/runtime/bubble-async/file.js | 3 +++ test/hotCases/runtime/bubble-async/index.js | 16 ++++++++++++++++ .../hotCases/runtime/bubble-async/parent-file.js | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/hotCases/runtime/bubble-async/file.js create mode 100644 test/hotCases/runtime/bubble-async/index.js create mode 100644 test/hotCases/runtime/bubble-async/parent-file.js diff --git a/lib/HotModuleReplacement.runtime.js b/lib/HotModuleReplacement.runtime.js index 855ca302e9b..4afddedc939 100644 --- a/lib/HotModuleReplacement.runtime.js +++ b/lib/HotModuleReplacement.runtime.js @@ -55,7 +55,8 @@ module.exports = function() { for (var name in $require$) { if ( Object.prototype.hasOwnProperty.call($require$, name) && - name !== "e" + name !== "e" && + name !== "t" ) { Object.defineProperty(fn, name, ObjectFactory(name)); } @@ -80,6 +81,10 @@ module.exports = function() { } } }; + fn.t = function(value, mode) { + if (mode & 1) value = fn(value); + return $require$.t(value, mode & ~1); + }; return fn; } diff --git a/test/hotCases/runtime/bubble-async/file.js b/test/hotCases/runtime/bubble-async/file.js new file mode 100644 index 00000000000..77e3c4ea564 --- /dev/null +++ b/test/hotCases/runtime/bubble-async/file.js @@ -0,0 +1,3 @@ +module.exports = 1; +--- +module.exports = 2; diff --git a/test/hotCases/runtime/bubble-async/index.js b/test/hotCases/runtime/bubble-async/index.js new file mode 100644 index 00000000000..f1fca336436 --- /dev/null +++ b/test/hotCases/runtime/bubble-async/index.js @@ -0,0 +1,16 @@ +import { load } from "./parent-file"; +import update from "../../update"; + +it("should bubble update from a nested dependency", () => { + return load().then(value => { + expect(value).toBe(1); + return new Promise((resolve, reject) => { + module.hot.accept("./parent-file", () => { + resolve(load().then(value => { + expect(value).toBe(2); + })); + }); + NEXT(update(reject)); + }); + }) +}); diff --git a/test/hotCases/runtime/bubble-async/parent-file.js b/test/hotCases/runtime/bubble-async/parent-file.js new file mode 100644 index 00000000000..d1fc9fb33a0 --- /dev/null +++ b/test/hotCases/runtime/bubble-async/parent-file.js @@ -0,0 +1,3 @@ +export function load() { + return import("./file").then(file => file.default); +}