| 178 | : defaultSizeGetter; |
| 179 | |
| 180 | const getModuleLengths = async ( |
| 181 | { |
| 182 | id, |
| 183 | renderedLength, |
| 184 | code, |
| 185 | }: { |
| 186 | id: string; |
| 187 | renderedLength: number; |
| 188 | code: string | null; |
| 189 | }, |
| 190 | useRenderedLength: boolean = false, |
| 191 | ): Promise<ModuleLengths & { id: string }> => { |
| 192 | const isCodeEmpty = code == null || code == ""; |
| 193 | |
| 194 | const result = { |
| 195 | id, |
| 196 | gzipLength: isCodeEmpty ? 0 : await gzipSizeGetter(code), |
| 197 | brotliLength: isCodeEmpty ? 0 : await brotliSizeGetter(code), |
| 198 | renderedLength: useRenderedLength |
| 199 | ? renderedLength |
| 200 | : isCodeEmpty |
| 201 | ? 0 |
| 202 | : Buffer.byteLength(code, "utf-8"), |
| 203 | }; |
| 204 | return result; |
| 205 | }; |
| 206 | |
| 207 | if (opts.sourcemap && !outputOptions.sourcemap) { |
| 208 | this.warn(WARN_SOURCEMAP_DISABLED); |