UNPKG

@storm-software/unbuild

Version:

A package containing `unbuild` utilities for building Storm Software libraries and applications

36 lines (33 loc) 806 B
import { writeInfo } from "./chunk-WH7FLZNL.js"; import { __name } from "./chunk-3GQAWCBQ.js"; // src/plugins/analyze.ts var formatBytes = /* @__PURE__ */ __name((bytes) => { if (bytes === 0) return "0 Byte"; const k = 1e3; const dm = 3; const sizes = [ "Bytes", "KB", "MB", "GB" ]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; }, "formatBytes"); var analyzePlugin = /* @__PURE__ */ __name((options) => { return { name: "storm:analyzer", renderChunk(source, chunk) { const sourceBytes = formatBytes(source.length); const fileName = chunk.fileName; writeInfo(` - ${fileName} ${sourceBytes}`, options.config); } }; }, "analyzePlugin"); export { analyzePlugin };