const require_omit = require('./src/utils/omit.cjs'); const require_check_exclude_filepath = require('./src/utils/check-exclude-filepath.cjs'); //#region src/extract.ts /** * Extract bundler stats * * Shallow clone stats object before any processing using `omit` to * 1. resolve getters * 2. prevent changes to the stats object * * @NOTE structuredClone is not supported by rolldown-vite: https://github.com/vitejs/rolldown-vite/issues/128 */ function extractRollupStats(bundle, options = {}) { const { source = false, map = false, excludeAssets, excludeModules } = options; const output = {}; Object.entries(bundle).forEach(([bundleEntryFilepath, bundleEntryStats]) => { if (require_check_exclude_filepath.checkExcludeFilepath(bundleEntryFilepath, excludeAssets)) return; if (bundleEntryStats.type === "asset") { const assetStatsOmitKeys = []; if (!source) assetStatsOmitKeys.push("source"); output[bundleEntryFilepath] = require_omit.omit(bundleEntryStats, assetStatsOmitKeys); return; } if (bundleEntryStats.type === "chunk") { const chunkStatsOmitKeys = []; if (!source) chunkStatsOmitKeys.push("code"); if (!map) chunkStatsOmitKeys.push("map"); const chunkStats = require_omit.omit(bundleEntryStats, chunkStatsOmitKeys); const chunkModulesStats = {}; Object.entries(chunkStats.modules).forEach(([bundleModuleFilepath, bundleModuleStats]) => { if (require_check_exclude_filepath.checkExcludeFilepath(bundleModuleFilepath, excludeModules)) return; const moduleStatsOmitKeys = []; if (!source) moduleStatsOmitKeys.push("code"); chunkModulesStats[bundleModuleFilepath] = require_omit.omit(bundleModuleStats, moduleStatsOmitKeys); }); chunkStats.modules = chunkModulesStats; output[bundleEntryFilepath] = chunkStats; return; } }); return output; } //#endregion module.exports = extractRollupStats; //# sourceMappingURL=extract.cjs.map