MCPcopy
hub / github.com/webpack/webpack / getEvaluatedExpr

Function getEvaluatedExpr

lib/url/URLParserPlugin.js:68–93  ·  view source on GitHub ↗
(expr, parser)

Source from the content-addressed store, hash-verified

66 * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
67 */
68const getEvaluatedExpr = (expr, parser) => {
69 let result = getEvaluatedExprCache.get(expr);
70 if (result !== undefined) return result;
71
72 /**
73 * Returns basic evaluated expression.
74 * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
75 */
76 const evaluate = () => {
77 if (expr.arguments.length !== 2) return;
78
79 const [arg1, arg2] = expr.arguments;
80
81 if (arg2.type !== "MemberExpression" || arg1.type === "SpreadElement") {
82 return;
83 }
84 if (!isMetaUrl(parser, arg2)) return;
85
86 return parser.evaluateExpression(arg1);
87 };
88
89 result = evaluate();
90 getEvaluatedExprCache.set(expr, result);
91
92 return result;
93};
94
95class URLParserPlugin {
96 /**

Callers 1

applyMethod · 0.85

Calls 3

evaluateFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected