@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.
- package/dist/config.d.ts +55 -41
- 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
|
-
*
|
|
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
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
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
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
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
|
-
*
|
|
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?:
|
|
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: {
|
|
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
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* what you are covering; `
|
|
589
|
-
*
|
|
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
|
-
*
|
|
592
|
-
* and no javascript here reads — one consumed by a sibling package, or by css
|
|
593
|
-
* `include`. It is inert under `tokens:
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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 '
|
|
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:
|
|
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.
|
|
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.
|
|
35
|
+
"@bamboocss/extractor": "1.44.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "tsx scripts/watch.ts",
|