-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VSCode and tsc very slow when using external tsplusTypes #252
Comments
I've fixed the performance issue with 3 caches, but the last one seems to have made the most difference. 1: for (const resolvedPath of resolvedPaths) {
const json = resolvedPath in tsPlusTypeCache ? tsPlusTypeCache[resolvedPath] : (() => { const text = sys.readFile(resolvedPath); if (text) { const json = JSON.parse(text); tsPlusTypeCache[resolvedPath] = json; return json}})()
if (json) { 2: if (options.configFilePath) {
const resolvedPaths = getResolvedPaths(options)
if (resolvedPaths.length === 0) {
return;
} function getResolvedPaths(options) {
if (options.configFilePath in resolvedPathsCache) { return resolvedPathsCache[options.configFilePath] }
let resolvedPaths = [];
if (options.tsPlusTypes) {
for (const path of options.tsPlusTypes) {
if (pathIsRelative(path)) {
resolvedPaths.push(resolvePath(options.configFilePath.split("/").slice(0, -1).join("/"), path));
} else {
const resolvedModule = resolveModuleName(path, options.configFilePath, options, sys).resolvedModule;
if (resolvedModule) {
resolvedPaths.push(resolvedModule.resolvedFileName);
break;
}
}
}
}
const packagePath = removeExtension(options.configFilePath.split("node_modules").slice(-1)[0].substring(1), ".d.ts");
if (packagePath) {
let packageName;
if (packagePath.startsWith("@")) {
packageName = packagePath.split(directorySeparator).slice(0, 2).join(directorySeparator);
} else {
packageName = packagePath.split(directorySeparator).slice(0, 1)[0];
}
const resolvedPackageJson = resolvePackageNameToPackageJson(packageName, options.configFilePath, options, sys, void 0);
if (resolvedPackageJson) {
const packageJsonText = sys.readFile(resolvePath(resolvedPackageJson.packageDirectory, "package.json"));
if (packageJsonText) {
const packageJson = JSON.parse(packageJsonText);
if (packageJson.tsPlusTypes) {
for (const path of toArray(packageJson.tsPlusTypes)) {
resolvedPaths.push(resolvePath(resolvedPackageJson.packageDirectory, path));
}
}
}
}
if (packagePath.startsWith("@")) {
packageName = mangleScopedPackageName(packagePath.split(directorySeparator).slice(0, 2).join(directorySeparator));
} else {
packageName = packagePath.split(directorySeparator).slice(0, 1)[0];
}
const { resolvedModule } = resolveModuleName(`@tsplus-types/${packageName}`, options.configFilePath, { ...options, resolveJsonModule: true }, sys);
if (resolvedModule) {
resolvedPaths.push(resolvedModule.resolvedFileName);
}
}
resolvedPathsCache[options.configFilePath] = resolvedPaths
return resolvedPaths
} 3:
const resolvedModule = key in resolvedModuleCache ? resolvedModuleCache[key] : (resolvedModuleCache[key] = resolveModuleName(moduleName, options.configFilePath, options, sys).resolvedModule); |
Merged
@0x706b this seems to work well now, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perhaps also related: #248
Using these https://github.com/tim-smart/effect-rpc/tree/main/packages/router/vendor by @tim-smart
coming out of https://github.com/tim-smart/tsplus-gen
The text was updated successfully, but these errors were encountered: