From a17e2470914b9923512e0f00cb8a82ce6edfb6d5 Mon Sep 17 00:00:00 2001 From: Jesper van den Ende Date: Tue, 4 Apr 2023 23:44:42 +0200 Subject: [PATCH] fix: Replace vendored imports with the correct paths on Windows. --- mod.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mod.js b/mod.js index 5c2a20d..32b3ca6 100644 --- a/mod.js +++ b/mod.js @@ -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"; @@ -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);