-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Sentry } from "../sentry.worker"; | ||
import { loadDependency } from "./loadDependency"; | ||
import { extractReferences } from "./extractReferences"; | ||
import { resolveImportSpecifier } from "./resolveSpecifiers"; | ||
import { VirtualTypeScriptEnvironment } from "../vfs/vfs_utils"; | ||
import { urlToFilepath } from "app/lib/tsUrlInterop"; | ||
import type { VirtualTypeScriptEnvironment } from "./vfs_utils"; | ||
import { urlToFilepath } from "./tsUrlInterop"; | ||
|
||
const NODE_FILE_PATH = "node_types.d.ts"; | ||
const NODE_FILE = `/// <reference types="npm:@types/[email protected]" />\n`; | ||
|
@@ -26,8 +25,8 @@ export function setupTypeAcquisition( | |
let downloaded = 0; | ||
|
||
// Used for debugging | ||
let debugLinks: [string, string][] = []; | ||
let debugIds = new Map<string, number>(); | ||
const debugLinks: [string, string][] = []; | ||
const debugIds = new Map<string, number>(); | ||
let debugCounter = 0; | ||
|
||
function getDebugId(url: string) { | ||
|
@@ -56,7 +55,7 @@ ${debugLinks | |
.join("\n")} | ||
`)*/ | ||
} catch (e) { | ||
Sentry.captureException(e); | ||
console.error(e); | ||
} | ||
}, | ||
/** | ||
|
@@ -102,7 +101,7 @@ ${debugLinks | |
if (downloadedPaths.has(resolvedUrl.url)) return; | ||
downloadedPaths.add(resolvedUrl.url); | ||
total++; | ||
let dep = await loadDependency(resolvedUrl.url); | ||
const dep = await loadDependency(resolvedUrl.url); | ||
downloaded++; | ||
if (dep === null) { | ||
console.error(`Failed to get ${importSpecifier}`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export function ensureTsExtension(fileName: string) { | ||
// If we're looking at an HTTP import that doesn't have | ||
// an extension like cjs, mjs, jsx, tsx, or ts, | ||
// add one. | ||
if (!fileName.match(/\.(t|[mc]?j)sx?$/)) { | ||
return `${fileName}.tsx`; | ||
} | ||
return fileName; | ||
} | ||
|
||
/** | ||
* All right, so as other comments talk about, Deno uses https:// | ||
* imports and TypeScript doesn't support them. TypeScript doesn't | ||
* support setting a 'file' with a URL as the path. | ||
* | ||
* Note: this does normalize both https and http to https, but | ||
* it doesn't matter that much: in reality, we are never | ||
* going to be loading http content. | ||
*/ | ||
export function urlToFilepath(path: string) { | ||
return ensureTsExtension(path.replace(/https?:\/\//, "/https/")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { System } from "typescript"; | ||
|
||
export interface VirtualTypeScriptEnvironment { | ||
sys: System; | ||
languageService: import("typescript").LanguageService; | ||
getSourceFile: ( | ||
fileName: string, | ||
) => import("typescript").SourceFile | undefined; | ||
createFile: (fileName: string, content: string) => void; | ||
updateFile: ( | ||
fileName: string, | ||
content: string, | ||
replaceTextSpan?: import("typescript").TextSpan, | ||
) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters