(key, value)
| 496 | }; |
| 497 | |
| 498 | const replaceStringifyValues = (key, value) => { |
| 499 | switch (value?.type) { |
| 500 | case 'ImportDeclaration': |
| 501 | case 'ExportNamedDeclaration': |
| 502 | case 'ExportAllDeclaration': { |
| 503 | const { attributes, ...nonAttributesProperties } = value; |
| 504 | return { |
| 505 | ...nonAttributesProperties, |
| 506 | ...(attributes?.length > 0 ? { assertions: attributes } : {}) |
| 507 | }; |
| 508 | } |
| 509 | case 'ImportExpression': { |
| 510 | const { options, ...nonOptionsProperties } = value; |
| 511 | return { ...nonOptionsProperties, ...(options ? { arguments: [options] } : {}) }; |
| 512 | } |
| 513 | case 'ClassDeclaration': |
| 514 | case 'ClassExpression': |
| 515 | case 'PropertyDefinition': |
| 516 | case 'MethodDefinition': { |
| 517 | const { decorators, ...rest } = value; |
| 518 | return rest; |
| 519 | } |
| 520 | case 'JSXText': { |
| 521 | // raw text is encoded differently in acorn |
| 522 | const { raw, ...nonRawProperties } = value; |
| 523 | return nonRawProperties; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | return key[0] === '_' |
| 528 | ? undefined |
| 529 | : typeof value == 'bigint' |
| 530 | ? `~BigInt${value.toString()}` |
| 531 | : value instanceof RegExp |
| 532 | ? `~RegExp${JSON.stringify({ flags: value.flags, source: value.source })}` |
| 533 | : value; |
| 534 | }; |
| 535 | |
| 536 | const reviveStringifyValues = (_, value) => |
| 537 | typeof value === 'string' |
nothing calls this directly
no test coverage detected
searching dependent graphs…