diff --git a/test/bundler/css/wpt/background-computed.test.ts b/test/bundler/css/wpt/background-computed.test.ts index cd762d81b1..78cf1c35b7 100644 --- a/test/bundler/css/wpt/background-computed.test.ts +++ b/test/bundler/css/wpt/background-computed.test.ts @@ -16,7 +16,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` -/* ../../a.css */ +/* a.css */ h1 { ${property}: ${expected}; } diff --git a/test/bundler/css/wpt/color-computed-rgb.test.ts b/test/bundler/css/wpt/color-computed-rgb.test.ts index 61552d3fea..4743bb4ccd 100644 --- a/test/bundler/css/wpt/color-computed-rgb.test.ts +++ b/test/bundler/css/wpt/color-computed-rgb.test.ts @@ -16,7 +16,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` -/* ../../a.css */ +/* a.css */ h1 { color: ${expected}; } diff --git a/test/bundler/css/wpt/color-computed.test.ts b/test/bundler/css/wpt/color-computed.test.ts index b1a0731ee1..d71e647fef 100644 --- a/test/bundler/css/wpt/color-computed.test.ts +++ b/test/bundler/css/wpt/color-computed.test.ts @@ -15,7 +15,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` -/* ../../a.css */ +/* a.css */ h1 { color: ${expected}; } diff --git a/test/bundler/css/wpt/relative_color_out_of_gamut.test.ts b/test/bundler/css/wpt/relative_color_out_of_gamut.test.ts index 64669d3e18..18c5e65d2d 100644 --- a/test/bundler/css/wpt/relative_color_out_of_gamut.test.ts +++ b/test/bundler/css/wpt/relative_color_out_of_gamut.test.ts @@ -17,7 +17,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` -/* ../../a.css */ +/* a.css */ h1 { color: #00f942; } @@ -38,7 +38,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from lab(100 104.3 -50.9) r g b); } @@ -59,7 +59,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from lab(0 104.3 -50.9) r g b); } @@ -80,7 +80,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from lch(100 116 334) r g b); } @@ -101,7 +101,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from lch(0 116 334) r g b); } @@ -122,7 +122,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from oklab(1 .365 -.16) r g b); } @@ -143,7 +143,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from oklab(0 .365 -.16) r g b); } @@ -164,7 +164,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from oklch(1 .399 336.3) r g b); } @@ -185,7 +185,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: rgb(from oklch(0 .399 336.3) r g b); } @@ -206,7 +206,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: #00f942; } @@ -227,7 +227,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from lab(100 104.3 -50.9) h s l); } @@ -248,7 +248,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from lab(0 104.3 -50.9) h s l); } @@ -269,7 +269,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from lch(100 116 334) h s l); } @@ -290,7 +290,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from lch(0 116 334) h s l); } @@ -311,7 +311,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from oklab(1 .365 -.16) h s l); } @@ -332,7 +332,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from oklab(0 .365 -.16) h s l); } @@ -353,7 +353,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from oklch(1 .399 336.3) h s l); } @@ -374,7 +374,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hsl(from oklch(0 .399 336.3) h s l); } @@ -395,7 +395,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: #00f942; } @@ -416,7 +416,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from lab(100 104.3 -50.9) h w b); } @@ -437,7 +437,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from lab(0 104.3 -50.9) h w b); } @@ -458,7 +458,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from lch(100 116 334) h w b); } @@ -479,7 +479,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from lch(0 116 334) h w b); } @@ -500,7 +500,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from oklab(1 .365 -.16) h w b); } @@ -521,7 +521,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from oklab(0 .365 -.16) h w b); } @@ -542,7 +542,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from oklch(1 .399 336.3) h w b); } @@ -563,7 +563,7 @@ h1 { onAfterBundle(api) { api.expectFile("/out.css").toEqualIgnoringWhitespace(` - /* ../../a.css */ + /* a.css */ h1 { color: hwb(from oklch(0 .399 336.3) h w b); } diff --git a/test/bundler/expectBundled.ts b/test/bundler/expectBundled.ts index 13d9764c95..52a831568f 100644 --- a/test/bundler/expectBundled.ts +++ b/test/bundler/expectBundled.ts @@ -649,13 +649,18 @@ function expectBundled( return (async () => { // Prepare virtual files with dedent applied for strings, preserve binary content as-is + // Use relative paths (strip leading /) to get consistent path comments in CSS output const virtualFiles: Record = {}; for (const [file, contents] of Object.entries(files)) { - virtualFiles[file] = typeof contents === "string" ? dedent(contents) : contents; + const relativePath = file.startsWith("/") ? file.slice(1) : file; + virtualFiles[relativePath] = typeof contents === "string" ? dedent(contents) : contents; } + // Convert entrypoints to relative paths too + const relativeEntryPoints = entryPoints.map(ep => (ep.startsWith("/") ? ep.slice(1) : ep)); + const build = await Bun.build({ - entrypoints: entryPoints, + entrypoints: relativeEntryPoints, files: virtualFiles, target, format,