Skip to content

Commit

Permalink
feat: Improved circular import error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jespertheend committed Feb 2, 2023
1 parent acb632f commit 8584877
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ImportResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ ${getRelativePath(this.#importMeta, url)}
throw new Error(
`Circular imports are not supported:
${importFileNames}
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
${importPathsWithoutDuplicates.join("\n")}`,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/getRelativePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { posix } from "https://deno.land/[email protected]/path/mod.ts";
export function getRelativePath(pathA, pathB) {
let a = posix.fromFileUrl(pathA);
if (!a.endsWith("/")) {
a = posix.dirname(a)
a = posix.dirname(a);
}
const b = posix.fromFileUrl(pathB);
let rel = posix.relative(a, b);
Expand Down
12 changes: 6 additions & 6 deletions test/integration/circular.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> A.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./A.js
./B.js`,
);
Expand Down Expand Up @@ -76,7 +76,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> C.js -> A.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./A.js
./B.js
./C.js`,
Expand Down Expand Up @@ -126,7 +126,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> C.js -> D.js -> B.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./A.js
./B.js
./C.js
Expand Down Expand Up @@ -173,7 +173,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> C.js -> A.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./root/A.js
./root/scripts/B.js
./root/C.js`,
Expand Down Expand Up @@ -311,7 +311,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> D.js -> F.js -> D.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./A.js
./B.js
./D.js
Expand Down Expand Up @@ -388,7 +388,7 @@ Deno.test({
Error,
`Circular imports are not supported:
A.js -> B.js -> A.js
Consider passing one of the following paths to \`importer.makeReal()\`:
Consider faking or passing one of the following paths to \`importer.makeReal()\`:
./A.js
../B/B.js`,
);
Expand Down

0 comments on commit 8584877

Please sign in to comment.