MCPcopy
hub / github.com/webpack/webpack / setTarget

Method setTarget

lib/ExportsInfo.js:1401–1437  ·  view source on GitHub ↗

* Updates target using the provided key. * @param {Dependency} key the key * @param {ModuleGraphConnection} connection the target module if a single one * @param {ExportInfoName[] | null=} exportName the exported name * @param {number=} priority priority * @returns {boolean} true, if somet

(key, connection, exportName, priority = 0)

Source from the content-addressed store, hash-verified

1399 * @returns {boolean} true, if something has changed
1400 */
1401 setTarget(key, connection, exportName, priority = 0) {
1402 if (exportName) exportName = [...exportName];
1403 if (!this._target) {
1404 this._target = /** @type {Target} */ (new Map());
1405 this._target.set(key, {
1406 connection,
1407 export: /** @type {ExportInfoName[]} */ (exportName),
1408 priority
1409 });
1410 return true;
1411 }
1412 const oldTarget = this._target.get(key);
1413 if (!oldTarget) {
1414 if (oldTarget === null && !connection) return false;
1415 this._target.set(key, {
1416 connection,
1417 export: /** @type {ExportInfoName[]} */ (exportName),
1418 priority
1419 });
1420 this._maxTarget = undefined;
1421 return true;
1422 }
1423 if (
1424 oldTarget.connection !== connection ||
1425 oldTarget.priority !== priority ||
1426 (exportName
1427 ? !oldTarget.export || !equals(oldTarget.export, exportName)
1428 : oldTarget.export)
1429 ) {
1430 oldTarget.connection = connection;
1431 oldTarget.export = /** @type {ExportInfoName[]} */ (exportName);
1432 oldTarget.priority = priority;
1433 this._maxTarget = undefined;
1434 return true;
1435 }
1436 return false;
1437 }
1438
1439 /**
1440 * Returns usage state.

Callers 2

mergeExportsMethod · 0.80

Calls 2

setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected