@bamboocss/vite 1.37.4 → 1.37.6

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
@@ -43,6 +43,19 @@ let ts_morph = require("ts-morph");
43
43
  /** The generated declaration that identifies a Bamboo stylesheet after minification. */
44
44
  const SENTINEL = "--made-with-bamboo";
45
45
  /**
46
+ * A class name with its CSS escapes removed, which is the only spelling both sides agree on.
47
+ *
48
+ * The same class reaches the stylesheet either escaped or not — `--bottom-mask-size_16px` is a
49
+ * valid selector as written, since a CSS ident may begin with `--`, while `esc` produces the
50
+ * escaped `\--…` form that reachability keys are stored in. Comparing raw spellings therefore
51
+ * missed a rule written the other way, and pruning removed an atom whose rule was in the sheet
52
+ * all along. It could only ever affect names needing an escape, which is why it presented as
53
+ * every custom property and vendor-prefixed declaration losing its rule at once.
54
+ *
55
+ * Stripping backslashes is unambiguous here: a semantic atom name never contains a literal one.
56
+ */
57
+ const bare = (className) => className.replaceAll("\\", "");
58
+ /**
46
59
  * Remove source-graph atoms no transformed module can emit.
47
60
  *
48
61
  * `prunableClasses` contains only atoms extracted from the source graph. Explicit `staticCss`
@@ -52,6 +65,8 @@ const SENTINEL = "--made-with-bamboo";
52
65
  const pruneStaticCss = (css, session, { prune = true } = {}) => {
53
66
  if (!css.includes(SENTINEL)) return css;
54
67
  const root = postcss.default.parse(css);
68
+ const prunable = new Set([...session.prunableClasses].map(bare));
69
+ const used = new Set([...session.usedClasses].map(bare));
55
70
  const isUtilityRule = (rule) => {
56
71
  let parent = rule.parent;
57
72
  while (parent) {
@@ -69,7 +84,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
69
84
  try {
70
85
  (0, postcss_selector_parser.default)((selectors) => {
71
86
  selectors.walkClasses((classNode) => {
72
- classes.add(classNode.toString().slice(1));
87
+ classes.add(bare(classNode.toString().slice(1)));
73
88
  });
74
89
  }).processSync(rule.selector);
75
90
  } catch {
@@ -77,7 +92,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
77
92
  }
78
93
  if (classes.size !== 1) return;
79
94
  const [className] = classes;
80
- if (!className || !session.prunableClasses.has(className) || session.usedClasses.has(className)) return;
95
+ if (!className || !prunable.has(className) || used.has(className)) return;
81
96
  rule.remove();
82
97
  });
83
98
  let removed = true;
@@ -96,7 +111,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
96
111
  try {
97
112
  (0, postcss_selector_parser.default)((selectors) => {
98
113
  selectors.walkClasses((classNode) => {
99
- present.add(classNode.toString().slice(1));
114
+ present.add(bare(classNode.toString().slice(1)));
100
115
  });
101
116
  }).processSync(rule.selector);
102
117
  } catch {}
@@ -107,8 +122,8 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
107
122
  orphaned.push(className);
108
123
  continue;
109
124
  }
110
- if (!session.prunableClasses.has(className)) continue;
111
- if (present.has(className)) continue;
125
+ if (!prunable.has(bare(className))) continue;
126
+ if (present.has(bare(className))) continue;
112
127
  orphaned.push(className);
113
128
  }
114
129
  if (orphaned.length) {
package/dist/index.mjs CHANGED
@@ -13,6 +13,19 @@ import { Node, SyntaxKind, VariableDeclarationKind } from "ts-morph";
13
13
  /** The generated declaration that identifies a Bamboo stylesheet after minification. */
14
14
  const SENTINEL = "--made-with-bamboo";
15
15
  /**
16
+ * A class name with its CSS escapes removed, which is the only spelling both sides agree on.
17
+ *
18
+ * The same class reaches the stylesheet either escaped or not — `--bottom-mask-size_16px` is a
19
+ * valid selector as written, since a CSS ident may begin with `--`, while `esc` produces the
20
+ * escaped `\--…` form that reachability keys are stored in. Comparing raw spellings therefore
21
+ * missed a rule written the other way, and pruning removed an atom whose rule was in the sheet
22
+ * all along. It could only ever affect names needing an escape, which is why it presented as
23
+ * every custom property and vendor-prefixed declaration losing its rule at once.
24
+ *
25
+ * Stripping backslashes is unambiguous here: a semantic atom name never contains a literal one.
26
+ */
27
+ const bare = (className) => className.replaceAll("\\", "");
28
+ /**
16
29
  * Remove source-graph atoms no transformed module can emit.
17
30
  *
18
31
  * `prunableClasses` contains only atoms extracted from the source graph. Explicit `staticCss`
@@ -22,6 +35,8 @@ const SENTINEL = "--made-with-bamboo";
22
35
  const pruneStaticCss = (css, session, { prune = true } = {}) => {
23
36
  if (!css.includes(SENTINEL)) return css;
24
37
  const root = postcss.parse(css);
38
+ const prunable = new Set([...session.prunableClasses].map(bare));
39
+ const used = new Set([...session.usedClasses].map(bare));
25
40
  const isUtilityRule = (rule) => {
26
41
  let parent = rule.parent;
27
42
  while (parent) {
@@ -39,7 +54,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
39
54
  try {
40
55
  selectorParser((selectors) => {
41
56
  selectors.walkClasses((classNode) => {
42
- classes.add(classNode.toString().slice(1));
57
+ classes.add(bare(classNode.toString().slice(1)));
43
58
  });
44
59
  }).processSync(rule.selector);
45
60
  } catch {
@@ -47,7 +62,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
47
62
  }
48
63
  if (classes.size !== 1) return;
49
64
  const [className] = classes;
50
- if (!className || !session.prunableClasses.has(className) || session.usedClasses.has(className)) return;
65
+ if (!className || !prunable.has(className) || used.has(className)) return;
51
66
  rule.remove();
52
67
  });
53
68
  let removed = true;
@@ -66,7 +81,7 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
66
81
  try {
67
82
  selectorParser((selectors) => {
68
83
  selectors.walkClasses((classNode) => {
69
- present.add(classNode.toString().slice(1));
84
+ present.add(bare(classNode.toString().slice(1)));
70
85
  });
71
86
  }).processSync(rule.selector);
72
87
  } catch {}
@@ -77,8 +92,8 @@ const pruneStaticCss = (css, session, { prune = true } = {}) => {
77
92
  orphaned.push(className);
78
93
  continue;
79
94
  }
80
- if (!session.prunableClasses.has(className)) continue;
81
- if (present.has(className)) continue;
95
+ if (!prunable.has(bare(className))) continue;
96
+ if (present.has(bare(className))) continue;
82
97
  orphaned.push(className);
83
98
  }
84
99
  if (orphaned.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.37.4",
3
+ "version": "1.37.6",
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.37.4",
44
- "@bamboocss/core": "1.37.4",
45
- "@bamboocss/extractor": "1.37.4",
46
- "@bamboocss/node": "1.37.4",
47
- "@bamboocss/logger": "1.37.4",
48
- "@bamboocss/shared": "1.37.4",
49
- "@bamboocss/types": "1.37.4"
43
+ "@bamboocss/config": "1.37.6",
44
+ "@bamboocss/extractor": "1.37.6",
45
+ "@bamboocss/core": "1.37.6",
46
+ "@bamboocss/node": "1.37.6",
47
+ "@bamboocss/logger": "1.37.6",
48
+ "@bamboocss/shared": "1.37.6",
49
+ "@bamboocss/types": "1.37.6"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.37.4"
54
+ "@bamboocss/fixture": "1.37.6"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"