@bamboocss/types 1.43.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/config.d.ts +55 -41
  2. package/package.json +2 -2
package/dist/config.d.ts CHANGED
@@ -523,27 +523,20 @@ export interface PluginsOptions {
523
523
  */
524
524
  export interface PruneOptions {
525
525
  /**
526
- * How to decide which token css variables to keep.
526
+ * Whether to drop token css variables nothing asks for.
527
527
  *
528
528
  * The token layer declares every token in the theme, and an app typically uses a small
529
529
  * fraction of them, so this is usually the largest single saving in render-blocking css.
530
530
  *
531
- * - `off` keeps every token declaration.
532
- * - `reachable` keeps what the generated css reaches. Because `token()` can name any
533
- * token, a project that calls it from javascript *anywhere* keeps every declaration
534
- * on the default preset that is 468 names against the 68 a narrower exemption kept, and
535
- * a token layer of 442 declarations rather than 2. The exemption is skipped entirely for
536
- * a project that never reaches for a token from javascript, so the saving is
537
- * all-or-nothing: one caller keeps every declaration.
538
- * - `accounted` reads the token paths out of your source and keeps only those. `token()`
539
- * and `token.value()` calls are resolved through a constant or a template literal the
540
- * extractor can follow, not only through a path spelled at the call, as is any literal
541
- * `var(--x)` written by hand.
542
- *
543
- * Under `accounted`, a path the build cannot follow makes the keep set fall back to
544
- * `reachable`'s blanket keep rather than silently dropping a declaration — which is why
545
- * `unresolvedPath` exists, and why setting it to `error` is what makes `accounted` worth
546
- * asking for: it guarantees you are shipping the exact set rather than the fallback.
531
+ * A variable is kept when the generated css references it, when a kept variable's own value
532
+ * references it, or when javascript under `include` names it — a `token()` or `token.value()`
533
+ * call, or a literal `var(--x)` written by hand. Paths are read through a constant or a
534
+ * template literal the extractor can follow, not only from a literal spelled at the call.
535
+ *
536
+ * A path the build cannot follow falls back to keeping every declaration rather than
537
+ * silently dropping one, because `token()` hands back a `var()` for every token and an
538
+ * unreadable path could name any of them. `unresolvedPath` decides whether that fallback is
539
+ * reported, and `keepTokens` replaces it with a bound you declare.
547
540
  *
548
541
  * A template literal is bounded rather than declined: `` token(`colors.${shade}`) `` cannot
549
542
  * say which token it wants, but it says which it *cannot*, so the `colors` category is kept
@@ -551,26 +544,39 @@ export interface PruneOptions {
551
544
  * is a path with no static head — `token(key)`, `token('colors.' + shade)` — and there
552
545
  * `keepTokens` is the answer.
553
546
  *
554
- * Three things stay invisible to `accounted`: a token named by a path assembled from a
555
- * value that only exists at runtime, one referenced only from a stylesheet outside
556
- * `include`, and one used by a separate package consuming the output as design tokens. The
557
- * scan reads `include`, which scopes style extraction rather than everything that may
558
- * import — so a script, a config, or a sibling workspace package that calls `token()` is
559
- * not covered, nor is a binding renamed away from `token`, as in `const t = token`. Name
560
- * them with `keepTokens`.
547
+ * A local binding named `token` is not the artifact and is not a reference: `token` is the
548
+ * obvious name for a token *object*, and `items.map((token) => token.value)` reads a
549
+ * parameter. Parameters, catch variables, function and class declarations, and a variable
550
+ * destructured off one of those are all resolved rather than matched by spelling.
551
+ *
552
+ * Three things stay invisible: a token named by a path assembled from a value that only
553
+ * exists at runtime, one referenced only from a stylesheet outside `include`, and one used
554
+ * by a separate package consuming the output as design tokens. The scan reads `include`,
555
+ * which scopes style extraction rather than everything that may import — so a script, a
556
+ * config, or a sibling workspace package that calls `token()` is not covered, nor is a
557
+ * binding renamed away from `token`, as in `const t = token`. Name them with `keepTokens`.
561
558
  *
562
559
  * A custom property declared by `global.css` or `global.vars` is not one of these cases:
563
560
  * the declaration ships whether or not anything in the stylesheet reads it, so whatever it
564
561
  * references is kept alongside it.
565
562
  *
566
- * @default 'reachable'
563
+ * This was three strategies — `'off' | 'reachable' | 'accounted'` — which conflated two
564
+ * separate questions: how hard to try, and what to say when it fails. `'reachable'` answered
565
+ * one cheap boolean ("does any javascript reach for a token") and threw away everything else
566
+ * it had read, so a single `token()` call anywhere kept all 468 declarations of the default
567
+ * preset. `'accounted'` did the work but was framed as an assertion, so it reported by
568
+ * default and had to be asked for. Doing the work is now the default and saying so is
569
+ * `unresolvedPath`; a file that never spells `token` is skipped, so the accounting costs
570
+ * nothing where there is nothing to account for.
571
+ *
572
+ * @default true
567
573
  */
568
- tokens?: 'off' | 'reachable' | 'accounted'
574
+ tokens?: boolean
569
575
  /**
570
576
  * Token paths to keep whatever the build can see, as exact names or `*` patterns.
571
577
  *
572
578
  * ```ts
573
- * prune: { tokens: 'accounted', keepTokens: ['colors.*'] }
579
+ * prune: { keepTokens: ['colors.*'] }
574
580
  * ```
575
581
  *
576
582
  * This is the bound the build could not infer, written by hand. It exists because the
@@ -581,16 +587,16 @@ export interface PruneOptions {
581
587
  * far smaller answer than keeping everything, and it is the same answer the build already
582
588
  * derives for itself from a template literal's static head.
583
589
  *
584
- * So under `accounted` this does two things: it keeps what it matches, and it stands in for
585
- * what could not be followed, in place of the blanket keep. Saying `keepTokens: ['colors.*']`
586
- * is saying *the reads you cannot follow land in `colors`* — an assertion about your own
587
- * code, which is why nothing infers it for you. Declines are still reported, so you can see
588
- * what you are covering; `unresolvedPath: 'error'` still fails, because asserting every path
589
- * resolves and declaring a bound for the ones that do not are contradictory requests.
590
+ * So this does two things: it keeps what it matches, and it stands in for what could not be
591
+ * followed, in place of the blanket keep. Saying `keepTokens: ['colors.*']` is saying *the
592
+ * reads you cannot follow land in `colors`* — an assertion about your own code, which is why
593
+ * nothing infers it for you. Under `unresolvedPath: 'warn'` the declines are still printed, so
594
+ * you can see what you are covering; `'error'` fails, because asserting every path resolves and
595
+ * declaring a bound for the ones that do not are contradictory requests.
590
596
  *
591
- * Under `reachable` it is additive only, for a token nothing in the stylesheet references
592
- * and no javascript here reads — one consumed by a sibling package, or by css outside
593
- * `include`. It is inert under `tokens: 'off'`, which keeps everything already.
597
+ * With nothing to stand in for it is additive only, naming a token nothing in the stylesheet
598
+ * references and no javascript here reads — one consumed by a sibling package, or by css
599
+ * outside `include`. It is inert under `tokens: false`, which keeps everything already.
594
600
  *
595
601
  * Patterns match the dotted token *path*, anchored and case-sensitively, with `*` standing
596
602
  * for any run of characters and a leading `!` excluding. `colors.*` keeps every colour,
@@ -609,17 +615,25 @@ export interface PruneOptions {
609
615
  */
610
616
  keepTokens?: string[]
611
617
  /**
612
- * What to do about a token path `accounted` cannot follow.
618
+ * What to do about a token path the build cannot follow.
613
619
  *
614
620
  * A path spelled at the call resolves; one assembled at runtime does not. An unfollowable
615
- * path is what forces `accounted` back onto the blanket keep — unless `keepTokens` names
621
+ * path is what forces the keep set back onto every declaration — unless `keepTokens` names
616
622
  * the bound — so this decides whether that happens quietly, loudly, or not at all.
617
623
  *
618
624
  * - `off` falls back and says nothing.
619
625
  * - `warn` falls back and reports what it could not follow.
620
626
  * - `error` fails the build, so the fallback can never ship unnoticed.
621
627
  *
622
- * Inert under `tokens: 'off'` and `tokens: 'reachable'`, which run no accounting pass.
628
+ * The keeps are identical across all three: this decides how loudly, and nothing else.
629
+ *
630
+ * It defaults to `off` because pruning is an inference the build makes on its own rather
631
+ * than a claim you asked it to check, and a default that reports has to be right about
632
+ * every project or it is just noise. Reach for `warn` when the token layer is larger than
633
+ * you expect — it names what is holding the keep set open — and `error` to assert that it
634
+ * never falls back at all.
635
+ *
636
+ * Inert under `tokens: false`, which keeps everything and runs no accounting pass.
623
637
  *
624
638
  * `error` and `keepTokens` do not combine: one asserts every path resolves, the other
625
639
  * declares where the ones that do not will land. A project that cannot make the first
@@ -629,7 +643,7 @@ export interface PruneOptions {
629
643
  * here: `strictTokens` and `strictPropertyValues` narrow generated *typescript*, and
630
644
  * neither implies nor is implied by this.
631
645
  *
632
- * @default 'warn'
646
+ * @default 'off'
633
647
  */
634
648
  unresolvedPath?: 'off' | 'warn' | 'error'
635
649
  /**
@@ -669,7 +683,7 @@ export interface PruneOptions {
669
683
  * property can be reached from outside the css entirely — a `token()` call, a `keepTokens`
670
684
  * pattern, a theme, a `globalCss` export. Those are exactly the tokens `tokens` keeps, so
671
685
  * this defers to that pass rather than asking again: a keyframe is dropped only when the
672
- * declarations naming it were dropped too. Under `tokens: 'off'` nothing is removable, so
686
+ * declarations naming it were dropped too. Under `tokens: false` nothing is removable, so
673
687
  * every keyframe a declaration names is kept.
674
688
  *
675
689
  * @default true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/types",
3
- "version": "1.43.0",
3
+ "version": "1.44.0",
4
4
  "description": "The types for css bamboo",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "ncp": "2.0.0",
33
33
  "pkg-types": "2.3.0",
34
34
  "ts-morph": "28.0.0",
35
- "@bamboocss/extractor": "1.43.0"
35
+ "@bamboocss/extractor": "1.44.0"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "tsx scripts/watch.ts",