MCPcopy
hub / github.com/webpack/webpack / runAsChild

Method runAsChild

lib/Compiler.js:691–740  ·  view source on GitHub ↗

* Processes the provided run as child callback. * @param {RunAsChildCallback} callback signals when the call finishes * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

689 * @returns {void}
690 */
691 runAsChild(callback) {
692 const startTime = Date.now();
693
694 /**
695 * Processes the provided err.
696 * @param {Error | null} err error
697 * @param {Chunk[]=} entries entries
698 * @param {Compilation=} compilation compilation
699 */
700 const finalCallback = (err, entries, compilation) => {
701 try {
702 callback(err, entries, compilation);
703 } catch (runAsChildErr) {
704 const err = new WebpackError(
705 `compiler.runAsChild callback error: ${runAsChildErr}`,
706 { cause: runAsChildErr }
707 );
708 err.details = /** @type {Error} */ (runAsChildErr).stack;
709 /** @type {Compilation} */
710 (this.parentCompilation).errors.push(err);
711 }
712 };
713
714 this.compile((err, _compilation) => {
715 if (err) return finalCallback(err);
716
717 const compilation = /** @type {Compilation} */ (_compilation);
718 const parentCompilation = /** @type {Compilation} */ (
719 this.parentCompilation
720 );
721
722 parentCompilation.children.push(compilation);
723
724 for (const { name, source, info } of compilation.getAssets()) {
725 parentCompilation.emitAsset(name, source, info);
726 }
727
728 /** @type {Chunk[]} */
729 const entries = [];
730
731 for (const ep of compilation.entrypoints.values()) {
732 entries.push(...ep.chunks);
733 }
734
735 compilation.startTime = startTime;
736 compilation.endTime = Date.now();
737
738 return finalCallback(null, entries, compilation);
739 });
740 }
741
742 purgeInputFileSystem() {
743 if (this.inputFileSystem && this.inputFileSystem.purge) {

Callers 7

loader.jsFile · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 5

compileMethod · 0.95
getAssetsMethod · 0.80
emitAssetMethod · 0.80
pushMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected