From d7cb92fff3f56ba57dad450a789bfb8ced7ee176 Mon Sep 17 00:00:00 2001 From: galargh Date: Fri, 27 Dec 2024 13:17:56 +0100 Subject: [PATCH] fix: make the result of parsing node direct imports system aware --- .../solidity/build-system/resolver/dependency-resolver.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts index e1bbdfcfc9..7fa91b0e6c 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts @@ -1318,6 +1318,8 @@ export class ResolverImplementation implements Resolver { path: string; } | undefined { + + // NOTE: We assume usage of path.posix.sep in the direct import const directImportPattern = /^(?(?:@[a-z0-9-~._]+\/)?[a-z0-9-~][a-z0-9-~._]*)\/(?.*)$/; @@ -1332,7 +1334,11 @@ export class ResolverImplementation implements Resolver { "Groups should be defined because they are part of the pattern", ); - return { package: match.groups.package, path: match.groups.path }; + // NOTE: We replace path.posix.sep with path.sep here so that the returned + // path can be later safely treated as a system aware path + const parsedPath = match.groups.path.replaceAll(path.posix.sep, path.sep); + + return { package: match.groups.package, path: parsedPath }; } }