Skip to content

Commit

Permalink
fix(defineEnv): fallback support for unenv-nightly (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Dec 18, 2024
1 parent 7e05819 commit 5d6aec3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,20 @@ export function defineEnv(opts: CreateEnvOptions = {}): {
const resolveOpts: ResolveOptions = {
url: resolvePaths,
};
const _resolve = (id: string) => resolvePathSync(id, resolveOpts);

const _tryResolve = (id: string) => {
try {
return resolvePathSync(id, resolveOpts);
} catch {}
};

const _resolve = (id: string) => {
let resolved = _tryResolve(id);
if (!resolved && id.startsWith("unenv/")) {
resolved = _tryResolve(id.replace("unenv/", "unenv-nightly/"));
}
return resolved || id;
};

// Resolve aliases
for (const alias in resolvedEnv.alias) {
Expand Down

0 comments on commit 5d6aec3

Please sign in to comment.