mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
Fix SVG entry point handling with data URL and file emission
This commit is contained in:
1
chevron-down.svg
Normal file
1
chevron-down.svg
Normal 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 |
@@ -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
3
style.css
Normal file
@@ -0,0 +1,3 @@
|
||||
select {
|
||||
background-image: url("./chevron-down.svg");
|
||||
}
|
||||
@@ -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>`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user