(err, result_)
| 1470 | * @returns {void} |
| 1471 | */ |
| 1472 | const processResult = (err, result_) => { |
| 1473 | if (err) { |
| 1474 | if (!(err instanceof Error)) { |
| 1475 | err = new NonErrorEmittedError(err); |
| 1476 | } |
| 1477 | const currentLoader = this.getCurrentLoader(loaderContext); |
| 1478 | const error = new ModuleBuildError(err, { |
| 1479 | from: |
| 1480 | currentLoader && |
| 1481 | compilation.runtimeTemplate.requestShortener.shorten( |
| 1482 | currentLoader.loader |
| 1483 | ) |
| 1484 | }); |
| 1485 | return callback(error); |
| 1486 | } |
| 1487 | const result = hooks.processResult.call( |
| 1488 | /** @type {Result} */ |
| 1489 | (result_), |
| 1490 | this |
| 1491 | ); |
| 1492 | const source = result[0]; |
| 1493 | const sourceMap = result.length >= 1 ? result[1] : null; |
| 1494 | const extraInfo = result.length >= 2 ? result[2] : null; |
| 1495 | |
| 1496 | if (!Buffer.isBuffer(source) && typeof source !== "string") { |
| 1497 | const currentLoader = this.getCurrentLoader(loaderContext, 0); |
| 1498 | const err = new Error( |
| 1499 | `Final loader (${ |
| 1500 | currentLoader |
| 1501 | ? compilation.runtimeTemplate.requestShortener.shorten( |
| 1502 | currentLoader.loader |
| 1503 | ) |
| 1504 | : "unknown" |
| 1505 | }) didn't return a Buffer or String` |
| 1506 | ); |
| 1507 | const error = new ModuleBuildError(err); |
| 1508 | return callback(error); |
| 1509 | } |
| 1510 | |
| 1511 | const isBinaryModule = |
| 1512 | this.generatorOptions && this.generatorOptions.binary !== undefined |
| 1513 | ? this.generatorOptions.binary |
| 1514 | : this.binary; |
| 1515 | |
| 1516 | this._source = this.createSource( |
| 1517 | options.context, |
| 1518 | isBinaryModule ? asBuffer(source) : asString(source), |
| 1519 | sourceMap, |
| 1520 | compilation.compiler.root |
| 1521 | ); |
| 1522 | if (this._sourceSizes !== undefined) this._sourceSizes.clear(); |
| 1523 | /** @type {PreparsedAst | null} */ |
| 1524 | this._ast = |
| 1525 | typeof extraInfo === "object" && |
| 1526 | extraInfo !== null && |
| 1527 | extraInfo.webpackAST !== undefined |
| 1528 | ? extraInfo.webpackAST |
| 1529 | : null; |
nothing calls this directly
no test coverage detected