carbon-preprocess-svelte 0.15.0 prunes one stylesheet for many pages
without reading Carbon again for each one.
Features
-
createCarbonCssPruner(css, options)takesoptimizeCarbonCss's
options butcomponentsandsafelist,
and itsprune({ components, safelist })returns what
optimizeCarbonCssreturns for the same options.
It reads the sheet,contentandsourcesonce,
and after the firstpruneit reuses what it read of the installed
Carbon, so apruneof components an earlier one analyzed reads no
file (#347, a8adda9).const pruner = await createCarbonCssPruner(css, { preserveAllIBMFonts: true }); for (const page of pages) { const { css } = await pruner.prune({ components: page.components, safelist: page.tokens }); }
Pruning Carbon's
all.cssfor 125 pages of 20 components
and 140 safelisted classes each, in one process: 28.3 → 7.0 s of CPU,
and 678 → 515 MB peak.
Performance
optimizeCarbonCssbundles svelte-prune 0.16.0,
which keeps what Carbon's stylesheets define and its sources read
between calls, and matches a stringsafelistwith one lookup
per class.
On the same workload, a warm call takes 205 → 47 ms (a8adda9).