Skip to content

Commit

Permalink
refactor: update to jiti 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 25, 2024
1 parent 24e8c47 commit c2cc1e9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"defu": "^6.1.4",
"dotenv": "^16.4.5",
"giget": "^1.2.3",
"jiti": "2.0.0-beta.3",
"jiti": "^2.0.0",
"mlly": "^1.7.1",
"ohash": "^1.1.4",
"pathe": "^1.1.2",
Expand Down
82 changes: 44 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { readFile, rm } from "node:fs/promises";
import { homedir } from "node:os";
import { resolve, extname, dirname, basename, join } from "pathe";
import { createJiti } from "jiti";
import { fileURLToPath } from "mlly";
import * as rc9 from "rc9";
import { defu } from "defu";
import { hash } from "ohash";
Expand Down Expand Up @@ -344,11 +345,8 @@ async function resolveConfig<

// Util to try resolving a module
const tryResolve = (id: string) => {
try {
return options.jiti!.esmResolve(id, { try: true });
} catch {
// Ignore errors
}
const resolved = options.jiti!.esmResolve(id, { try: true });
return resolved ? fileURLToPath(resolved) : undefined;
};

// Try resolving as npm package
Expand Down

0 comments on commit c2cc1e9

Please sign in to comment.