(code)
| 311 | * @returns {string | undefined} result |
| 312 | */ |
| 313 | const toCacheVersion = (code) => { |
| 314 | if (code === null) { |
| 315 | return class="st">"null"; |
| 316 | } |
| 317 | if (code === undefined) { |
| 318 | return class="st">"undefined"; |
| 319 | } |
| 320 | if (Object.is(code, -0)) { |
| 321 | return class="st">"-0"; |
| 322 | } |
| 323 | if (code instanceof RuntimeValue) { |
| 324 | return code.getCacheVersion(); |
| 325 | } |
| 326 | if (code instanceof RegExp && code.toString) { |
| 327 | return code.toString(); |
| 328 | } |
| 329 | if (typeof code === class="st">"function" && code.toString) { |
| 330 | return `(${code.toString()})`; |
| 331 | } |
| 332 | if (typeof code === class="st">"object") { |
| 333 | const items = Object.keys(code).map((key) => ({ |
| 334 | key, |
| 335 | value: toCacheVersion( |
| 336 | /** @type {Record<string, CodeValue>} */ |
| 337 | (code)[key] |
| 338 | ) |
| 339 | })); |
| 340 | if (items.some(({ value }) => value === undefined)) return; |
| 341 | return `{${items.map(({ key, value }) => `${key}: ${value}`).join(class="st">", ")}}`; |
| 342 | } |
| 343 | if (typeof code === class="st">"bigint") { |
| 344 | return `${code}n`; |
| 345 | } |
| 346 | return `${code}`; |
| 347 | }; |
| 348 | |
| 349 | const PLUGIN_NAME = class="st">"DefinePlugin"; |
| 350 | const VALUE_DEP_PREFIX = `webpack/${PLUGIN_NAME} `; |
no test coverage detected