Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 765623e

Browse files
committed
feat: use pathToFileURL for filename in resolvePath
The resolvePath function now uses pathToFileURL to convert the filename to a URL. This change ensures that the filename is correctly handled as a URL when passed to resolvePath.
1 parent 8981591 commit 765623e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/css-module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import to from 'await-to-js';
44
import { transform } from 'lightningcss';
55
import MagicString from 'magic-string';
66
import type { StaticImport } from 'mlly';
7-
import { parseStaticImport, resolvePath } from 'mlly';
7+
import { parseStaticImport, pathToFileURL, resolvePath } from 'mlly';
88
import { stringToUint8Array, uint8ArrayToString } from 'uint8array-extras';
99

1010
type getCssModuleImportsProps = {
@@ -43,7 +43,9 @@ export async function getCssModuleImports(
4343
return { path: s.toString(), defaultImport, imp };
4444
}
4545

46-
const [err, resolved] = await to(resolvePath(specifier, { url: filename }));
46+
const [err, resolved] = await to(resolvePath(specifier, {
47+
url: filename == null ? undefined : pathToFileURL(filename),
48+
}));
4749

4850
if (err != null) {
4951
console.error(err.message);

0 commit comments

Comments
 (0)