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

one hour ago

carbon-preprocess-svelte 0.14.0 always prunes Carbon's CSS by the props
your app passes, and names the Carbon tokens your CSS reads that
nothing declares.

Changes

  • propAware is removed: CSS is always pruned by the props the app
    passes, as propAware's default already did (b5430cf).
    Its exclude and assume are top-level options now,
    and passing propAware throws:

    carbon-preprocess-svelte: `propAware` was removed in 0.14.0: CSS is always pruned by the props the app passes. Remove it, and use `exclude: ["DataTable"]` for a component that should keep every variant.
    

    Move exclude and assume up a level, and drop propAware: true.
    For propAware: false, drop it, and exclude a component whose
    styles go missing.
    A build that set propAware: false takes about 95 ms longer,
    plus about 5 ms per Carbon stylesheet, as the default already did.

  • The CLI always prunes by the props the --content files pass,
    and takes --exclude (b5430cf).
    --prop-aware exits 2 with what to pass instead.
    For one <Button kind="tertiary">,
    Carbon's white.css goes to 33.0 kB, where 0.13.0 left 67.6 kB;
    --exclude Button gives 64.9 kB.

  • When the analysis can't read the app,
    Carbon's CSS is left unpruned with a warning,
    and the CLI exits 2 and changes no file (b5430cf).
    0.13.0 pruned by the imported components alone.

Features

Undeclared Carbon tokens are named (#313, bbdc956).
The plugins, createCarbonOptimizer,
and optimizeCarbonCss given sources warn after pruning,
with the v11 name for a v10 one:

carbon-preprocess-svelte: CSS reads Carbon tokens that no stylesheet declares, so they resolve to nothing:
  --cds-brand-x
  --cds-ui-01: a v10 name, now --cds-layer-01
v10 names were renamed in carbon-components-svelte 0.114: https://github.com/carbon-design-system/carbon-components-svelte/blob/master/docs/migrations/v0.114.x.md#1-color-tokens

Before, a var() without a fallback that read such a token resolved to
nothing, with no message.

Fixes

  • An app that renders Theme, or only imports it,
    keeps just the Carbon tokens its CSS reads (#315, 5339168, 43c3040).
    Theme sets its tokens inline, so 0.13.0 kept all 406 of
    Carbon's tokens.
    A one-Button app with <Theme bind:theme /> and white.css goes
    from 6.1 kB to 3.6 kB gzipped.

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

NewReleases is sending notifications on new releases.