* Returns the estimated size for the requested source type. * @param {NormalModule} module the module * @param {SourceType=} type source type * @returns {number} estimate size of the module
(module, type)
| 689 | * @returns {number} estimate size of the module |
| 690 | */ |
| 691 | getSize(module, type) { |
| 692 | switch (type) { |
| 693 | case JAVASCRIPT_TYPE: { |
| 694 | const cssData = /** @type {CssModuleBuildInfo} */ (module.buildInfo) |
| 695 | .cssData; |
| 696 | if (!cssData) { |
| 697 | return 42; |
| 698 | } |
| 699 | if (cssData.exports.size === 0) { |
| 700 | if ( |
| 701 | /** @type {CssModuleBuildMeta} */ (module.buildMeta).isCssModule |
| 702 | ) { |
| 703 | return 42; |
| 704 | } |
| 705 | return 0; |
| 706 | } |
| 707 | const exports = cssData.exports; |
| 708 | /** @type {Record<string, string>} */ |
| 709 | const exportsObj = {}; |
| 710 | for (const [key, value] of exports) { |
| 711 | exportsObj[key] = value; |
| 712 | } |
| 713 | const stringifiedExports = JSON.stringify(exportsObj); |
| 714 | |
| 715 | return stringifiedExports.length + 42; |
| 716 | } |
| 717 | case CSS_TEXT_TYPE: |
| 718 | case CSS_TYPE: { |
| 719 | const originalSource = module.originalSource(); |
| 720 | |
| 721 | if (!originalSource) { |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | return originalSource.size(); |
| 726 | } |
| 727 | default: |
| 728 | return 0; |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | /** |
| 733 | * Updates the hash with the data contributed by this instance. |
nothing calls this directly
no test coverage detected