You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. /*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */
  6. module.exports = function() {
  7. // eslint-disable-next-line no-unused-vars
  8. function hotDownloadUpdateChunk(chunkId) {
  9. var filename = require("path").join(__dirname, $hotChunkFilename$);
  10. require("fs").readFile(filename, "utf-8", function(err, content) {
  11. if (err) {
  12. if ($require$.onError) return $require$.oe(err);
  13. throw err;
  14. }
  15. var chunk = {};
  16. require("vm").runInThisContext(
  17. "(function(exports) {" + content + "\n})",
  18. { filename: filename }
  19. )(chunk);
  20. hotAddUpdateChunk(chunk.id, chunk.modules);
  21. });
  22. }
  23. // eslint-disable-next-line no-unused-vars
  24. function hotDownloadManifest() {
  25. var filename = require("path").join(__dirname, $hotMainFilename$);
  26. return new Promise(function(resolve, reject) {
  27. require("fs").readFile(filename, "utf-8", function(err, content) {
  28. if (err) return resolve();
  29. try {
  30. var update = JSON.parse(content);
  31. } catch (e) {
  32. return reject(e);
  33. }
  34. resolve(update);
  35. });
  36. });
  37. }
  38. // eslint-disable-next-line no-unused-vars
  39. function hotDisposeChunk(chunkId) {
  40. delete installedChunks[chunkId];
  41. }
  42. };