github carbon-design-system/carbon-preprocess-svelte v0.15.0

3 hours ago

carbon-preprocess-svelte 0.15.0 prunes one stylesheet for many pages
without reading Carbon again for each one.

Features

  • createCarbonCssPruner(css, options) takes optimizeCarbonCss's
    options but components and safelist,
    and its prune({ components, safelist }) returns what
    optimizeCarbonCss returns for the same options.
    It reads the sheet, content and sources once,
    and after the first prune it reuses what it read of the installed
    Carbon, so a prune of 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.css for 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

  • optimizeCarbonCss bundles svelte-prune 0.16.0,
    which keeps what Carbon's stylesheets define and its sources read
    between calls, and matches a string safelist with one lookup
    per class.
    On the same workload, a warm call takes 205 → 47 ms (a8adda9).

Don't miss a new carbon-preprocess-svelte release

NewReleases is sending notifications on new releases.