WebpackMissingModule.js 671 B

123456789101112131415161718
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const toErrorCode = err => `var e = new Error(${JSON.stringify(err)}); e.code = 'MODULE_NOT_FOUND';`;
  7. exports.module = request => `!(function webpackMissingModule() { ${exports.moduleCode(request)} }())`;
  8. exports.promise = (request) => {
  9. const errorCode = toErrorCode(`Cannot find module "${request}"`);
  10. return `Promise.reject(function webpackMissingModule() { ${errorCode}; return e; }())`;
  11. };
  12. exports.moduleCode = (request) => {
  13. const errorCode = toErrorCode(`Cannot find module "${request}"`);
  14. return `${errorCode} throw e;`;
  15. };