Skip to content

Commit

Permalink
Fix on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Apr 18, 2024
1 parent a3e30ed commit 4c4fac7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ async function processImportMapInput(
load: FetchCacher["load"],
): Promise<ImportMapRustLibInput> {
if (typeof importMap === "string" || importMap instanceof URL) {
importMap = locationToUrl(importMap);
const data = await load(importMap.toString(), false, "use");
if (data == null) {
return undefined;
}
switch (data.kind) {
case "module": {
return {
baseUrl: locationToUrl(importMap).toString(),
baseUrl: importMap.toString(),
jsonString: data.content instanceof Uint8Array
? new TextDecoder().decode(data.content)
: data.content,
Expand All @@ -333,8 +334,7 @@ async function processImportMapInput(
throw new Error("Unexpected kind.");
}
}
}
if (typeof importMap === "object") {
} else if (typeof importMap === "object") {
const { baseUrl, imports, scopes } = importMap;
const url = locationToUrl(baseUrl ?? Deno.cwd());
// Rust lib expects url to be the file URL to the import map file, but the
Expand All @@ -347,8 +347,9 @@ async function processImportMapInput(
baseUrl: url.toString(),
jsonString: JSON.stringify({ imports, scopes }),
};
} else {
return undefined;
}
return undefined;
}

type ImportMapJsLibInput =
Expand Down

0 comments on commit 4c4fac7

Please sign in to comment.