MCPcopy Create free account
hub / github.com/btd/rollup-plugin-visualizer / getModuleLengths

Function getModuleLengths

plugin/index.ts:180–205  ·  view source on GitHub ↗
(
        {
          id,
          renderedLength,
          code,
        }: {
          id: string;
          renderedLength: number;
          code: string | null;
        },
        useRenderedLength: boolean = false,
      )

Source from the content-addressed store, hash-verified

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);

Callers 1

generateBundleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected