@bamboocss/vite 1.35.3 → 1.35.5
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 +15 -4
- package/dist/index.mjs +15 -4
- package/package.json +9 -9
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
|
|
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
|
|
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
|
}
|
|
@@ -2382,8 +2392,9 @@ const foldSource = (options) => {
|
|
|
2382
2392
|
if (!definition || definition.getSourceFile() !== sourceFile) continue;
|
|
2383
2393
|
const nameNode = definition.getFirstAncestorByKind(ts_morph.SyntaxKind.VariableDeclaration)?.getNameNode();
|
|
2384
2394
|
if (!nameNode || !ts_morph.Node.isIdentifier(nameNode)) continue;
|
|
2385
|
-
|
|
2386
|
-
|
|
2395
|
+
const references = nameNode.findReferencesAsNodes();
|
|
2396
|
+
if (skipped.filter((item) => SURVIVES_TO_RUNTIME.has(item.reason) && item.end > item.start).some((item) => references.some((ref) => ref.getStart() >= item.start && ref.getStart() < item.end))) continue;
|
|
2397
|
+
const survivor = references.find((ref) => !applied.some(([from, to]) => ref.getStart() >= from && ref.getStart() < to));
|
|
2387
2398
|
if (!survivor) continue;
|
|
2388
2399
|
const survivorFile = survivor.getSourceFile();
|
|
2389
2400
|
const foreign = survivorFile !== sourceFile;
|
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
|
|
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
|
|
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
|
}
|
|
@@ -2352,8 +2362,9 @@ const foldSource = (options) => {
|
|
|
2352
2362
|
if (!definition || definition.getSourceFile() !== sourceFile) continue;
|
|
2353
2363
|
const nameNode = definition.getFirstAncestorByKind(SyntaxKind.VariableDeclaration)?.getNameNode();
|
|
2354
2364
|
if (!nameNode || !Node.isIdentifier(nameNode)) continue;
|
|
2355
|
-
|
|
2356
|
-
|
|
2365
|
+
const references = nameNode.findReferencesAsNodes();
|
|
2366
|
+
if (skipped.filter((item) => SURVIVES_TO_RUNTIME.has(item.reason) && item.end > item.start).some((item) => references.some((ref) => ref.getStart() >= item.start && ref.getStart() < item.end))) continue;
|
|
2367
|
+
const survivor = references.find((ref) => !applied.some(([from, to]) => ref.getStart() >= from && ref.getStart() < to));
|
|
2357
2368
|
if (!survivor) continue;
|
|
2358
2369
|
const survivorFile = survivor.getSourceFile();
|
|
2359
2370
|
const foreign = survivorFile !== sourceFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/vite",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.5",
|
|
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.
|
|
44
|
-
"@bamboocss/
|
|
45
|
-
"@bamboocss/
|
|
46
|
-
"@bamboocss/
|
|
47
|
-
"@bamboocss/
|
|
48
|
-
"@bamboocss/
|
|
49
|
-
"@bamboocss/types": "1.35.
|
|
43
|
+
"@bamboocss/config": "1.35.5",
|
|
44
|
+
"@bamboocss/core": "1.35.5",
|
|
45
|
+
"@bamboocss/extractor": "1.35.5",
|
|
46
|
+
"@bamboocss/shared": "1.35.5",
|
|
47
|
+
"@bamboocss/logger": "1.35.5",
|
|
48
|
+
"@bamboocss/node": "1.35.5",
|
|
49
|
+
"@bamboocss/types": "1.35.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
53
53
|
"vite": "7.2.6",
|
|
54
|
-
"@bamboocss/fixture": "1.35.
|
|
54
|
+
"@bamboocss/fixture": "1.35.5"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"vite": ">=5"
|