| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Haijie Xie @hai-x
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | const RuntimeGlobals = require("../RuntimeGlobals");
|
|---|
| 9 |
|
|---|
| 10 | const Template = require("../Template");
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * Generates javascript hmr.
|
|---|
| 14 | * @param {string} type unique identifier used for HMR runtime properties
|
|---|
| 15 | * @returns {string} HMR runtime code
|
|---|
| 16 | */
|
|---|
| 17 | const generateJavascriptHMR = (type) =>
|
|---|
| 18 | Template.getFunctionContent(
|
|---|
| 19 | require("../hmr/JavascriptHotModuleReplacement.runtime")
|
|---|
| 20 | )
|
|---|
| 21 | .replace(/\$key\$/g, type)
|
|---|
| 22 | .replace(/\$installedChunks\$/g, "installedChunks")
|
|---|
| 23 | .replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
|
|---|
| 24 | .replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
|
|---|
| 25 | .replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
|
|---|
| 26 | .replace(/\$ensureChunkHandlers\$/g, RuntimeGlobals.ensureChunkHandlers)
|
|---|
| 27 | .replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
|
|---|
| 28 | .replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
|
|---|
| 29 | .replace(
|
|---|
| 30 | /\$hmrDownloadUpdateHandlers\$/g,
|
|---|
| 31 | RuntimeGlobals.hmrDownloadUpdateHandlers
|
|---|
| 32 | )
|
|---|
| 33 | .replace(
|
|---|
| 34 | /\$hmrInvalidateModuleHandlers\$/g,
|
|---|
| 35 | RuntimeGlobals.hmrInvalidateModuleHandlers
|
|---|
| 36 | );
|
|---|
| 37 |
|
|---|
| 38 | module.exports.generateJavascriptHMR = generateJavascriptHMR;
|
|---|