MCPcopy
hub / github.com/webpack/webpack / toInlinedValue

Function toInlinedValue

lib/optimize/InlineExports.js:108–125  ·  view source on GitHub ↗
(evaluated)

Source from the content-addressed store, hash-verified

106 * @returns {InlinedValue | undefined} inlined value or undefined
107 */
108const toInlinedValue = (evaluated) => {
109 if (!evaluated) return;
110 if (evaluated.isNull()) return new InlinedValue("null", null);
111 if (evaluated.isUndefined()) return new InlinedValue("undefined", undefined);
112 if (evaluated.isBoolean()) {
113 return new InlinedValue("boolean", /** @type {boolean} */ (evaluated.bool));
114 }
115 if (evaluated.isNumber()) {
116 const num = /** @type {number} */ (evaluated.number);
117 if (String(num).length > MAX_INLINE_BYTES) return;
118 return new InlinedValue("number", num);
119 }
120 if (evaluated.isString()) {
121 const str = /** @type {string} */ (evaluated.string);
122 if (str.length > MAX_INLINE_BYTES) return;
123 return new InlinedValue("string", str);
124 }
125};
126
127/** @type {WeakSet<ModuleGraph>} */
128const inlineEnabledModuleGraphs = new WeakSet();

Callers 2

handleConstValueMethod · 0.85
applyMethod · 0.85

Calls 5

isNullMethod · 0.80
isUndefinedMethod · 0.80
isBooleanMethod · 0.80
isNumberMethod · 0.80
isStringMethod · 0.80

Tested by

no test coverage detected