MCPcopy
hub / github.com/webpack/webpack / _codeGenerationModule

Method _codeGenerationModule

lib/Compilation.js:4091–4155  ·  view source on GitHub ↗

* Code generation module. * @param {Module} module module * @param {RuntimeSpec} runtime runtime * @param {RuntimeSpec[]} runtimes runtimes * @param {string} hash hash * @param {DependencyTemplates} dependencyTemplates dependencyTemplates * @param {ChunkGraph} chunkGraph chunkGraph * @

(
		module,
		runtime,
		runtimes,
		hash,
		dependencyTemplates,
		chunkGraph,
		moduleGraph,
		runtimeTemplate,
		errors,
		results,
		callback
	)

Source from the content-addressed store, hash-verified

4089 * @param {(err?: WebpackError | null, result?: boolean) => void} callback callback
4090 */
4091 _codeGenerationModule(
4092 module,
4093 runtime,
4094 runtimes,
4095 hash,
4096 dependencyTemplates,
4097 chunkGraph,
4098 moduleGraph,
4099 runtimeTemplate,
4100 errors,
4101 results,
4102 callback
4103 ) {
4104 let codeGenerated = false;
4105 const cache = new MultiItemCache(
4106 runtimes.map((runtime) =>
4107 this._codeGenerationCache.getItemCache(
4108 `${module.identifier()}|${getRuntimeKey(runtime)}`,
4109 `${hash}|${dependencyTemplates.getHash()}`
4110 )
4111 )
4112 );
4113 cache.get((err, cachedResult) => {
4114 if (err) return callback(/** @type {WebpackError} */ (err));
4115 /** @type {CodeGenerationResult} */
4116 let result;
4117 if (!cachedResult) {
4118 try {
4119 codeGenerated = true;
4120 this.codeGeneratedModules.add(module);
4121 result = module.codeGeneration({
4122 chunkGraph,
4123 moduleGraph,
4124 dependencyTemplates,
4125 runtimeTemplate,
4126 runtime,
4127 runtimes,
4128 codeGenerationResults: results,
4129 compilation: this
4130 });
4131 } catch (err) {
4132 errors.push(
4133 new CodeGenerationError(module, /** @type {Error} */ (err))
4134 );
4135 result = cachedResult = {
4136 sources: new Map(),
4137 runtimeRequirements: null,
4138 data: undefined
4139 };
4140 }
4141 } else {
4142 result = cachedResult;
4143 }
4144 for (const runtime of runtimes) {
4145 results.add(module, runtime, result);
4146 }
4147 if (!cachedResult) {
4148 cache.store(result, (err) =>

Callers 2

runIterationMethod · 0.95
codeGenMethod · 0.95

Calls 10

getMethod · 0.95
storeMethod · 0.95
getRuntimeKeyFunction · 0.85
getItemCacheMethod · 0.80
callbackFunction · 0.50
identifierMethod · 0.45
getHashMethod · 0.45
addMethod · 0.45
codeGenerationMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected