* Processes the provided module. * @param {NormalModule} module the current module * @param {Dependency} dependency the dependency to generate * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments * @param {ReplaceSource} source the current replace source wh
(module, dependency, initFragments, source, generateContext)
| 246 | * @returns {void} |
| 247 | */ |
| 248 | sourceDependency(module, dependency, initFragments, source, generateContext) { |
| 249 | const constructor = |
| 250 | /** @type {DependencyConstructor} */ |
| 251 | (dependency.constructor); |
| 252 | const template = generateContext.dependencyTemplates.get(constructor); |
| 253 | if (!template) { |
| 254 | throw new Error( |
| 255 | `No template for dependency: ${dependency.constructor.name}` |
| 256 | ); |
| 257 | } |
| 258 | |
| 259 | /** @type {DependencyTemplateContext} */ |
| 260 | /** @type {InitFragment<GenerateContext>[] | undefined} */ |
| 261 | let chunkInitFragments; |
| 262 | /** @type {DependencyTemplateContext} */ |
| 263 | const templateContext = { |
| 264 | runtimeTemplate: generateContext.runtimeTemplate, |
| 265 | dependencyTemplates: generateContext.dependencyTemplates, |
| 266 | moduleGraph: generateContext.moduleGraph, |
| 267 | chunkGraph: generateContext.chunkGraph, |
| 268 | module, |
| 269 | runtime: generateContext.runtime, |
| 270 | runtimeRequirements: generateContext.runtimeRequirements, |
| 271 | concatenationScope: generateContext.concatenationScope, |
| 272 | codeGenerationResults: |
| 273 | /** @type {CodeGenerationResults} */ |
| 274 | (generateContext.codeGenerationResults), |
| 275 | initFragments, |
| 276 | get chunkInitFragments() { |
| 277 | if (!chunkInitFragments) { |
| 278 | const data = |
| 279 | /** @type {NonNullable<GenerateContext["getData"]>} */ |
| 280 | (generateContext.getData)(); |
| 281 | chunkInitFragments = data.get("chunkInitFragments"); |
| 282 | if (!chunkInitFragments) { |
| 283 | chunkInitFragments = []; |
| 284 | data.set("chunkInitFragments", chunkInitFragments); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return chunkInitFragments; |
| 289 | } |
| 290 | }; |
| 291 | |
| 292 | template.apply(dependency, source, templateContext); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Processes the provided dependencies block. |
no test coverage detected