MCPcopy
hub / github.com/webpack/webpack / codeGeneration

Method codeGeneration

lib/Compilation.js:3933–3965  ·  view source on GitHub ↗

* Generates code and runtime requirements for this module. * @param {Callback} callback callback

(callback)

Source from the content-addressed store, hash-verified

3931 * @param {Callback} callback callback
3932 */
3933 codeGeneration(callback) {
3934 const { chunkGraph } = this;
3935 this.codeGenerationResults = new CodeGenerationResults(
3936 this.outputOptions.hashFunction
3937 );
3938 /** @type {CodeGenerationJobs} */
3939 const jobs = [];
3940 for (const module of this.modules) {
3941 const runtimes = chunkGraph.getModuleRuntimes(module);
3942 if (runtimes.size === 1) {
3943 for (const runtime of runtimes) {
3944 const hash = chunkGraph.getModuleHash(module, runtime);
3945 jobs.push({ module, hash, runtime, runtimes: [runtime] });
3946 }
3947 } else if (runtimes.size > 1) {
3948 /** @type {Map<string, { runtimes: RuntimeSpec[] }>} */
3949 const map = new Map();
3950 for (const runtime of runtimes) {
3951 const hash = chunkGraph.getModuleHash(module, runtime);
3952 const job = map.get(hash);
3953 if (job === undefined) {
3954 const newJob = { module, hash, runtime, runtimes: [runtime] };
3955 jobs.push(newJob);
3956 map.set(hash, newJob);
3957 } else {
3958 job.runtimes.push(runtime);
3959 }
3960 }
3961 }
3962 }
3963
3964 this._runCodeGenerationJobs(jobs, callback);
3965 }
3966
3967 /**
3968 * Run code generation jobs.

Callers 2

sealMethod · 0.95
_codeGenerationModuleMethod · 0.45

Calls 6

getModuleRuntimesMethod · 0.80
getModuleHashMethod · 0.45
pushMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected