Skip to content

Commit

Permalink
fix(babel-plugin): import resolve should respect windows system
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Jan 13, 2025
1 parent 06ffe7e commit bcd5c74
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/babel-plugin/src/utils/state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,11 @@ const filePathResolver = (
// Try to resolve relative paths as is
if (importPathStr.startsWith('.')) {
try {
return moduleResolve(importPathStr, url.pathToFileURL(sourceFilePath))
.pathname;
const { href } = moduleResolve(
importPathStr,
url.pathToFileURL(sourceFilePath),
);
return url.fileURLToPath(href);
} catch {
continue;
}
Expand All @@ -691,8 +694,11 @@ const filePathResolver = (
const allAliases = possibleAliasedPaths(importPathStr, aliases);
for (const possiblePath of allAliases) {
try {
return moduleResolve(possiblePath, url.pathToFileURL(sourceFilePath))
.pathname;
const { href } = moduleResolve(
possiblePath,
url.pathToFileURL(sourceFilePath),
);
return url.fileURLToPath(href);
} catch {
continue;
}
Expand Down

0 comments on commit bcd5c74

Please sign in to comment.