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.

20 lines
650 B

4 years ago
  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 =>
  7. `var e = new Error(${JSON.stringify(err)}); e.code = 'MODULE_NOT_FOUND';`;
  8. exports.module = request =>
  9. `!(function webpackMissingModule() { ${exports.moduleCode(request)} }())`;
  10. exports.promise = request => {
  11. const errorCode = toErrorCode(`Cannot find module '${request}'`);
  12. return `Promise.reject(function webpackMissingModule() { ${errorCode} return e; }())`;
  13. };
  14. exports.moduleCode = request => {
  15. const errorCode = toErrorCode(`Cannot find module '${request}'`);
  16. return `${errorCode} throw e;`;
  17. };