@bamboocss/vite 1.36.0 → 1.36.1

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/index.cjs CHANGED
@@ -89,6 +89,33 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
89
89
  removed = true;
90
90
  });
91
91
  }
92
+ if (prune) {
93
+ const present = /* @__PURE__ */ new Set();
94
+ root.walkRules((rule) => {
95
+ if (!isUtilityRule(rule)) return;
96
+ try {
97
+ (0, postcss_selector_parser.default)((selectors) => {
98
+ selectors.walkClasses((classNode) => {
99
+ present.add(classNode.toString().slice(1));
100
+ });
101
+ }).processSync(rule.selector);
102
+ } catch {}
103
+ });
104
+ const orphaned = [];
105
+ for (const className of session.usedClasses) {
106
+ if (/\s/.test(className)) {
107
+ orphaned.push(className);
108
+ continue;
109
+ }
110
+ if (!session.prunableClasses.has(className)) continue;
111
+ if (present.has(className)) continue;
112
+ orphaned.push(className);
113
+ }
114
+ if (orphaned.length) throw new Error(`bamboocss: ${orphaned.length} compiled class(es) have no rule in the emitted stylesheet. Elements carrying them would render unstyled.\n\n${(0, _bamboocss_shared.truncateList)(orphaned, {
115
+ unit: "class",
116
+ separator: "\n"
117
+ })}\n\nThis is a compiler bug rather than anything to fix in your source — please report it with the class names above.`);
118
+ }
92
119
  if (session.denseClassNames) root.walkRules((rule) => {
93
120
  if (!isUtilityRule(rule)) return;
94
121
  const transitionClasses = /* @__PURE__ */ new Set();
@@ -2693,8 +2720,11 @@ const createStaticCompilationSession = (denseClassNames = true) => {
2693
2720
  }).join(" ");
2694
2721
  },
2695
2722
  markClassUsed(className) {
2696
- const semantic = session.semanticClasses.get(className) ?? className;
2697
- session.usedClasses.add((0, _bamboocss_shared.esc)(semantic));
2723
+ for (const token of className.split(" ")) {
2724
+ if (!token) continue;
2725
+ const semantic = session.semanticClasses.get(token) ?? token;
2726
+ session.usedClasses.add((0, _bamboocss_shared.esc)(semantic));
2727
+ }
2698
2728
  }
2699
2729
  };
2700
2730
  return session;
package/dist/index.mjs CHANGED
@@ -59,6 +59,33 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
59
59
  removed = true;
60
60
  });
61
61
  }
62
+ if (prune) {
63
+ const present = /* @__PURE__ */ new Set();
64
+ root.walkRules((rule) => {
65
+ if (!isUtilityRule(rule)) return;
66
+ try {
67
+ selectorParser((selectors) => {
68
+ selectors.walkClasses((classNode) => {
69
+ present.add(classNode.toString().slice(1));
70
+ });
71
+ }).processSync(rule.selector);
72
+ } catch {}
73
+ });
74
+ const orphaned = [];
75
+ for (const className of session.usedClasses) {
76
+ if (/\s/.test(className)) {
77
+ orphaned.push(className);
78
+ continue;
79
+ }
80
+ if (!session.prunableClasses.has(className)) continue;
81
+ if (present.has(className)) continue;
82
+ orphaned.push(className);
83
+ }
84
+ if (orphaned.length) throw new Error(`bamboocss: ${orphaned.length} compiled class(es) have no rule in the emitted stylesheet. Elements carrying them would render unstyled.\n\n${truncateList(orphaned, {
85
+ unit: "class",
86
+ separator: "\n"
87
+ })}\n\nThis is a compiler bug rather than anything to fix in your source — please report it with the class names above.`);
88
+ }
62
89
  if (session.denseClassNames) root.walkRules((rule) => {
63
90
  if (!isUtilityRule(rule)) return;
64
91
  const transitionClasses = /* @__PURE__ */ new Set();
@@ -2663,8 +2690,11 @@ const createStaticCompilationSession = (denseClassNames = true) => {
2663
2690
  }).join(" ");
2664
2691
  },
2665
2692
  markClassUsed(className) {
2666
- const semantic = session.semanticClasses.get(className) ?? className;
2667
- session.usedClasses.add(esc(semantic));
2693
+ for (const token of className.split(" ")) {
2694
+ if (!token) continue;
2695
+ const semantic = session.semanticClasses.get(token) ?? token;
2696
+ session.usedClasses.add(esc(semantic));
2697
+ }
2668
2698
  }
2669
2699
  };
2670
2700
  return session;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.36.0",
3
+ "version": "1.36.1",
4
4
  "description": "Vite integration for Bamboo CSS",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -40,18 +40,18 @@
40
40
  "postcss": "8.5.26",
41
41
  "postcss-selector-parser": "7.1.5",
42
42
  "ts-morph": "28.0.0",
43
- "@bamboocss/config": "1.36.0",
44
- "@bamboocss/core": "1.36.0",
45
- "@bamboocss/extractor": "1.36.0",
46
- "@bamboocss/logger": "1.36.0",
47
- "@bamboocss/node": "1.36.0",
48
- "@bamboocss/shared": "1.36.0",
49
- "@bamboocss/types": "1.36.0"
43
+ "@bamboocss/config": "1.36.1",
44
+ "@bamboocss/extractor": "1.36.1",
45
+ "@bamboocss/logger": "1.36.1",
46
+ "@bamboocss/node": "1.36.1",
47
+ "@bamboocss/core": "1.36.1",
48
+ "@bamboocss/types": "1.36.1",
49
+ "@bamboocss/shared": "1.36.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.36.0"
54
+ "@bamboocss/fixture": "1.36.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"