Skip to content

Commit

Permalink
fix: Replace vendored imports with the correct paths on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jespertheend committed Apr 4, 2023
1 parent 0dceb98 commit a17e247
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,9 @@ ${importmapMessage}
const oldSpecifier = node.text;
const resolvedUrl = resolveModuleSpecifierAll(baseUrl, oldSpecifier);
if (resolvedUrl) {
newSpecifier = resolvedUrl.pathname;
// Resolved urls should always be absolute. So we don't need the file:// prefix here I think.
// Either way, TypeScript doesn't seem to have support for resolving file:// specifiers.
newSpecifier = fromFileUrl(resolvedUrl.href);
}
if (newSpecifier && newSpecifier.endsWith(".ts")) {
newSpecifier = newSpecifier.slice(0, -3) + ".js";
Expand Down Expand Up @@ -722,7 +724,7 @@ ${importmapMessage}

logger.debug(`Modifying ${filePath}`);

const ast = await parseFileAst(fileContent, filePath, (node, { sourceFile }) => {
const ast = parseFileAst(fileContent, filePath, (node, { sourceFile }) => {
// Collect imports/exports with a deno-types comment
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier) {
const commentRanges = ts.getLeadingCommentRanges(sourceFile.text, node.pos);
Expand Down

0 comments on commit a17e247

Please sign in to comment.