Skip to content

Commit e733d42

Browse files
committed
Fix Windows path resolution in inline-raw-files plugin
Use path.resolve with dirname instead of constructing a file:// URL, which mishandled Windows drive letters (file://C:/... treats C: as hostname, dropping the drive from .pathname). path.resolve works correctly on all platforms and avoids URL encoding of special chars. Like a goose finding its way home regardless of weather, the path resolver now navigates Windows and Unix waters alike.
1 parent 2f6bdec commit e733d42

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tsdown.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFileSync } from 'node:fs';
2+
import { dirname, resolve } from 'node:path';
23
import { defineConfig } from 'tsdown';
34
import type { Plugin } from 'rolldown';
45

@@ -9,7 +10,7 @@ function inlineRawFiles(): Plugin {
910
// Redirect .css imports to a virtual .cssraw ID so rolldown's
1011
// native CSS handling doesn't extract them into separate files.
1112
if (source.endsWith('.css') && importer) {
12-
const resolved = new URL(source, 'file://' + importer).pathname;
13+
const resolved = resolve(dirname(importer), source);
1314
return { id: resolved + '.cssraw' };
1415
}
1516
},

0 commit comments

Comments
 (0)