* If `module` is passed, `loc` and `request` must also be passed. * @param {string | ChunkGroupOptions} groupOptions options for the chunk group * @param {Module=} module the module the references the chunk group * @param {DependencyLocation=} loc the location from with the chunk group is refe
(groupOptions, module, loc, request)
| 4375 | * @returns {ChunkGroup} the new or existing chunk group |
| 4376 | */ |
| 4377 | addChunkInGroup(groupOptions, module, loc, request) { |
| 4378 | if (typeof groupOptions === "string") { |
| 4379 | groupOptions = { name: groupOptions }; |
| 4380 | } |
| 4381 | const name = groupOptions.name; |
| 4382 | if (name) { |
| 4383 | const chunkGroup = this.namedChunkGroups.get(name); |
| 4384 | if (chunkGroup !== undefined) { |
| 4385 | if (module) { |
| 4386 | chunkGroup.addOrigin( |
| 4387 | module, |
| 4388 | /** @type {DependencyLocation} */ |
| 4389 | (loc), |
| 4390 | /** @type {string} */ |
| 4391 | (request) |
| 4392 | ); |
| 4393 | } |
| 4394 | return chunkGroup; |
| 4395 | } |
| 4396 | } |
| 4397 | const chunkGroup = new ChunkGroup(groupOptions); |
| 4398 | if (module) { |
| 4399 | chunkGroup.addOrigin( |
| 4400 | module, |
| 4401 | /** @type {DependencyLocation} */ |
| 4402 | (loc), |
| 4403 | /** @type {string} */ |
| 4404 | (request) |
| 4405 | ); |
| 4406 | } |
| 4407 | const chunk = this.addChunk(name); |
| 4408 | |
| 4409 | if (chunkGroup.pushChunk(chunk)) { |
| 4410 | chunk.addGroup(chunkGroup); |
| 4411 | } |
| 4412 | |
| 4413 | this.chunkGroups.push(chunkGroup); |
| 4414 | if (name) { |
| 4415 | this.namedChunkGroups.set(name, chunkGroup); |
| 4416 | } |
| 4417 | return chunkGroup; |
| 4418 | } |
| 4419 | |
| 4420 | /** |
| 4421 | * Adds the provided async entrypoint to this chunk group. |