MCPcopy
hub / github.com/webpack/webpack / transformToCode

Function transformToCode

lib/DefinePlugin.js:254–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

252 objKeys
253) => {
254 const transformToCode = () => {
255 if (code === null) {
256 return "null";
257 }
258 if (code === undefined) {
259 return "undefined";
260 }
261 if (Object.is(code, -0)) {
262 return "-0";
263 }
264 if (code instanceof RuntimeValue) {
265 return toCode(
266 code.exec(parser, valueCacheVersions, key),
267 parser,
268 valueCacheVersions,
269 key,
270 runtimeTemplate,
271 logger,
272 asiSafe
273 );
274 }
275 if (code instanceof RegExp && code.toString) {
276 return code.toString();
277 }
278 if (typeof code === "function" && code.toString) {
279 return `(${code.toString()})`;
280 }
281 if (typeof code === "object") {
282 return stringifyObj(
283 code,
284 parser,
285 valueCacheVersions,
286 key,
287 runtimeTemplate,
288 logger,
289 asiSafe,
290 objKeys
291 );
292 }
293 if (typeof code === "bigint") {
294 return runtimeTemplate.supportsBigIntLiteral()
295 ? `${code}n`
296 : `BigInt("${code}")`;
297 }
298 return `${code}`;
299 };
300
301 const strCode = transformToCode();
302

Callers 1

toCodeFunction · 0.85

Calls 5

toCodeFunction · 0.85
stringifyObjFunction · 0.85
execMethod · 0.80
supportsBigIntLiteralMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected