Compare commits

...

1 Commits

Author SHA1 Message Date
Cursor Agent
71d600aa62 Fix SVG entry point handling with data URL and file emission 2025-06-10 05:07:35 +00:00
4 changed files with 32 additions and 0 deletions

1
chevron-down.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>

After

Width:  |  Height:  |  Size: 271 B

View File

@@ -195,6 +195,10 @@ pub noinline fn computeChunks(
const entry_bits: *const AutoBitSet = &file_entry_bits[source_index.get()];
if (css_reprs[source_index.get()] != null) continue;
// Check if this file has a JavaScript-like loader
const loader = loaders[source_index.get()];
if (!loader.isJavaScriptLike()) continue;
if (this.graph.code_splitting) {
const js_chunk_key = try temp_allocator.dupe(u8, entry_bits.bytes(this.graph.entry_points.len));
var js_chunk_entry = try js_chunks.getOrPut(js_chunk_key);

3
style.css Normal file
View File

@@ -0,0 +1,3 @@
select {
background-image: url("./chevron-down.svg");
}

View File

@@ -2358,3 +2358,27 @@ for (const backend of ["api", "cli"] as const) {
});
});
}
// Fixes #20278
itBundled("edgecase/SvgEntryPointAndDataUrl", {
files: {
"/style.css": `select {
background-image: url("./chevron-down.svg");
}`,
"/chevron-down.svg": `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>`,
},
entryPoints: ["/style.css", "/chevron-down.svg"],
outdir: "/out",
onAfterBundle(api) {
// The CSS should inline the SVG as a data URL
api.expectFile("/out/style.css").toContain("background-image: url(");
api.expectFile("/out/style.css").toContain("data:image/svg+xml");
// The SVG should also be emitted as a separate file
api
.expectFile("/out/chevron-down.svg")
.toEqual(
`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>`,
);
},
});