From 0b8ce3f2c9b540dbd1c9ba21354f8bf850e72a96 Mon Sep 17 00:00:00 2001 From: alvarius Date: Sun, 24 Sep 2023 13:13:36 +0100 Subject: [PATCH] fix(common): always import relative sol files from ./ (#1585) --- .changeset/fresh-scissors-unite.md | 5 +++++ packages/common/src/codegen/utils/loadUserTypesFile.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/fresh-scissors-unite.md diff --git a/.changeset/fresh-scissors-unite.md b/.changeset/fresh-scissors-unite.md new file mode 100644 index 0000000000..bc4cc8fe8b --- /dev/null +++ b/.changeset/fresh-scissors-unite.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/common": patch +--- + +Minor fix to resolving user types: `solc` doesn't like relative imports without `./`, but is fine with relative imports from `./../`, so we always append `./` to the relative path. diff --git a/packages/common/src/codegen/utils/loadUserTypesFile.ts b/packages/common/src/codegen/utils/loadUserTypesFile.ts index 2a5394e483..8573e8c165 100644 --- a/packages/common/src/codegen/utils/loadUserTypesFile.ts +++ b/packages/common/src/codegen/utils/loadUserTypesFile.ts @@ -31,8 +31,9 @@ function loadUserTypesFile( data: string; } { if (unresolvedFilePath.at(0) === ".") { + const relativePath = path.relative(outputBaseDirectory, unresolvedFilePath); return { - filePath: path.relative(outputBaseDirectory, unresolvedFilePath), + filePath: "./" + relativePath, // solc doesn't like relative paths without "./" data: readFileSync(unresolvedFilePath, "utf8"), }; } else {