MCPcopy
hub / github.com/webpack/webpack / tagTopLevelSymbol

Function tagTopLevelSymbol

lib/optimize/InnerGraph.js:313–337  ·  view source on GitHub ↗

* @param {JavascriptParser} parser parser * @param {string} name name of variable * @param {PureCondition=} pure pure condition * @returns {TopLevelSymbol=} symbol

(parser, name, pure)

Source from the content-addressed store, hash-verified

311 * @returns {TopLevelSymbol=} symbol
312 */
313 function tagTopLevelSymbol(parser, name, pure) {
314 const innerGraphState = getState(parser.state);
315 if (!innerGraphState) return;
316
317 parser.defineVariable(name);
318
319 const existingTag = /** @type {TopLevelSymbol} */ (
320 parser.getTagData(name, topLevelSymbolTag)
321 );
322 if (existingTag) {
323 if (pure !== undefined) {
324 existingTag.setPure(pure);
325 }
326 return existingTag;
327 }
328
329 const symbol = new TopLevelSymbol(name, pure);
330 parser.tagVariable(
331 name,
332 topLevelSymbolTag,
333 symbol,
334 JavascriptParser.VariableInfoFlags.Normal
335 );
336 return symbol;
337 }
338
339 /**
340 * @param {Module} module module

Callers 1

addVariableUsageFunction · 0.85

Calls 5

defineVariableMethod · 0.80
getTagDataMethod · 0.80
setPureMethod · 0.80
tagVariableMethod · 0.80
getStateFunction · 0.70

Tested by

no test coverage detected