@@ -1786,3 +1786,89 @@ func TestLoaderTextUTF8BOM(t *testing.T) {
17861786 },
17871787 })
17881788}
1789+
1790+ // See: https://github.com/evanw/esbuild/issues/4075
1791+ func TestLoaderInlineSourceMapAbsolutePathIssue4075Unix (t * testing.T ) {
1792+ urlEncodedUnix := "%22file%3A%2F%2F%2Fout%2Fsrc%2Fstyles1.scss%22" // file:///out/src/styles1.scss
1793+ pathEncodedUnix := "%22%2Fout%2Fsrc%2Fstyles2.scss%22" // /out/src/styles2.scss
1794+
1795+ loader_suite .expectBundledUnix (t , bundled {
1796+ files : map [string ]string {
1797+ "/home/user/project/src/entry.css" : `
1798+ @import "./styles1.css";
1799+ @import "./styles2.css";
1800+ ` ,
1801+ "/home/user/project/src/styles1.css" : `/* You can add global styles to this file, and also import other style files */
1802+ * {
1803+ content: "foo";
1804+ }
1805+
1806+ /*# sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22:3,` +
1807+ `%22sourceRoot%22:%22%22,%22sources%22:%5B` + urlEncodedUnix + `%5D,%22n` +
1808+ `ames%22:%5B%5D,%22mappings%22:%22AAAA;AACA;EACE,SAAS%22,%22file%22:%22o` +
1809+ `ut%22,%22sourcesContent%22:%5B%22/*%20You%20can%20add%20global%20styles` +
1810+ `%20to%20this%20file,%20and%20also%20import%20other%20style%20files%20%2` +
1811+ `A/%5Cn*%20%7B%5Cn%20%20content:%20%5C%22foo%5C%22%5Cn%7D%5Cn%22%5D%7D */` ,
1812+ "/home/user/project/src/styles2.css" : `/* You can add global styles to this file, and also import other style files */
1813+ * {
1814+ content: "bar";
1815+ }
1816+
1817+ /*# sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22:3,` +
1818+ `%22sourceRoot%22:%22%22,%22sources%22:%5B` + pathEncodedUnix + `%5D,%22` +
1819+ `names%22:%5B%5D,%22mappings%22:%22AAAA;AACA;EACE,SAAS%22,%22file%22:%22` +
1820+ `out%22,%22sourcesContent%22:%5B%22/*%20You%20can%20add%20global%20style` +
1821+ `s%20to%20this%20file,%20and%20also%20import%20other%20style%20files%20%` +
1822+ `2A/%5Cn*%20%7B%5Cn%20%20content:%20%5C%22bar%5C%22%5Cn%7D%5Cn%22%5D%7D */` ,
1823+ },
1824+ entryPaths : []string {"/home/user/project/src/entry.css" },
1825+ options : config.Options {
1826+ Mode : config .ModeBundle ,
1827+ SourceMap : config .SourceMapLinkedWithComment ,
1828+ AbsOutputDir : "/out" ,
1829+ },
1830+ })
1831+ }
1832+
1833+ // See: https://github.com/evanw/esbuild/issues/4075
1834+ func TestLoaderInlineSourceMapAbsolutePathIssue4075Windows (t * testing.T ) {
1835+ urlEncodedWin := "%22file%3A%2F%2F%2FC%3A%2Fout%2Fsrc%2Fstyles1.scss%22" // file:///C:/out/src/styles1.scss
1836+ pathEncodedWin := "%22C%3A%5C%5Cout%5C%5Csrc%5C%5Cstyles2.scss%22" // C:\out\src\styles2.scss
1837+
1838+ loader_suite .expectBundledWindows (t , bundled {
1839+ files : map [string ]string {
1840+ "/home/user/project/src/entry.css" : `
1841+ @import "./styles1.css";
1842+ @import "./styles2.css";
1843+ ` ,
1844+ "/home/user/project/src/styles1.css" : `/* You can add global styles to this file, and also import other style files */
1845+ * {
1846+ content: "foo";
1847+ }
1848+
1849+ /*# sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22:3,` +
1850+ `%22sourceRoot%22:%22%22,%22sources%22:%5B` + urlEncodedWin + `%5D,%22n` +
1851+ `ames%22:%5B%5D,%22mappings%22:%22AAAA;AACA;EACE,SAAS%22,%22file%22:%22o` +
1852+ `ut%22,%22sourcesContent%22:%5B%22/*%20You%20can%20add%20global%20styles` +
1853+ `%20to%20this%20file,%20and%20also%20import%20other%20style%20files%20%2` +
1854+ `A/%5Cn*%20%7B%5Cn%20%20content:%20%5C%22foo%5C%22%5Cn%7D%5Cn%22%5D%7D */` ,
1855+ "/home/user/project/src/styles2.css" : `/* You can add global styles to this file, and also import other style files */
1856+ * {
1857+ content: "bar";
1858+ }
1859+
1860+ /*# sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22:3,` +
1861+ `%22sourceRoot%22:%22%22,%22sources%22:%5B` + pathEncodedWin + `%5D,%22` +
1862+ `names%22:%5B%5D,%22mappings%22:%22AAAA;AACA;EACE,SAAS%22,%22file%22:%22` +
1863+ `out%22,%22sourcesContent%22:%5B%22/*%20You%20can%20add%20global%20style` +
1864+ `s%20to%20this%20file,%20and%20also%20import%20other%20style%20files%20%` +
1865+ `2A/%5Cn*%20%7B%5Cn%20%20content:%20%5C%22bar%5C%22%5Cn%7D%5Cn%22%5D%7D */` ,
1866+ },
1867+ entryPaths : []string {"/home/user/project/src/entry.css" },
1868+ options : config.Options {
1869+ Mode : config .ModeBundle ,
1870+ SourceMap : config .SourceMapLinkedWithComment ,
1871+ AbsOutputDir : "/out" ,
1872+ },
1873+ })
1874+ }
0 commit comments