@pithyjs/vite-plugin 0.1.0-beta.0 → 0.2.0-beta.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/README.md +57 -8
- package/dist/aotCodegen/generateBindings.d.ts +9 -2
- package/dist/aotCodegen/generateBindings.d.ts.map +1 -1
- package/dist/aotCodegen/generateBindings.js +22 -7
- package/dist/aotCodegen/generateBindings.js.map +1 -1
- package/dist/aotCodegen/generateDomFactory.d.ts +7 -2
- package/dist/aotCodegen/generateDomFactory.d.ts.map +1 -1
- package/dist/aotCodegen/generateDomFactory.js +74 -13
- package/dist/aotCodegen/generateDomFactory.js.map +1 -1
- package/dist/aotCodegen/index.d.ts +1 -1
- package/dist/aotCodegen/index.d.ts.map +1 -1
- package/dist/aotCodegen/serializeNode.d.ts.map +1 -1
- package/dist/aotCodegen/serializeNode.js +11 -0
- package/dist/aotCodegen/serializeNode.js.map +1 -1
- package/dist/babelPlugin/babelPlugin.d.ts +4 -3
- package/dist/babelPlugin/babelPlugin.d.ts.map +1 -1
- package/dist/babelPlugin/babelPlugin.js +257 -143
- package/dist/babelPlugin/babelPlugin.js.map +1 -1
- package/dist/babelPlugin/extractUsedIdentifiers.d.ts.map +1 -1
- package/dist/babelPlugin/extractUsedIdentifiers.js +62 -6
- package/dist/babelPlugin/extractUsedIdentifiers.js.map +1 -1
- package/dist/buildPlugin/plugin.d.ts +0 -25
- package/dist/buildPlugin/plugin.d.ts.map +1 -1
- package/dist/buildPlugin/plugin.js +41 -3
- package/dist/buildPlugin/plugin.js.map +1 -1
- package/dist/designSystemPlugin/channelVars.d.ts +139 -0
- package/dist/designSystemPlugin/channelVars.d.ts.map +1 -0
- package/dist/designSystemPlugin/channelVars.js +1099 -0
- package/dist/designSystemPlugin/channelVars.js.map +1 -0
- package/dist/designSystemPlugin/cssTokens.d.ts +24 -3
- package/dist/designSystemPlugin/cssTokens.d.ts.map +1 -1
- package/dist/designSystemPlugin/cssTokens.js.map +1 -1
- package/dist/designSystemPlugin/enumerate.d.ts.map +1 -1
- package/dist/designSystemPlugin/enumerate.js +14 -1
- package/dist/designSystemPlugin/enumerate.js.map +1 -1
- package/dist/designSystemPlugin/patterns/a11y.d.ts.map +1 -1
- package/dist/designSystemPlugin/patterns/a11y.js +27 -8
- package/dist/designSystemPlugin/patterns/a11y.js.map +1 -1
- package/dist/designSystemPlugin/patterns/borders.d.ts.map +1 -1
- package/dist/designSystemPlugin/patterns/borders.js +8 -3
- package/dist/designSystemPlugin/patterns/borders.js.map +1 -1
- package/dist/designSystemPlugin/patterns/colors.d.ts.map +1 -1
- package/dist/designSystemPlugin/patterns/colors.js +14 -2
- package/dist/designSystemPlugin/patterns/colors.js.map +1 -1
- package/dist/designSystemPlugin/patterns/radius.js +1 -1
- package/dist/designSystemPlugin/patterns/typography.d.ts.map +1 -1
- package/dist/designSystemPlugin/patterns/typography.js +114 -17
- package/dist/designSystemPlugin/patterns/typography.js.map +1 -1
- package/dist/designSystemPlugin/plugin.d.ts +33 -0
- package/dist/designSystemPlugin/plugin.d.ts.map +1 -1
- package/dist/designSystemPlugin/plugin.js +289 -9
- package/dist/designSystemPlugin/plugin.js.map +1 -1
- package/dist/designSystemPlugin/types.d.ts +96 -1
- package/dist/designSystemPlugin/types.d.ts.map +1 -1
- package/dist/designSystemPlugin/types.js +31 -2
- package/dist/designSystemPlugin/types.js.map +1 -1
- package/dist/htmlTransform/htmlTransform.d.ts +7 -4
- package/dist/htmlTransform/htmlTransform.d.ts.map +1 -1
- package/dist/htmlTransform/htmlTransform.js +19 -6
- package/dist/htmlTransform/htmlTransform.js.map +1 -1
- package/dist/iconsPlugin/plugin.d.ts +3 -0
- package/dist/iconsPlugin/plugin.d.ts.map +1 -1
- package/dist/iconsPlugin/plugin.js +12 -1
- package/dist/iconsPlugin/plugin.js.map +1 -1
- package/dist/iconsPlugin/types.d.ts +11 -0
- package/dist/iconsPlugin/types.d.ts.map +1 -1
- package/dist/iconsPlugin/types.js +11 -0
- package/dist/iconsPlugin/types.js.map +1 -1
- package/dist/ssrPlugin/plugin.d.ts.map +1 -1
- package/dist/ssrPlugin/plugin.js +16 -0
- package/dist/ssrPlugin/plugin.js.map +1 -1
- package/package.json +5 -5
- package/dist/babelPlugin/extractOriginalTagNames.d.ts +0 -20
- package/dist/babelPlugin/extractOriginalTagNames.d.ts.map +0 -1
- package/dist/babelPlugin/extractOriginalTagNames.js +0 -44
- package/dist/babelPlugin/extractOriginalTagNames.js.map +0 -1
|
@@ -26,6 +26,106 @@ const whitespacePattern = WHITESPACES.join('|');
|
|
|
26
26
|
const verticalAlignPattern = VERTICAL_ALIGNS.join('|');
|
|
27
27
|
const displaySizePattern = DISPLAY_SIZES.join('|');
|
|
28
28
|
const proseSizePattern = PROSE_SIZES.join('|');
|
|
29
|
+
/**
|
|
30
|
+
* Font-size SCALE LEVELS are not always spelled the same as the CSS custom
|
|
31
|
+
* properties the design system emits. The step-0 level is called `base` in
|
|
32
|
+
* `FONT_SIZES` (and in the `u-text-base` class name, which is public API), but
|
|
33
|
+
* `typographyCssVars()` emits it as `--font-size-body`. Emitting
|
|
34
|
+
* `var(--font-size-base)` therefore referenced a property that is never defined,
|
|
35
|
+
* so every `u-text-base` silently fell back to its hardcoded literal.
|
|
36
|
+
*
|
|
37
|
+
* Any level absent from this map emits `--font-size-<level>` unchanged.
|
|
38
|
+
*/
|
|
39
|
+
const FONT_SIZE_VAR_NAME = {
|
|
40
|
+
base: 'body',
|
|
41
|
+
};
|
|
42
|
+
/** Resolve a font-size level to the CSS custom property the design system emits. */
|
|
43
|
+
function fontSizeVar(size) {
|
|
44
|
+
return `--font-size-${FONT_SIZE_VAR_NAME[size] ?? size}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Subtrees `.u-prose` keeps its hands off: anything marked `.u-not-prose`, plus
|
|
48
|
+
* any nested ui-kit component ROOT and its internals — a component owns its own
|
|
49
|
+
* box. Prose's own `.ui-prose` hook is exempted; it IS the prose root.
|
|
50
|
+
*
|
|
51
|
+
* MIRROR of `$_prose-exclude` in
|
|
52
|
+
* `packages/design-system/src/typography/styles/utilities/_text.scss`, where the
|
|
53
|
+
* five shapes (every term anchored under `.u-prose` / bare + descendant /
|
|
54
|
+
* prefix-anchored attribute match / `:not(:has(.u-prose))` on the descendant
|
|
55
|
+
* terms so a nested `<Prose>` keeps its treatment / the accepted depth bleed)
|
|
56
|
+
* are each explained against the defect they close. Both copies are pinned by
|
|
57
|
+
* `packages/ui-kit/tests/prose-selectors.test.ts` — change one and that suite
|
|
58
|
+
* fails.
|
|
59
|
+
*/
|
|
60
|
+
const PROSE_EXCLUDE = '.u-prose .u-not-prose, .u-prose .u-not-prose *, ' +
|
|
61
|
+
'.u-prose [class^="ui-"]:not(.ui-prose), .u-prose [class*=" ui-"]:not(.ui-prose), ' +
|
|
62
|
+
'.u-prose [class^="ui-"]:not(.ui-prose):not(:has(.u-prose)) *, .u-prose [class*=" ui-"]:not(.ui-prose):not(:has(.u-prose)) *';
|
|
63
|
+
/**
|
|
64
|
+
* CSS for the `.u-prose` long-form container.
|
|
65
|
+
*
|
|
66
|
+
* MIRROR — the canonical source is the SCSS utility at
|
|
67
|
+
* `packages/design-system/src/typography/styles/utilities/_text.scss`
|
|
68
|
+
* (`.u-prose`). This generator exists because apps consume utilities through
|
|
69
|
+
* `virtual:pithy-design-system` and never compile that SCSS; the two must be
|
|
70
|
+
* kept in sync, exactly as every other utility in this file mirrors its SCSS
|
|
71
|
+
* counterpart. See the block comment above `.u-prose` there for why the rhythm
|
|
72
|
+
* is expressed in `em` rather than `--space-*` tokens, and why BOTH `:where()`
|
|
73
|
+
* and `PROSE_EXCLUDE` are load-bearing: the first covers the properties a
|
|
74
|
+
* nested component declares, the second the ones it does not.
|
|
75
|
+
*/
|
|
76
|
+
function proseCSS(className) {
|
|
77
|
+
// Zero-specificity descendant selector, minus the excluded subtrees.
|
|
78
|
+
const el = (selector) => `.${className} :where(${selector}):not(:where(${PROSE_EXCLUDE}))`;
|
|
79
|
+
return `.${className} {
|
|
80
|
+
max-inline-size: 65ch;
|
|
81
|
+
font-size: var(--font-size-body);
|
|
82
|
+
line-height: var(--line-height-body);
|
|
83
|
+
}
|
|
84
|
+
${el('h1')} { margin-block-start: 0; margin-block-end: 0.75em; }
|
|
85
|
+
${el('h2')} { margin-block-start: 1.5em; margin-block-end: 0.75em; }
|
|
86
|
+
${el('h3')} { margin-block-start: 1.25em; margin-block-end: 0.5em; }
|
|
87
|
+
${el('h4, h5, h6')} { margin-block-start: 1em; margin-block-end: 0.5em; }
|
|
88
|
+
${el('p')} { margin-block-end: 1.25em; }
|
|
89
|
+
${el('ul, ol')} { margin-block-end: 1.25em; padding-inline-start: 1.5em; }
|
|
90
|
+
${el('li')} { margin-block-end: 0.5em; }
|
|
91
|
+
${el('li > ul, li > ol')} { margin-block: 0.5em; }
|
|
92
|
+
${el('hr')} { margin-block: 2.5em; border: 0; border-block-start: var(--border-width-hairline) var(--border-style-solid) var(--color-divider); }
|
|
93
|
+
${el('a')} { color: var(--color-primary); text-decoration: underline; text-decoration-color: var(--color-primary); text-decoration-thickness: var(--border-width-hairline); text-underline-offset: 0.15em; text-decoration-skip-ink: auto; }
|
|
94
|
+
${el('a')}:hover, ${el('a')}:focus-visible { color: var(--color-primary-hover); text-decoration-color: var(--color-primary-hover); }
|
|
95
|
+
${el('a')}:focus-visible { outline: none; box-shadow: 0 0 0 var(--focus-ring-offset) var(--color-surface, #fff), 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--ring-color, var(--color-primary)); }
|
|
96
|
+
@media (forced-colors: active) {
|
|
97
|
+
${el('a')}:focus-visible { outline: var(--focus-ring-width) solid Highlight; outline-offset: var(--focus-ring-offset); }
|
|
98
|
+
}
|
|
99
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
100
|
+
${el('a')} { transition: var(--motion-transition-color), text-decoration-color var(--motion-duration-normal) var(--motion-easing-standard); }
|
|
101
|
+
}
|
|
102
|
+
${el('strong, b')} { font-weight: var(--font-weight-semibold); }
|
|
103
|
+
${el('em, i')} { font-style: italic; }
|
|
104
|
+
${el('code')} { font-family: var(--font-family-mono); font-size: var(--inline-code-font-size); padding-block: var(--inline-code-padding-block); padding-inline: var(--inline-code-padding-inline); margin-inline: var(--inline-code-margin-inline); background-color: var(--color-surface-variant); border: var(--border-width-hairline) var(--border-style-solid) var(--color-border); border-radius: var(--radius-xs); overflow-wrap: break-word; }
|
|
105
|
+
${el('pre code')} { padding: 0; margin-inline: 0; background-color: transparent; border: 0; border-radius: 0; font-size: inherit; }
|
|
106
|
+
${el('pre')} { margin-block: 1.5em; padding-block: 1em; padding-inline: 1.25em; font-family: var(--font-family-mono); font-size: 0.875em; background-color: var(--color-surface-variant); border: var(--border-width-hairline) var(--border-style-solid) var(--color-border); border-radius: var(--radius-md); overflow-x: auto; }
|
|
107
|
+
${el('blockquote')} { margin-block: 1.5em; margin-inline: 0; padding-block: 0.25em; padding-inline-start: 1.25em; border-inline-start: var(--border-width-medium) var(--border-style-solid) var(--color-primary); color: var(--color-text-muted); font-style: italic; }
|
|
108
|
+
${el('blockquote > :last-child')} { margin-block-end: 0; }
|
|
109
|
+
${el('img, video')} { display: block; max-inline-size: 100%; block-size: auto; margin-block: 1.5em; border-radius: var(--radius-md); }
|
|
110
|
+
${el('figure')} { margin-block: 1.5em; margin-inline: 0; }
|
|
111
|
+
${el('figure > img, figure > video')} { margin-block: 0; }
|
|
112
|
+
${el('figcaption')} { margin-block-start: 0.75em; font-size: 0.875em; color: var(--color-text-muted); text-align: center; }
|
|
113
|
+
${el('table')} { inline-size: 100%; margin-block: 1.5em; border-collapse: collapse; }
|
|
114
|
+
${el('caption')} { margin-block-end: 0.5em; color: var(--color-text-muted); font-size: 0.875em; text-align: start; }
|
|
115
|
+
${el('th, td')} { padding-block: 0.5em; padding-inline: 0.75em; border-block-end: var(--border-width-hairline) var(--border-style-solid) var(--color-border); text-align: start; vertical-align: top; }
|
|
116
|
+
${el('thead th')} { border-block-end: var(--border-width-thin) var(--border-style-solid) var(--color-border); font-weight: var(--font-weight-semibold); }
|
|
117
|
+
${el('tbody tr:last-child > *')} { border-block-end: 0; }
|
|
118
|
+
${el('dl')} { margin-block-end: 1.25em; }
|
|
119
|
+
${el('dt')} { margin-block-start: 1em; font-weight: var(--font-weight-semibold); }
|
|
120
|
+
${el('dd')} { margin-block-start: 0.25em; margin-inline-start: 1.5em; color: var(--color-text-muted); }
|
|
121
|
+
/* Container edges — MUST STAY LAST. Same (0,1,0) specificity as every element
|
|
122
|
+
rule above, so the later rule wins. Emitted before them, a leading <pre> /
|
|
123
|
+
<blockquote> / <figure> / <img> / <table> had its own margin-block re-applied
|
|
124
|
+
and sat with a top gap instead of flush. Mirrors the trailing block in
|
|
125
|
+
_text.scss. */
|
|
126
|
+
.${className} > :where(:first-child):not(:where(.u-not-prose)) { margin-block-start: 0; }
|
|
127
|
+
.${className} > :where(:last-child):not(:where(.u-not-prose)) { margin-block-end: 0; }`;
|
|
128
|
+
}
|
|
29
129
|
export const typographyPatterns = [
|
|
30
130
|
// ============================================
|
|
31
131
|
// Font Family: u-font-body, u-font-heading, u-font-mono
|
|
@@ -52,7 +152,7 @@ export const typographyPatterns = [
|
|
|
52
152
|
const size = match[1];
|
|
53
153
|
// Use CSS variables for fluid support, with static fallback
|
|
54
154
|
return `.${className} {
|
|
55
|
-
font-size: var(
|
|
155
|
+
font-size: var(${fontSizeVar(size)}, ${FONT_SIZE_VALUES[size].value}) !important;
|
|
56
156
|
}`;
|
|
57
157
|
},
|
|
58
158
|
},
|
|
@@ -337,21 +437,18 @@ export const typographyPatterns = [
|
|
|
337
437
|
name: 'prose',
|
|
338
438
|
category: 'typography',
|
|
339
439
|
pattern: /^u-prose$/,
|
|
340
|
-
generate: className =>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
.${className}
|
|
352
|
-
.${className} blockquote { margin: 1.5em 0; }
|
|
353
|
-
.${className} pre { margin: 1.5em 0; }
|
|
354
|
-
.${className} hr { margin: 2.5em 0; }`,
|
|
440
|
+
generate: className => proseCSS(className),
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
// `.u-not-prose` is a MARKER class, not a style: it only ever appears inside
|
|
444
|
+
// prose's `:not()` exclusion list. It still has to be registered, or the JIT
|
|
445
|
+
// extractor scans it out of source, finds no matching pattern, and reports it
|
|
446
|
+
// as an unknown utility on every build. Emits a comment on purpose — there
|
|
447
|
+
// are no declarations to make.
|
|
448
|
+
name: 'not-prose',
|
|
449
|
+
category: 'typography',
|
|
450
|
+
pattern: /^u-not-prose$/,
|
|
451
|
+
generate: className => `/* .${className} — marker class consumed by .u-prose's exclusion list; intentionally no declarations */`,
|
|
355
452
|
},
|
|
356
453
|
{
|
|
357
454
|
name: 'prose-size',
|
|
@@ -367,7 +464,7 @@ export const typographyPatterns = [
|
|
|
367
464
|
const config = configs[size];
|
|
368
465
|
return `.${className} {
|
|
369
466
|
font-size: ${config.fontSize} !important;
|
|
370
|
-
max-
|
|
467
|
+
max-inline-size: ${config.maxWidth} !important;
|
|
371
468
|
}`;
|
|
372
469
|
},
|
|
373
470
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.js","sourceRoot":"","sources":["../../../src/designSystemPlugin/patterns/typography.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAGF,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,0CAA0C,CAAC;AAElD,mCAAmC;AACnC,MAAM,iBAAiB,GA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AAM,CAAC,YAAY,eAAe,IAAI,CAAC;QACpD,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;YACvD,4DAA4D;YAC5D,OAAO,IAAI,SAAS
|
|
1
|
+
{"version":3,"file":"typography.js","sourceRoot":"","sources":["../../../src/designSystemPlugin/patterns/typography.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAGF,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,0CAA0C,CAAC;AAElD,mCAAmC;AACnC,MAAM,iBAAiB,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,MAAM,iBAAiB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,iBAAiB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,oBAAoB,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,MAAM,gBAAgB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,MAAM,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,oBAAoB,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,MAAM,kBAAkB,GAAG,aAAa,CAAC,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,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,SAAS;;;EAGtC;KACC;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,0BAA0B;QACnC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,SAAS;;;EAGtC;KACC;CACF,CAAC"}
|
|
@@ -21,13 +21,46 @@ import { type DesignSystemPluginOptions } from './types';
|
|
|
21
21
|
* Extracts used utility classes from source files and generates
|
|
22
22
|
* only the CSS needed for those utilities.
|
|
23
23
|
*
|
|
24
|
+
* Also prepends the **static design-system token stylesheet** to the virtual
|
|
25
|
+
* module — the color palette plus every other token category (typography,
|
|
26
|
+
* spacing, radius, borders, shadows, motion, a11y, iconography, layout) — so
|
|
27
|
+
* that SSR/SSG output, which never runs the runtime managers, still resolves
|
|
28
|
+
* every `var(--color-*)`, `var(--font-*)`, `var(--control-*)` and friends.
|
|
29
|
+
* Tokens are not gated on utility usage — UI Kit component SCSS references them
|
|
30
|
+
* outside of any `u-*` class, so that would leave those components unstyled. The
|
|
31
|
+
* one exception is each colour token's `-rgb`/`-l`/`-c`/`-h` channel variants,
|
|
32
|
+
* gated on `var()` references found in scanned stylesheets; see
|
|
33
|
+
* `gateChannelVars`.
|
|
34
|
+
*
|
|
35
|
+
* Pass the app's design system config as the `designSystem` option so the
|
|
36
|
+
* emitted tokens match what `initDesignSystem()` will write; if they diverge,
|
|
37
|
+
* hydration rewrites the tokens and the page flashes.
|
|
38
|
+
*
|
|
39
|
+
* Keep that config in its own module and import it from both `pithy.config.ts`
|
|
40
|
+
* and `vite.config.ts`. Do **not** import `./pithy.config` here: `vite.config.ts`
|
|
41
|
+
* is bundled by esbuild and then executed by bare Node, and Vite externalizes
|
|
42
|
+
* bare specifiers, so it would drag `@pithyjs/shared`'s `defineConfig` into a
|
|
43
|
+
* Node ESM import that fails with `ERR_MODULE_NOT_FOUND`. A dedicated module
|
|
44
|
+
* with no runtime imports still gives one source of truth.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // design-system.config.ts — type import only, so bare Node can load it
|
|
48
|
+
* import type { DesignSystemConfig } from '@pithyjs/design-system/palette';
|
|
49
|
+
*
|
|
50
|
+
* export const designSystem: DesignSystemConfig = {
|
|
51
|
+
* shadows: { preset: 'elevated' },
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
24
54
|
* @example
|
|
25
55
|
* // vite.config.ts
|
|
26
56
|
* import { designSystemPlugin } from '@pithyjs/vite-plugin';
|
|
57
|
+
* import { designSystem } from './design-system.config';
|
|
27
58
|
*
|
|
28
59
|
* export default defineConfig({
|
|
29
60
|
* plugins: [
|
|
30
61
|
* designSystemPlugin({
|
|
62
|
+
* // Same object pithy.config.ts uses — no mirroring, no drift
|
|
63
|
+
* designSystem,
|
|
31
64
|
* safelist: ['u-bg-success', /^u-text-/],
|
|
32
65
|
* debug: true,
|
|
33
66
|
* })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/designSystemPlugin/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/designSystemPlugin/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAmBlE,OAAO,EAKL,KAAK,yBAAyB,EAC/B,MAAM,SAAS,CAAC;AAyEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,kLAAkL;AAClL,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAyjBR"}
|
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { readFileSync, readdirSync, statSync } from 'fs';
|
|
17
17
|
import { join, dirname } from 'path';
|
|
18
|
+
import { themeToCss, resolveTheme, designSystemToCss, } from '@pithyjs/design-system/palette';
|
|
18
19
|
import { createCollector } from './collector';
|
|
20
|
+
import { collectChannelVarRefs, createChannelVarGate, isChannelScanCandidate, resolveChannelScanRoots, scanChannelVarRefs, } from './channelVars';
|
|
19
21
|
import { generateCSS } from './generator';
|
|
20
22
|
import { enumerateAllUtilities } from './enumerate';
|
|
21
|
-
import { VIRTUAL_MODULE_ID, RESOLVED_VIRTUAL_MODULE_ID, resolveOptions, } from './types';
|
|
23
|
+
import { VIRTUAL_MODULE_ID, RESOLVED_VIRTUAL_MODULE_ID, resolveOptions, defaultModeOf, } from './types';
|
|
22
24
|
/**
|
|
23
25
|
* Format byte count to human-readable string
|
|
24
26
|
*/
|
|
@@ -71,19 +73,57 @@ function matchPattern(path, pattern) {
|
|
|
71
73
|
const regex = new RegExp(`^${regexPattern}$|^.*/${regexPattern}$`);
|
|
72
74
|
return regex.test(path);
|
|
73
75
|
}
|
|
76
|
+
/** Channel declarations an UNGATED sheet carries, for the dropped count. */
|
|
77
|
+
function fullChannelDeclarationCount(theme, defaultMode) {
|
|
78
|
+
const full = themeToCss(theme, { defaultMode });
|
|
79
|
+
return (full.match(/--color-[\w-]+-(?:rgb|l|c|h)\s*:/g) ?? []).length;
|
|
80
|
+
}
|
|
74
81
|
/**
|
|
75
82
|
* Vite plugin for Pithy Design System CSS tree-shaking
|
|
76
83
|
*
|
|
77
84
|
* Extracts used utility classes from source files and generates
|
|
78
85
|
* only the CSS needed for those utilities.
|
|
79
86
|
*
|
|
87
|
+
* Also prepends the **static design-system token stylesheet** to the virtual
|
|
88
|
+
* module — the color palette plus every other token category (typography,
|
|
89
|
+
* spacing, radius, borders, shadows, motion, a11y, iconography, layout) — so
|
|
90
|
+
* that SSR/SSG output, which never runs the runtime managers, still resolves
|
|
91
|
+
* every `var(--color-*)`, `var(--font-*)`, `var(--control-*)` and friends.
|
|
92
|
+
* Tokens are not gated on utility usage — UI Kit component SCSS references them
|
|
93
|
+
* outside of any `u-*` class, so that would leave those components unstyled. The
|
|
94
|
+
* one exception is each colour token's `-rgb`/`-l`/`-c`/`-h` channel variants,
|
|
95
|
+
* gated on `var()` references found in scanned stylesheets; see
|
|
96
|
+
* `gateChannelVars`.
|
|
97
|
+
*
|
|
98
|
+
* Pass the app's design system config as the `designSystem` option so the
|
|
99
|
+
* emitted tokens match what `initDesignSystem()` will write; if they diverge,
|
|
100
|
+
* hydration rewrites the tokens and the page flashes.
|
|
101
|
+
*
|
|
102
|
+
* Keep that config in its own module and import it from both `pithy.config.ts`
|
|
103
|
+
* and `vite.config.ts`. Do **not** import `./pithy.config` here: `vite.config.ts`
|
|
104
|
+
* is bundled by esbuild and then executed by bare Node, and Vite externalizes
|
|
105
|
+
* bare specifiers, so it would drag `@pithyjs/shared`'s `defineConfig` into a
|
|
106
|
+
* Node ESM import that fails with `ERR_MODULE_NOT_FOUND`. A dedicated module
|
|
107
|
+
* with no runtime imports still gives one source of truth.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // design-system.config.ts — type import only, so bare Node can load it
|
|
111
|
+
* import type { DesignSystemConfig } from '@pithyjs/design-system/palette';
|
|
112
|
+
*
|
|
113
|
+
* export const designSystem: DesignSystemConfig = {
|
|
114
|
+
* shadows: { preset: 'elevated' },
|
|
115
|
+
* };
|
|
116
|
+
*
|
|
80
117
|
* @example
|
|
81
118
|
* // vite.config.ts
|
|
82
119
|
* import { designSystemPlugin } from '@pithyjs/vite-plugin';
|
|
120
|
+
* import { designSystem } from './design-system.config';
|
|
83
121
|
*
|
|
84
122
|
* export default defineConfig({
|
|
85
123
|
* plugins: [
|
|
86
124
|
* designSystemPlugin({
|
|
125
|
+
* // Same object pithy.config.ts uses — no mirroring, no drift
|
|
126
|
+
* designSystem,
|
|
87
127
|
* safelist: ['u-bg-success', /^u-text-/],
|
|
88
128
|
* debug: true,
|
|
89
129
|
* })
|
|
@@ -94,15 +134,119 @@ function matchPattern(path, pattern) {
|
|
|
94
134
|
export function designSystemPlugin(options = {}) {
|
|
95
135
|
const resolvedOptions = resolveOptions(options);
|
|
96
136
|
const { include, exclude, debug, devMode } = resolvedOptions;
|
|
137
|
+
/**
|
|
138
|
+
* Base color tokens are NOT JIT-gated: `var(--color-*)` references come from
|
|
139
|
+
* UI Kit component SCSS as well as from `u-*` utility classes, and the
|
|
140
|
+
* collector only sees utility classes.
|
|
141
|
+
*
|
|
142
|
+
* Their `-rgb`/`-l`/`-c`/`-h` channel variants are gated on references found
|
|
143
|
+
* by {@link scanChannelVarRefs}. `themeToCss` is therefore evaluated per
|
|
144
|
+
* `load()`, not once per plugin instance: the scan it depends on runs in
|
|
145
|
+
* `buildStart`, strictly after this function exists, and in dev it is re-run
|
|
146
|
+
* when a scanned file changes.
|
|
147
|
+
*
|
|
148
|
+
* The gate fails open everywhere detection is uncertain; see
|
|
149
|
+
* {@link scanChannelVarRefs} for why that direction and no other.
|
|
150
|
+
*
|
|
151
|
+
* Imported from the `@pithyjs/design-system/palette` subpath, NOT the package
|
|
152
|
+
* root: the root `dist` entry is not loadable by bare Node (tsc emits
|
|
153
|
+
* extensionless/directory specifiers), and Vite's config bundler externalizes
|
|
154
|
+
* bare specifiers to a path Node then imports — so importing the root here
|
|
155
|
+
* would break every vite.config load. `./palette` is an esbuild-bundled,
|
|
156
|
+
* self-contained, DOM-free ESM file.
|
|
157
|
+
*/
|
|
158
|
+
const defaultMode = defaultModeOf(resolvedOptions.designSystem);
|
|
159
|
+
const theme = resolveTheme(resolvedOptions.designSystem.colors);
|
|
160
|
+
function paletteCss(utilityCSS) {
|
|
161
|
+
const gate = createChannelVarGate({
|
|
162
|
+
enabled: resolvedOptions.gateChannelVars,
|
|
163
|
+
scan: channelScan,
|
|
164
|
+
// Everything shipped in the same response, not just the utilities: the
|
|
165
|
+
// token sheet is concatenated below, so a channel reference emitted
|
|
166
|
+
// there would otherwise ship while the gate dropped its variable.
|
|
167
|
+
extraRefs: collectChannelVarRefs(utilityCSS + '\n' + tokensCSS),
|
|
168
|
+
safelist: resolvedOptions.channelVarSafelist,
|
|
169
|
+
});
|
|
170
|
+
log(`Channel vars: ${gate.active ? 'gated' : 'all emitted'} — ${gate.reason}`);
|
|
171
|
+
// A degraded scan means the feature is off and the build still succeeds,
|
|
172
|
+
// which is indistinguishable from success behind a default-off flag. Warn
|
|
173
|
+
// unconditionally, once, the way collect-css.ts does for its analogous
|
|
174
|
+
// "no plugin registered" case.
|
|
175
|
+
if (gate.degraded && resolvedOptions.gateChannelVars && !warnedInactive) {
|
|
176
|
+
warnedInactive = true;
|
|
177
|
+
console.warn(`[pithy-design-system] Channel-variable gating is INACTIVE — ${gate.reason}. ` +
|
|
178
|
+
`Every --color-*-rgb/-l/-c/-h variable ships. Pass debug: true for the scan roots.`);
|
|
179
|
+
}
|
|
180
|
+
const css = themeToCss(theme, {
|
|
181
|
+
defaultMode,
|
|
182
|
+
keepChannelVar: gate.active ? gate.keep : undefined,
|
|
183
|
+
});
|
|
184
|
+
// The ACTIVE path needs a signal too, and until now only the harmless
|
|
185
|
+
// state (gate off, keeping everything) printed anything. Every fail-closed
|
|
186
|
+
// path in this module is silent in a real build otherwise: the only way one
|
|
187
|
+
// has ever been found is by someone reading the scanner. One line, once,
|
|
188
|
+
// naming what was dropped and where it looked.
|
|
189
|
+
if (gate.active && !announcedActive) {
|
|
190
|
+
announcedActive = true;
|
|
191
|
+
const kept = (css.match(/--color-[\w-]+-(?:rgb|l|c|h)\s*:/g) ?? [])
|
|
192
|
+
.length;
|
|
193
|
+
const dropped = fullChannelDeclarationCount(theme, defaultMode) - kept;
|
|
194
|
+
console.info(`[pithy-design-system] Channel-variable gating ACTIVE — dropped ${dropped} ` +
|
|
195
|
+
`of ${dropped + kept} channel declarations (${gate.reason}). ` +
|
|
196
|
+
`Scanned: ${channelScan?.filesScanned ?? 0} file(s) under ` +
|
|
197
|
+
`${scannedRoots.join(', ') || 'no roots'}. ` +
|
|
198
|
+
`A variable missing with JavaScript disabled means this scan did not see it — ` +
|
|
199
|
+
`add it to channelVarSafelist or a root to channelVarScanRoots.`);
|
|
200
|
+
}
|
|
201
|
+
return css;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Static stylesheet for every **non-color** token category — typography,
|
|
205
|
+
* spacing, radius, borders, shadows, motion, a11y, iconography, layout.
|
|
206
|
+
*
|
|
207
|
+
* Same problem as the palette above, same shape of fix: those categories are
|
|
208
|
+
* written to `document.documentElement.style` by their runtime managers, so a
|
|
209
|
+
* JS-disabled SSG page had ~106 undefined `var()` references — headers in
|
|
210
|
+
* Times serif, zero-padding buttons, no shadows, no focus rings. Serializing
|
|
211
|
+
* them here makes the page paint correctly with no JavaScript, and the runtime
|
|
212
|
+
* managers then write byte-identical values on hydration (both sides go
|
|
213
|
+
* through the same pure formatters), so hydration is a visual no-op.
|
|
214
|
+
*
|
|
215
|
+
* Driven by the whole `designSystem` config rather than plugin-local defaults:
|
|
216
|
+
* emitting defaults while the app configures `bodyFont: 'Inter'` would just
|
|
217
|
+
* trade "undefined until JS" for "wrong until JS".
|
|
218
|
+
*
|
|
219
|
+
* Deliberately NOT JIT-gated: UI Kit component SCSS references these tokens
|
|
220
|
+
* outside any `u-*` utility class, so filtering by detected utility usage
|
|
221
|
+
* would leave those components unstyled. Cost is a fixed ~10 KB raw / ~2 KB
|
|
222
|
+
* gzip per page. A usage gate of the shape the palette's channel variants got
|
|
223
|
+
* is possible here too, but these are one variable per token, not five.
|
|
224
|
+
*
|
|
225
|
+
* Computed once per plugin instance — pure, deterministic, and dependent only
|
|
226
|
+
* on plugin options, never on collector state.
|
|
227
|
+
*/
|
|
228
|
+
const tokensCSS = designSystemToCss(resolvedOptions.designSystem, {
|
|
229
|
+
defaultMode,
|
|
230
|
+
});
|
|
231
|
+
/** Palette + non-color tokens, prepended to every virtual-module response. */
|
|
232
|
+
function staticTokens(utilityCSS) {
|
|
233
|
+
return paletteCss(utilityCSS) + '\n' + tokensCSS;
|
|
234
|
+
}
|
|
97
235
|
let config;
|
|
98
236
|
let devServer = null;
|
|
99
237
|
let collector;
|
|
238
|
+
/** Channel-variable references found on disk; `null` until `buildStart`. */
|
|
239
|
+
let channelScan = null;
|
|
100
240
|
let cachedCSS = null;
|
|
101
241
|
let lastHash = '';
|
|
102
242
|
let fullCSSBytes = null;
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
243
|
+
/** Latch so the degraded-scan warning prints once per build, not per load. */
|
|
244
|
+
let warnedInactive = false;
|
|
245
|
+
/** Same, for the active-path summary. */
|
|
246
|
+
let announcedActive = false;
|
|
247
|
+
/** Roots the last scan actually read, for that summary. */
|
|
248
|
+
let scannedRoots = [];
|
|
249
|
+
/** Log debug messages if debug mode is enabled */
|
|
106
250
|
function log(...args) {
|
|
107
251
|
if (debug) {
|
|
108
252
|
console.log('[pithy-design-system]', ...args);
|
|
@@ -123,9 +267,46 @@ export function designSystemPlugin(options = {}) {
|
|
|
123
267
|
// Vite normalizes aliases to an array of { find, replacement }
|
|
124
268
|
if (Array.isArray(aliases)) {
|
|
125
269
|
for (const alias of aliases) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
270
|
+
if (!alias.replacement)
|
|
271
|
+
continue;
|
|
272
|
+
const NAME = '@pithyjs/ui-kit';
|
|
273
|
+
if (typeof alias.find === 'string') {
|
|
274
|
+
// Vite's rule, not exact-only: `=== name`, or a prefix ending at a
|
|
275
|
+
// `/` SEGMENT boundary. Exact-only here while `aliasReplacement`
|
|
276
|
+
// implemented Vite's rule meant `{find:'@pithyjs'}` resolved the scan
|
|
277
|
+
// root but not this one — so ui-kit's utility classes never reached
|
|
278
|
+
// the collector and its components rendered UNSTYLED in JIT mode.
|
|
279
|
+
// Same failure as the RegExp branch had, left in the string branch.
|
|
280
|
+
if (alias.find === NAME) {
|
|
281
|
+
const dir = normalizeToDir(alias.replacement);
|
|
282
|
+
if (dir)
|
|
283
|
+
return dir;
|
|
284
|
+
}
|
|
285
|
+
else if (NAME.startsWith(`${alias.find}/`)) {
|
|
286
|
+
const dir = normalizeToDir(alias.replacement + NAME.slice(alias.find.length));
|
|
287
|
+
if (dir)
|
|
288
|
+
return dir;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if (alias.find instanceof RegExp) {
|
|
292
|
+
// A LOCAL CLONE. The alias object is Vite's, and it calls
|
|
293
|
+
// `pattern.test(importee)` on it for every later import. `test` and
|
|
294
|
+
// `[Symbol.replace]` both advance `lastIndex` on /y or /g, so
|
|
295
|
+
// leaving it advanced made the user's alias stop resolving for the
|
|
296
|
+
// rest of the build — a module-resolution failure caused by a CSS
|
|
297
|
+
// plugin. Resetting before the call did not cover that; not touching
|
|
298
|
+
// the object does.
|
|
299
|
+
const find = new RegExp(alias.find.source, alias.find.flags);
|
|
300
|
+
if (find.test(NAME)) {
|
|
301
|
+
find.lastIndex = 0;
|
|
302
|
+
// STRING replacement so `$1` works — the canonical monorepo alias
|
|
303
|
+
// is `/^@pithyjs\/(.*)$/` with `packages/$1/src`.
|
|
304
|
+
const dir = normalizeToDir(NAME.replace(find, alias.replacement));
|
|
305
|
+
// Only accept a usable answer: a broad regex matching first must
|
|
306
|
+
// not shadow a later exact alias that would have worked.
|
|
307
|
+
if (dir)
|
|
308
|
+
return dir;
|
|
309
|
+
}
|
|
129
310
|
}
|
|
130
311
|
}
|
|
131
312
|
}
|
|
@@ -200,6 +381,86 @@ export function designSystemPlugin(options = {}) {
|
|
|
200
381
|
}
|
|
201
382
|
log(`Pre-scanned ${files.length} files, found ${collector.getAllUtilities().size} utilities`);
|
|
202
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Scan every stylesheet reachable from this build for channel-variable usage.
|
|
386
|
+
*
|
|
387
|
+
* Separate from `scanSourceFiles`: that walk is driven by `include`, which
|
|
388
|
+
* lists `.ts`/`.tsx`/`.pithy` and no stylesheet at all, and it stops at the
|
|
389
|
+
* app root plus the aliased ui-kit directory.
|
|
390
|
+
*/
|
|
391
|
+
/** Whether two scans would gate identically — same refs, wildcards, degraded. */
|
|
392
|
+
function sameChannelScan(a, b) {
|
|
393
|
+
if (a === null || b === null)
|
|
394
|
+
return a === b;
|
|
395
|
+
const sameSet = (x, y) => x.size === y.size && [...x].every(v => y.has(v));
|
|
396
|
+
return (a.degraded === b.degraded &&
|
|
397
|
+
sameSet(a.refs, b.refs) &&
|
|
398
|
+
sameSet(a.wildcardSuffixes, b.wildcardSuffixes));
|
|
399
|
+
}
|
|
400
|
+
function scanChannelVars() {
|
|
401
|
+
if (!resolvedOptions.gateChannelVars)
|
|
402
|
+
return;
|
|
403
|
+
try {
|
|
404
|
+
const plan = resolveChannelScanRoots(config.root, config.resolve?.alias, resolvedOptions.channelVarScanRoots);
|
|
405
|
+
// Name the roots. A package outside the Vite root is simply not seen,
|
|
406
|
+
// and the scan cannot report what it never looked at — so the only
|
|
407
|
+
// honest signal is what it DID look at, next to the option that adds
|
|
408
|
+
// more. Without this a sibling workspace package reads as "clean".
|
|
409
|
+
log(`Channel-var scan roots (add others with \`channelVarScanRoots\`):\n` +
|
|
410
|
+
plan.roots.map(r => ` - ${r.dir}`).join('\n'));
|
|
411
|
+
scannedRoots = plan.roots.map(r => r.dir);
|
|
412
|
+
channelScan = scanChannelVarRefs(plan);
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
// An unexpected throw would otherwise escape `buildStart` and fail the
|
|
416
|
+
// build. Uncertainty ships everything; a crash ships nothing.
|
|
417
|
+
channelScan = {
|
|
418
|
+
refs: new Set(),
|
|
419
|
+
wildcardSuffixes: new Set(),
|
|
420
|
+
degraded: true,
|
|
421
|
+
reason: `scan threw: ${String(err)}`,
|
|
422
|
+
filesScanned: 0,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
log(`Channel-var scan: ${channelScan.filesScanned} file(s), ` +
|
|
426
|
+
`${channelScan.refs.size} ref(s)` +
|
|
427
|
+
(channelScan.degraded ? ` — DEGRADED: ${channelScan.reason}` : ''));
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Re-run the channel scan after a dev edit, before the HMR update goes out.
|
|
431
|
+
*
|
|
432
|
+
* The generated CSS is regenerated whenever collector state changes, but the
|
|
433
|
+
* scan is not part of that state: without this, adding `var(--color-info-l)`
|
|
434
|
+
* to a stylesheet regenerates the sheet against the scan taken at startup, the
|
|
435
|
+
* variable is never emitted, and the element is unstyled with no error until
|
|
436
|
+
* the dev server is restarted. Dev and build gate identically so the two
|
|
437
|
+
* produce the same sheet — but do NOT read that as dev surfacing a gate
|
|
438
|
+
* miss. `ThemeManager` writes the channel variables as INLINE styles on
|
|
439
|
+
* `documentElement`, which outrank this `:root` sheet, so any app calling
|
|
440
|
+
* `initDesignSystem()` paints correctly in dev and in a hydrated page even
|
|
441
|
+
* when the gate drops a variable it should have kept. The only place a miss
|
|
442
|
+
* is observable is the JavaScript-disabled static export — which is also
|
|
443
|
+
* the only place it is a bug.
|
|
444
|
+
*/
|
|
445
|
+
let rescanTimer = null;
|
|
446
|
+
function rescanChannelVarsSoon() {
|
|
447
|
+
if (!resolvedOptions.gateChannelVars)
|
|
448
|
+
return;
|
|
449
|
+
if (rescanTimer)
|
|
450
|
+
clearTimeout(rescanTimer);
|
|
451
|
+
rescanTimer = setTimeout(() => {
|
|
452
|
+
rescanTimer = null;
|
|
453
|
+
const before = channelScan;
|
|
454
|
+
scanChannelVars();
|
|
455
|
+
// The scan is a full re-glob, so only pay for the reload when the kept
|
|
456
|
+
// set actually moved. Most edits touch no channel reference at all.
|
|
457
|
+
if (sameChannelScan(before, channelScan))
|
|
458
|
+
return;
|
|
459
|
+
cachedCSS = null;
|
|
460
|
+
sendHMRUpdate();
|
|
461
|
+
}, 50);
|
|
462
|
+
rescanTimer.unref?.();
|
|
463
|
+
}
|
|
203
464
|
/**
|
|
204
465
|
* Invalidate the virtual CSS module and send an HMR update.
|
|
205
466
|
* Used for incremental updates during dev (file edits, additions, deletions).
|
|
@@ -240,7 +501,7 @@ export function designSystemPlugin(options = {}) {
|
|
|
240
501
|
const isJitMode = resolvedOptions.jit || (config.command === 'serve' && devMode === 'jit');
|
|
241
502
|
if (isJitMode) {
|
|
242
503
|
const result = generateCSS(utilities, resolvedOptions);
|
|
243
|
-
cachedCSS = result.css;
|
|
504
|
+
cachedCSS = staticTokens(result.css) + '\n' + result.css;
|
|
244
505
|
if (debug) {
|
|
245
506
|
const { stats } = result;
|
|
246
507
|
log(`Generated: ${stats.matched} matched, ${stats.unknown} unknown`, Object.entries(stats.byCategory)
|
|
@@ -268,7 +529,7 @@ export function designSystemPlugin(options = {}) {
|
|
|
268
529
|
// Full mode - include all utilities
|
|
269
530
|
const allUtils = enumerateAllUtilities();
|
|
270
531
|
const result = generateCSS(allUtils, resolvedOptions);
|
|
271
|
-
cachedCSS = result.css;
|
|
532
|
+
cachedCSS = staticTokens(result.css) + '\n' + result.css;
|
|
272
533
|
}
|
|
273
534
|
lastHash = currentHash;
|
|
274
535
|
return cachedCSS;
|
|
@@ -327,6 +588,12 @@ export function designSystemPlugin(options = {}) {
|
|
|
327
588
|
},
|
|
328
589
|
configureServer(srv) {
|
|
329
590
|
devServer = srv;
|
|
591
|
+
for (const event of ['add', 'change', 'unlink']) {
|
|
592
|
+
srv.watcher.on(event, filePath => {
|
|
593
|
+
if (isChannelScanCandidate(filePath))
|
|
594
|
+
rescanChannelVarsSoon();
|
|
595
|
+
});
|
|
596
|
+
}
|
|
330
597
|
srv.watcher.on('unlink', filePath => {
|
|
331
598
|
if (!shouldProcessFile(filePath, include, exclude)) {
|
|
332
599
|
return;
|
|
@@ -337,6 +604,18 @@ export function designSystemPlugin(options = {}) {
|
|
|
337
604
|
sendHMRUpdate();
|
|
338
605
|
});
|
|
339
606
|
},
|
|
607
|
+
// An in-flight rescan would otherwise fire after the server is disposed,
|
|
608
|
+
// running a full filesystem scan and broadcasting to a closed socket. The
|
|
609
|
+
// SSG export hits this every run: `buildSSG` creates a middleware-mode
|
|
610
|
+
// server whose watcher sees each emitted `.html`, and the last timer lands
|
|
611
|
+
// after `vite.close()`.
|
|
612
|
+
closeBundle() {
|
|
613
|
+
if (rescanTimer) {
|
|
614
|
+
clearTimeout(rescanTimer);
|
|
615
|
+
rescanTimer = null;
|
|
616
|
+
}
|
|
617
|
+
devServer = null;
|
|
618
|
+
},
|
|
340
619
|
buildStart() {
|
|
341
620
|
collector.clear();
|
|
342
621
|
cachedCSS = null;
|
|
@@ -344,6 +623,7 @@ export function designSystemPlugin(options = {}) {
|
|
|
344
623
|
// Pre-scan source files so the collector is populated
|
|
345
624
|
// before the virtual CSS module is first loaded
|
|
346
625
|
scanSourceFiles();
|
|
626
|
+
scanChannelVars();
|
|
347
627
|
log('Build started - collector ready');
|
|
348
628
|
},
|
|
349
629
|
};
|