* Generates code and runtime requirements for this module. * @param {Callback} callback callback
(callback)
| 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. |
no test coverage detected