MCPcopy
hub / github.com/webpack/webpack / addChunkInGroup

Method addChunkInGroup

lib/Compilation.js:4377–4418  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

iteratorBlockFunction · 0.80

Calls 7

addOriginMethod · 0.95
addChunkMethod · 0.95
pushChunkMethod · 0.95
addGroupMethod · 0.80
getMethod · 0.45
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected