MCPcopy
hub / github.com/webpack/webpack / getSourceForEmptyAsyncContext

Method getSourceForEmptyAsyncContext

lib/ContextModule.js:1265–1279  ·  view source on GitHub ↗

* @param {ModuleId} id module id * @param {RuntimeTemplate} runtimeTemplate runtime template * @returns {string} source for empty async context

(id, runtimeTemplate)

Source from the content-addressed store, hash-verified

1263 * @returns {string} source for empty async context
1264 */
1265 getSourceForEmptyAsyncContext(id, runtimeTemplate) {
1266 return `function webpackEmptyAsyncContext(req) {
1267 // Here Promise.resolve().then() is used instead of new Promise() to prevent
1268 // uncaught exception popping up in devtools
1269 return Promise.resolve().then(${runtimeTemplate.basicFunction("", [
1270 `${runtimeTemplate.renderConst()} e = new Error("Cannot find module '" + req + "'");`,
1271 "e.code = 'MODULE_NOT_FOUND';",
1272 "throw e;"
1273 ])});
1274}
1275webpackEmptyAsyncContext.keys = ${runtimeTemplate.returningFunction("[]")};
1276webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
1277webpackEmptyAsyncContext.id = ${JSON.stringify(id)};
1278module.exports = webpackEmptyAsyncContext;`;
1279 }
1280
1281 /**
1282 * @param {string} asyncMode module mode

Callers 1

getSourceStringMethod · 0.95

Calls 3

basicFunctionMethod · 0.80
renderConstMethod · 0.80
returningFunctionMethod · 0.80

Tested by

no test coverage detected