MCPcopy
hub / github.com/webpack/webpack / _addEntryItem

Method _addEntryItem

lib/Compilation.js:2704–2774  ·  lib/Compilation.js::Compilation._addEntryItem

* Adds the provided string to the compilation. * @param {string} context context path for entry * @param {Dependency} entry entry dependency that should be followed * @param {"dependencies" | "includeDependencies"} target type of entry * @param {EntryOptions} options options * @param {Modu

(context, entry, target, options, callback)

Source from the content-addressed store, hash-verified

2702 * @returns {void} returns
2703 */
2704 _addEntryItem(context, entry, target, options, callback) {
2705 const { name } = options;
2706 /** @type {EntryData | undefined} */
2707 let entryData =
2708 name !== undefined ? this.entries.get(name) : this.globalEntry;
2709 if (entryData === undefined) {
2710 entryData = {
2711 dependencies: [],
2712 includeDependencies: [],
2713 options: {
2714 name: undefined,
2715 ...options
2716 }
2717 };
2718 entryData[target].push(entry);
2719 this.entries.set(
2720 /** @type {NonNullable<EntryOptions[class="st">"name"]>} */
2721 (name),
2722 entryData
2723 );
2724 } else {
2725 entryData[target].push(entry);
2726 for (const key_ of Object.keys(options)) {
2727 const key = /** @type {keyof EntryOptions} */ (key_);
2728 if (options[key] === undefined) continue;
2729 if (entryData.options[key] === options[key]) continue;
2730 if (
2731 Array.isArray(entryData.options[key]) &&
2732 Array.isArray(options[key]) &&
2733 arrayEquals(entryData.options[key], options[key])
2734 ) {
2735 continue;
2736 }
2737 if (entryData.options[key] === undefined) {
2738 /** @type {EntryOptions[keyof EntryOptions]} */
2739 (entryData.options[key]) = options[key];
2740 } else {
2741 return callback(
2742 new WebpackError(
2743 `Conflicting entry option ${key} = ${entryData.options[key]} vs ${options[key]}`
2744 )
2745 );
2746 }
2747 }
2748 }
2749
2750 this.hooks.addEntry.call(entry, options);
2751
2752 this.addModuleTree(
2753 {
2754 context,
2755 dependency: entry,
2756 contextInfo: entryData.options.layer
2757 ? { issuerLayer: entryData.options.layer }
2758 : undefined
2759 },
2760 (err, module) => {
2761 if (err) {

Callers 2

addEntryMethod · 0.95
addIncludeMethod · 0.95

Calls 8

addModuleTreeMethod · 0.95
isArrayMethod · 0.80
keysMethod · 0.65
callbackFunction · 0.50
getMethod · 0.45
pushMethod · 0.45
setMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected