@bamboocss/vite 1.35.3 → 1.35.4

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
@@ -170,6 +170,16 @@ const replaceAssetReferences = (bundle, previous, next, sourcemap) => {
170
170
  }
171
171
  };
172
172
  /**
173
+ * Could this bundle entry be the generated stylesheet?
174
+ *
175
+ * The filename is checked before the bytes because the alternative decodes every asset in the
176
+ * bundle to a UTF-8 string in order to search it — fonts, images and sourcemaps included. On an
177
+ * app with a large asset graph that is seconds of decode and a lot of garbage, twice over, to
178
+ * answer a question the extension already answers. The marker is a CSS custom property, so it
179
+ * cannot occur anywhere but CSS.
180
+ */
181
+ const carriesGeneratedCss = (output) => output.type === "asset" && output.fileName.endsWith(".css");
182
+ /**
173
183
  * Prune and rename compiler-owned CSS, then give changed assets a hash of their final bytes.
174
184
  *
175
185
  * Rollup has already expanded `[hash]` when `generateBundle` runs. Mutating only `source`
@@ -179,7 +189,7 @@ const replaceAssetReferences = (bundle, previous, next, sourcemap) => {
179
189
  const optimizeStaticCssAssets = (bundle, session, options = {}) => {
180
190
  const { rename = true } = options;
181
191
  for (const [bundleName, output] of Object.entries(bundle)) {
182
- if (output.type !== "asset") continue;
192
+ if (!carriesGeneratedCss(output)) continue;
183
193
  const source = typeof output.source === "string" ? output.source : Buffer.from(output.source).toString();
184
194
  if (!source.includes("--made-with-bamboo")) continue;
185
195
  const optimized = pruneStaticCss(source, session);
@@ -298,7 +308,7 @@ const bamboocssCss = (options) => {
298
308
  optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset && !rolldown });
299
309
  if (!session.transformedFiles.size) return;
300
310
  if (!Object.values(bundle).some((output) => {
301
- if (output.type !== "asset") return false;
311
+ if (!carriesGeneratedCss(output)) return false;
302
312
  return (typeof output.source === "string" ? output.source : Buffer.from(output.source).toString()).includes("--made-with-bamboo");
303
313
  })) throw new Error(`bamboocss: ${session.transformedFiles.size} module(s) were compiled to Bamboo class values, but no emitted asset carries the generated stylesheet. The build would ship unstyled.\n\nThis happens when another plugin, or the bundler itself, drops or replaces the CSS asset after it is emitted. If you are on Rolldown, report this — the rename that used to cause it is already disabled there. Otherwise look for a plugin running in \`generateBundle\` that rewrites CSS assets.`);
304
314
  }
package/dist/index.mjs CHANGED
@@ -140,6 +140,16 @@ const replaceAssetReferences = (bundle, previous, next, sourcemap) => {
140
140
  }
141
141
  };
142
142
  /**
143
+ * Could this bundle entry be the generated stylesheet?
144
+ *
145
+ * The filename is checked before the bytes because the alternative decodes every asset in the
146
+ * bundle to a UTF-8 string in order to search it — fonts, images and sourcemaps included. On an
147
+ * app with a large asset graph that is seconds of decode and a lot of garbage, twice over, to
148
+ * answer a question the extension already answers. The marker is a CSS custom property, so it
149
+ * cannot occur anywhere but CSS.
150
+ */
151
+ const carriesGeneratedCss = (output) => output.type === "asset" && output.fileName.endsWith(".css");
152
+ /**
143
153
  * Prune and rename compiler-owned CSS, then give changed assets a hash of their final bytes.
144
154
  *
145
155
  * Rollup has already expanded `[hash]` when `generateBundle` runs. Mutating only `source`
@@ -149,7 +159,7 @@ const replaceAssetReferences = (bundle, previous, next, sourcemap) => {
149
159
  const optimizeStaticCssAssets = (bundle, session, options = {}) => {
150
160
  const { rename = true } = options;
151
161
  for (const [bundleName, output] of Object.entries(bundle)) {
152
- if (output.type !== "asset") continue;
162
+ if (!carriesGeneratedCss(output)) continue;
153
163
  const source = typeof output.source === "string" ? output.source : Buffer.from(output.source).toString();
154
164
  if (!source.includes("--made-with-bamboo")) continue;
155
165
  const optimized = pruneStaticCss(source, session);
@@ -268,7 +278,7 @@ const bamboocssCss = (options) => {
268
278
  optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset && !rolldown });
269
279
  if (!session.transformedFiles.size) return;
270
280
  if (!Object.values(bundle).some((output) => {
271
- if (output.type !== "asset") return false;
281
+ if (!carriesGeneratedCss(output)) return false;
272
282
  return (typeof output.source === "string" ? output.source : Buffer.from(output.source).toString()).includes("--made-with-bamboo");
273
283
  })) throw new Error(`bamboocss: ${session.transformedFiles.size} module(s) were compiled to Bamboo class values, but no emitted asset carries the generated stylesheet. The build would ship unstyled.\n\nThis happens when another plugin, or the bundler itself, drops or replaces the CSS asset after it is emitted. If you are on Rolldown, report this — the rename that used to cause it is already disabled there. Otherwise look for a plugin running in \`generateBundle\` that rewrites CSS assets.`);
274
284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.35.3",
3
+ "version": "1.35.4",
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.35.3",
44
- "@bamboocss/extractor": "1.35.3",
45
- "@bamboocss/logger": "1.35.3",
46
- "@bamboocss/node": "1.35.3",
47
- "@bamboocss/core": "1.35.3",
48
- "@bamboocss/shared": "1.35.3",
49
- "@bamboocss/types": "1.35.3"
43
+ "@bamboocss/config": "1.35.4",
44
+ "@bamboocss/core": "1.35.4",
45
+ "@bamboocss/extractor": "1.35.4",
46
+ "@bamboocss/logger": "1.35.4",
47
+ "@bamboocss/node": "1.35.4",
48
+ "@bamboocss/types": "1.35.4",
49
+ "@bamboocss/shared": "1.35.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.35.3"
54
+ "@bamboocss/fixture": "1.35.4"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"