NodeMainTemplateAsync.runtime.js 1.4 KB

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