mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Try a naive file load during parse, to see if that helps with pre-caching.
This commit is contained in:
parent
d2cb05a6b5
commit
98404ec7bf
@ -1,4 +1,12 @@
|
||||
namespace ts {
|
||||
let fs: typeof import("fs") | undefined;
|
||||
let path: typeof import("path") | undefined;
|
||||
try {
|
||||
fs = require("fs");
|
||||
path = require("path");
|
||||
}
|
||||
catch {}
|
||||
|
||||
const enum SignatureFlags {
|
||||
None = 0,
|
||||
Yield = 1 << 0,
|
||||
@ -7010,7 +7018,19 @@ namespace ts {
|
||||
function parseModuleSpecifier(): Expression {
|
||||
if (token() === SyntaxKind.StringLiteral) {
|
||||
const result = parseLiteralNode();
|
||||
result.text = internIdentifier(result.text);
|
||||
const text = result.text;
|
||||
if (fs && path && result.text.charCodeAt(0) === CharacterCodes.dot) {
|
||||
const initPath = path.resolve(fileName, result.text);
|
||||
const ext = path.extname(initPath);
|
||||
fs.readFile(text, noop);
|
||||
if (!ext) {
|
||||
fs.readFile(text + ".ts", noop);
|
||||
fs.readFile(text + ".tsx", noop);
|
||||
fs.readFile(text + ".d.ts", noop);
|
||||
fs.readFile(text + ".js", noop);
|
||||
}
|
||||
}
|
||||
result.text = internIdentifier(text);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user