@bamboocss/vite 1.37.0 → 1.37.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
@@ -211,22 +211,23 @@ const carriesGeneratedCss = (output) => output.type === "asset" && output.fileNa
211
211
  */
212
212
  const optimizeStaticCssAssets = (bundle, session, options = {}) => {
213
213
  const { rename = true } = options;
214
- for (const [bundleName, output] of Object.entries(bundle)) {
214
+ for (const output of Object.values(bundle)) {
215
215
  if (!carriesGeneratedCss(output)) continue;
216
216
  const source = typeof output.source === "string" ? output.source : Buffer.from(output.source).toString();
217
217
  if (!source.includes("--made-with-bamboo")) continue;
218
218
  const optimized = pruneStaticCss(source, session);
219
219
  output.source = optimized;
220
220
  if (optimized === source) continue;
221
- if (!rename) continue;
221
+ if (!rename) {
222
+ output.source = source;
223
+ continue;
224
+ }
222
225
  const nextName = output.fileName.replace(/\.css$/, `.b-${(0, _bamboocss_shared.toHash)(optimized)}.css`);
223
226
  if (nextName === output.fileName) continue;
224
227
  if (bundle[nextName] && bundle[nextName] !== output) throw new Error(`bamboocss: final CSS asset name collision at ${JSON.stringify(nextName)}.`);
225
228
  const previous = output.fileName;
226
229
  output.fileName = nextName;
227
230
  replaceAssetReferences(bundle, previous, nextName, session.sourcemap);
228
- delete bundle[bundleName];
229
- bundle[nextName] = output;
230
231
  }
231
232
  };
232
233
  /**
@@ -332,8 +333,7 @@ const bamboocssCss = (options) => {
332
333
  generateBundle: {
333
334
  order: "post",
334
335
  handler(_, bundle) {
335
- const rolldown = Boolean(this.meta?.rolldownVersion);
336
- optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset && !rolldown });
336
+ optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset });
337
337
  if (!session.transformedFiles.size) return;
338
338
  if (!Object.values(bundle).some((output) => {
339
339
  if (!carriesGeneratedCss(output)) return false;
package/dist/index.d.cts CHANGED
@@ -39,17 +39,15 @@ interface BambooVitePluginOptions {
39
39
  /**
40
40
  * Give the pruned stylesheet a final name derived from its own bytes.
41
41
  *
42
- * Rollup expands `[hash]` before `generateBundle`, so pruning after it can leave two
43
- * different reachable subsets under one CDN key. Renaming closes that, at the cost of
44
- * replacing an entry in the output bundle — which not every consumer of the bundle
45
- * tolerates. Rolldown drops the asset outright (detected automatically, no flag needed),
46
- * and a framework that relocates assets itself, such as react-router's SSR build, can
47
- * lose track of the new name.
42
+ * Rollup and Rolldown both expand `[hash]` before `generateBundle`, so pruning after it can
43
+ * leave two different reachable subsets under one CDN key. Renaming the pruned stylesheet to
44
+ * a hash of its own bytes closes that.
48
45
  *
49
- * Turning it off keeps the pruned bytes and Vite's own content hash. That hash is computed
50
- * before pruning, so it stops describing the file exactly; in practice it still changes
51
- * whenever the extracted CSS does, and only a change that alters *reachability alone*
52
- * can now reuse a key. Prefer that over an asset your framework cannot find.
46
+ * Turning it off does not merely skip the rename it skips the pruning with it. The two are
47
+ * one operation: pruned bytes under a name describing the unpruned ones is how a stale
48
+ * stylesheet outlives a deploy, which is worse than shipping a larger sheet. Reach for this
49
+ * only when something downstream cannot follow a renamed asset, and expect the full
50
+ * extracted stylesheet when you do.
53
51
  *
54
52
  * @default true
55
53
  */
package/dist/index.d.mts CHANGED
@@ -39,17 +39,15 @@ interface BambooVitePluginOptions {
39
39
  /**
40
40
  * Give the pruned stylesheet a final name derived from its own bytes.
41
41
  *
42
- * Rollup expands `[hash]` before `generateBundle`, so pruning after it can leave two
43
- * different reachable subsets under one CDN key. Renaming closes that, at the cost of
44
- * replacing an entry in the output bundle — which not every consumer of the bundle
45
- * tolerates. Rolldown drops the asset outright (detected automatically, no flag needed),
46
- * and a framework that relocates assets itself, such as react-router's SSR build, can
47
- * lose track of the new name.
42
+ * Rollup and Rolldown both expand `[hash]` before `generateBundle`, so pruning after it can
43
+ * leave two different reachable subsets under one CDN key. Renaming the pruned stylesheet to
44
+ * a hash of its own bytes closes that.
48
45
  *
49
- * Turning it off keeps the pruned bytes and Vite's own content hash. That hash is computed
50
- * before pruning, so it stops describing the file exactly; in practice it still changes
51
- * whenever the extracted CSS does, and only a change that alters *reachability alone*
52
- * can now reuse a key. Prefer that over an asset your framework cannot find.
46
+ * Turning it off does not merely skip the rename it skips the pruning with it. The two are
47
+ * one operation: pruned bytes under a name describing the unpruned ones is how a stale
48
+ * stylesheet outlives a deploy, which is worse than shipping a larger sheet. Reach for this
49
+ * only when something downstream cannot follow a renamed asset, and expect the full
50
+ * extracted stylesheet when you do.
53
51
  *
54
52
  * @default true
55
53
  */
package/dist/index.mjs CHANGED
@@ -181,22 +181,23 @@ const carriesGeneratedCss = (output) => output.type === "asset" && output.fileNa
181
181
  */
182
182
  const optimizeStaticCssAssets = (bundle, session, options = {}) => {
183
183
  const { rename = true } = options;
184
- for (const [bundleName, output] of Object.entries(bundle)) {
184
+ for (const output of Object.values(bundle)) {
185
185
  if (!carriesGeneratedCss(output)) continue;
186
186
  const source = typeof output.source === "string" ? output.source : Buffer.from(output.source).toString();
187
187
  if (!source.includes("--made-with-bamboo")) continue;
188
188
  const optimized = pruneStaticCss(source, session);
189
189
  output.source = optimized;
190
190
  if (optimized === source) continue;
191
- if (!rename) continue;
191
+ if (!rename) {
192
+ output.source = source;
193
+ continue;
194
+ }
192
195
  const nextName = output.fileName.replace(/\.css$/, `.b-${toHash(optimized)}.css`);
193
196
  if (nextName === output.fileName) continue;
194
197
  if (bundle[nextName] && bundle[nextName] !== output) throw new Error(`bamboocss: final CSS asset name collision at ${JSON.stringify(nextName)}.`);
195
198
  const previous = output.fileName;
196
199
  output.fileName = nextName;
197
200
  replaceAssetReferences(bundle, previous, nextName, session.sourcemap);
198
- delete bundle[bundleName];
199
- bundle[nextName] = output;
200
201
  }
201
202
  };
202
203
  /**
@@ -302,8 +303,7 @@ const bamboocssCss = (options) => {
302
303
  generateBundle: {
303
304
  order: "post",
304
305
  handler(_, bundle) {
305
- const rolldown = Boolean(this.meta?.rolldownVersion);
306
- optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset && !rolldown });
306
+ optimizeStaticCssAssets(bundle, session, { rename: renameCssAsset });
307
307
  if (!session.transformedFiles.size) return;
308
308
  if (!Object.values(bundle).some((output) => {
309
309
  if (!carriesGeneratedCss(output)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.37.0",
3
+ "version": "1.37.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.37.0",
44
- "@bamboocss/core": "1.37.0",
45
- "@bamboocss/extractor": "1.37.0",
46
- "@bamboocss/logger": "1.37.0",
47
- "@bamboocss/node": "1.37.0",
48
- "@bamboocss/shared": "1.37.0",
49
- "@bamboocss/types": "1.37.0"
43
+ "@bamboocss/config": "1.37.1",
44
+ "@bamboocss/extractor": "1.37.1",
45
+ "@bamboocss/logger": "1.37.1",
46
+ "@bamboocss/node": "1.37.1",
47
+ "@bamboocss/core": "1.37.1",
48
+ "@bamboocss/shared": "1.37.1",
49
+ "@bamboocss/types": "1.37.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.37.0"
54
+ "@bamboocss/fixture": "1.37.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"