diff --git a/hot/poll.js b/hot/poll.js new file mode 100644 index 0000000..f7855c9 --- /dev/null +++ b/hot/poll.js @@ -0,0 +1,47 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + Version 3e03edc on Jul 9, 2018 +*/ +/*globals __resourceQuery */ +if (module.hot) { + var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000; + var log = require("webpack/hot/log"); + + var checkForUpdate = function checkForUpdate(fromUpdate) { + if (module.hot.status() === "idle") { + module.hot + .check(true) + .then(function(updatedModules) { + if (!updatedModules) { + if (fromUpdate) log("info", "[HMR] Update applied."); + return; + } + require("webpack/hot/log-apply-result")(updatedModules, updatedModules); + checkForUpdate(true); + }) + .catch(function(err) { + var status = module.hot.status(); + if (["abort", "fail"].indexOf(status) >= 0) { + log("warning", "[HMR] Cannot apply update."); + log("warning", "[HMR] " + (err.stack || err.message)); + log("warning", "[HMR] You need to restart the application!"); + } else { + log( + "warning", + "[HMR] Update failed: " + (err.stack || err.message) + ); + } + // + if (process.send) { + log("warning", "[HMR] udk auto restart the application..."); + process.send({ action: 'run' }); + } + // + }); + } + }; + setInterval(checkForUpdate, hotPollInterval); +} else { + throw new Error("[HMR] Hot Module Replacement is disabled."); +} diff --git a/lib/devContainer.ts b/lib/devContainer.ts index ca4b942..ccc4835 100644 --- a/lib/devContainer.ts +++ b/lib/devContainer.ts @@ -651,7 +651,7 @@ export class DevContainerRuntime extends ContainerRuntime { if (!config.autoRestart) { ensureConfigHasPlugin(nodeConfigs, HMRPlugin, [ hmr.pluginNode ]); - ensureConfigHasEntry(nodeConfigs, 'webpack/hot/poll', hmr.hotPollInterval, { + ensureConfigHasEntry(nodeConfigs, 'udk/hot/poll', hmr.hotPollInterval, { entriesFilter: hmr.entriesNode, topModuleEntries: config.topModuleEntries, });