Skip to content

Commit

Permalink
fix: handle references that doesn't point to a package root
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Aug 17, 2021
1 parent 97e7d92 commit b259015
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 107 deletions.
128 changes: 64 additions & 64 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ const SLICES = [
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.3
{
from: `530aad19e4ac19d35cb6b200168c91ce86cb0050`,
to: `cece814b81e51816f6803df887c425ba75833797`,
to: `8f569da31e6ea242a4bc9cf18f841ad0c122893c`,
onto: `28e3e6ff2f49f1dbf06d31809ec73dbe42f1aa63`,
range: `>=4.3 <4.4`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.4
{
from: `0fc83b4d571df33a3c40c20c0eba68965fb52aca`,
to: `98866a5a740b487c20046d4ffaa36aa1f202dde9`,
to: `3f4e1516e0a956e1e0d46d9caf2a1f896fb77aaa`,
onto: `55dd850009603aafa6ef8cc88020fa30d217d5b6`,
range: `>=4.4`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ semver exclusivity >=4.4
ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
synchronizeProgram();
diff --git a/lib/tsserver.js b/lib/tsserver.js
index ac49ace7b..a88e5e2b7 100644
index ac49ace7b..d60ad05ba 100644
semver exclusivity >=4.4
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
Expand Down Expand Up @@ -781,7 +781,7 @@ semver exclusivity >=4.4
}
return statement;
});
@@ -162653,6 +162863,37 @@ var ts;
@@ -162653,6 +162863,39 @@ var ts;
return this.projectReferences;
};
ConfiguredProject.prototype.updateReferences = function (refs) {
Expand All @@ -807,7 +807,9 @@ semver exclusivity >=4.4
+ var getPnpPath_1 = function (path) {
+ try {
+ var targetLocator = pnpApi_1.findPackageLocator(path + "/");
+ return pnpApi_1.resolveToUnqualified(targetLocator.name, basePath_1 + "/");
+ var packageLocation = pnpApi_1.getPackageInformation(targetLocator).packageLocation;
+ var request = ts.combinePaths(targetLocator.name, ts.getRelativePathFromDirectory(packageLocation, path, false));
+ return pnpApi_1.resolveToUnqualified(request, basePath_1 + "/");
+ }
+ catch (_a) {
+ // something went wrong with the resolution, try not to fail
Expand All @@ -819,15 +821,15 @@ semver exclusivity >=4.4
this.projectReferences = refs;
this.potentialProjectReferences = undefined;
};
@@ -163269,6 +163510,7 @@ var ts;
@@ -163269,6 +163512,7 @@ var ts;
watchDirectory: ts.returnNoopFileWatcher,
} :
ts.getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
+ this.pnpWatcher = this.watchPnpFile();
}
ProjectService.prototype.toPath = function (fileName) {
return ts.toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
@@ -165121,7 +165363,7 @@ var ts;
@@ -165121,7 +165365,7 @@ var ts;
};
ProjectService.prototype.setHostConfiguration = function (args) {
var _this = this;
Expand All @@ -836,7 +838,7 @@ semver exclusivity >=4.4
if (args.file) {
var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file));
if (info) {
@@ -165139,7 +165381,7 @@ var ts;
@@ -165139,7 +165383,7 @@ var ts;
this.logger.info("Format host information updated");
}
if (args.preferences) {
Expand All @@ -845,7 +847,7 @@ semver exclusivity >=4.4
this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences);
if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
// Load configured projects for external projects that are pending reload
@@ -165165,6 +165407,8 @@ var ts;
@@ -165165,6 +165409,8 @@ var ts;
if (args.watchOptions) {
this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions;
this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches.");
Expand All @@ -854,7 +856,7 @@ semver exclusivity >=4.4
}
}
};
@@ -166159,6 +166403,25 @@ var ts;
@@ -166159,6 +166405,25 @@ var ts;
});
};
/*@internal*/
Expand All @@ -880,7 +882,7 @@ semver exclusivity >=4.4
ProjectService.prototype.watchPackageJsonFile = function (path) {
var _this = this;
var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = new ts.Map());
@@ -171030,6 +171293,9 @@ var ts;
@@ -171030,6 +171295,9 @@ var ts;
}
try {
var args = [ts.combinePaths(__dirname, "watchGuard.js"), path];
Expand All @@ -890,7 +892,7 @@ semver exclusivity >=4.4
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("Starting " + process.execPath + " with args:" + server.stringifyIndented(args));
}
@@ -171290,6 +171556,9 @@ var ts;
@@ -171290,6 +171558,9 @@ var ts;
break;
}
}
Expand All @@ -914,7 +916,7 @@ semver exclusivity >=4.4
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js
index 47d329d5e..762c02cbf 100644
index 47d329d5e..701859def 100644
semver exclusivity >=4.4
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
Expand Down Expand Up @@ -1396,7 +1398,7 @@ semver exclusivity >=4.4
}
return statement;
});
@@ -162847,6 +163057,37 @@ var ts;
@@ -162847,6 +163057,39 @@ var ts;
return this.projectReferences;
};
ConfiguredProject.prototype.updateReferences = function (refs) {
Expand All @@ -1422,7 +1424,9 @@ semver exclusivity >=4.4
+ var getPnpPath_1 = function (path) {
+ try {
+ var targetLocator = pnpApi_1.findPackageLocator(path + "/");
+ return pnpApi_1.resolveToUnqualified(targetLocator.name, basePath_1 + "/");
+ var packageLocation = pnpApi_1.getPackageInformation(targetLocator).packageLocation;
+ var request = ts.combinePaths(targetLocator.name, ts.getRelativePathFromDirectory(packageLocation, path, false));
+ return pnpApi_1.resolveToUnqualified(request, basePath_1 + "/");
+ }
+ catch (_a) {
+ // something went wrong with the resolution, try not to fail
Expand All @@ -1434,15 +1438,15 @@ semver exclusivity >=4.4
this.projectReferences = refs;
this.potentialProjectReferences = undefined;
};
@@ -163463,6 +163704,7 @@ var ts;
@@ -163463,6 +163706,7 @@ var ts;
watchDirectory: ts.returnNoopFileWatcher,
} :
ts.getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
+ this.pnpWatcher = this.watchPnpFile();
}
ProjectService.prototype.toPath = function (fileName) {
return ts.toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
@@ -165315,7 +165557,7 @@ var ts;
@@ -165315,7 +165559,7 @@ var ts;
};
ProjectService.prototype.setHostConfiguration = function (args) {
var _this = this;
Expand All @@ -1451,7 +1455,7 @@ semver exclusivity >=4.4
if (args.file) {
var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file));
if (info) {
@@ -165333,7 +165575,7 @@ var ts;
@@ -165333,7 +165577,7 @@ var ts;
this.logger.info("Format host information updated");
}
if (args.preferences) {
Expand All @@ -1460,7 +1464,7 @@ semver exclusivity >=4.4
this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences);
if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
// Load configured projects for external projects that are pending reload
@@ -165359,6 +165601,8 @@ var ts;
@@ -165359,6 +165603,8 @@ var ts;
if (args.watchOptions) {
this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions;
this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches.");
Expand All @@ -1469,7 +1473,7 @@ semver exclusivity >=4.4
}
}
};
@@ -166353,6 +166597,25 @@ var ts;
@@ -166353,6 +166599,25 @@ var ts;
});
};
/*@internal*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ semver exclusivity >=4.3 <4.4
ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
synchronizeProgram();
diff --git a/lib/tsserver.js b/lib/tsserver.js
index 58028943d..954b4a25f 100644
index 58028943d..2dd0e1e8b 100644
semver exclusivity >=4.3 <4.4
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
Expand Down Expand Up @@ -794,7 +794,7 @@ semver exclusivity >=4.3 <4.4
}
return statement;
});
@@ -159155,6 +159374,37 @@ var ts;
@@ -159155,6 +159374,39 @@ var ts;
return this.projectReferences;
};
ConfiguredProject.prototype.updateReferences = function (refs) {
Expand All @@ -820,7 +820,9 @@ semver exclusivity >=4.3 <4.4
+ var getPnpPath_1 = function (path) {
+ try {
+ var targetLocator = pnpApi_1.findPackageLocator(path + "/");
+ return pnpApi_1.resolveToUnqualified(targetLocator.name, basePath_1 + "/");
+ var packageLocation = pnpApi_1.getPackageInformation(targetLocator).packageLocation;
+ var request = ts.combinePaths(targetLocator.name, ts.getRelativePathFromDirectory(packageLocation, path, false));
+ return pnpApi_1.resolveToUnqualified(request, basePath_1 + "/");
+ }
+ catch (_a) {
+ // something went wrong with the resolution, try not to fail
Expand All @@ -832,15 +834,15 @@ semver exclusivity >=4.3 <4.4
this.projectReferences = refs;
this.potentialProjectReferences = undefined;
};
@@ -159762,6 +160012,7 @@ var ts;
@@ -159762,6 +160014,7 @@ var ts;
watchDirectory: ts.returnNoopFileWatcher,
} :
ts.getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
+ this.pnpWatcher = this.watchPnpFile();
}
ProjectService.prototype.toPath = function (fileName) {
return ts.toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
@@ -161586,7 +161837,7 @@ var ts;
@@ -161586,7 +161839,7 @@ var ts;
};
ProjectService.prototype.setHostConfiguration = function (args) {
var _this = this;
Expand All @@ -849,7 +851,7 @@ semver exclusivity >=4.3 <4.4
if (args.file) {
var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file));
if (info) {
@@ -161604,7 +161855,7 @@ var ts;
@@ -161604,7 +161857,7 @@ var ts;
this.logger.info("Format host information updated");
}
if (args.preferences) {
Expand All @@ -858,7 +860,7 @@ semver exclusivity >=4.3 <4.4
this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences);
if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
// Load configured projects for external projects that are pending reload
@@ -161630,6 +161881,8 @@ var ts;
@@ -161630,6 +161883,8 @@ var ts;
if (args.watchOptions) {
this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions;
this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches.");
Expand All @@ -867,7 +869,7 @@ semver exclusivity >=4.3 <4.4
}
}
};
@@ -162607,6 +162860,25 @@ var ts;
@@ -162607,6 +162862,25 @@ var ts;
});
};
/*@internal*/
Expand All @@ -893,7 +895,7 @@ semver exclusivity >=4.3 <4.4
ProjectService.prototype.watchPackageJsonFile = function (path) {
var _this = this;
var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = new ts.Map());
@@ -167357,6 +167629,9 @@ var ts;
@@ -167357,6 +167631,9 @@ var ts;
}
try {
var args = [ts.combinePaths(__dirname, "watchGuard.js"), path];
Expand All @@ -903,7 +905,7 @@ semver exclusivity >=4.3 <4.4
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("Starting " + process.execPath + " with args:" + server.stringifyIndented(args));
}
@@ -167617,6 +167892,9 @@ var ts;
@@ -167617,6 +167894,9 @@ var ts;
break;
}
}
Expand All @@ -927,7 +929,7 @@ semver exclusivity >=4.3 <4.4
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js
index ee78ce982..a7af3eed1 100644
index ee78ce982..a6637815c 100644
semver exclusivity >=4.3 <4.4
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
Expand Down Expand Up @@ -1422,7 +1424,7 @@ semver exclusivity >=4.3 <4.4
}
return statement;
});
@@ -159349,6 +159568,37 @@ var ts;
@@ -159349,6 +159568,39 @@ var ts;
return this.projectReferences;
};
ConfiguredProject.prototype.updateReferences = function (refs) {
Expand All @@ -1448,7 +1450,9 @@ semver exclusivity >=4.3 <4.4
+ var getPnpPath_1 = function (path) {
+ try {
+ var targetLocator = pnpApi_1.findPackageLocator(path + "/");
+ return pnpApi_1.resolveToUnqualified(targetLocator.name, basePath_1 + "/");
+ var packageLocation = pnpApi_1.getPackageInformation(targetLocator).packageLocation;
+ var request = ts.combinePaths(targetLocator.name, ts.getRelativePathFromDirectory(packageLocation, path, false));
+ return pnpApi_1.resolveToUnqualified(request, basePath_1 + "/");
+ }
+ catch (_a) {
+ // something went wrong with the resolution, try not to fail
Expand All @@ -1460,15 +1464,15 @@ semver exclusivity >=4.3 <4.4
this.projectReferences = refs;
this.potentialProjectReferences = undefined;
};
@@ -159956,6 +160206,7 @@ var ts;
@@ -159956,6 +160208,7 @@ var ts;
watchDirectory: ts.returnNoopFileWatcher,
} :
ts.getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
+ this.pnpWatcher = this.watchPnpFile();
}
ProjectService.prototype.toPath = function (fileName) {
return ts.toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
@@ -161780,7 +162031,7 @@ var ts;
@@ -161780,7 +162033,7 @@ var ts;
};
ProjectService.prototype.setHostConfiguration = function (args) {
var _this = this;
Expand All @@ -1477,7 +1481,7 @@ semver exclusivity >=4.3 <4.4
if (args.file) {
var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file));
if (info) {
@@ -161798,7 +162049,7 @@ var ts;
@@ -161798,7 +162051,7 @@ var ts;
this.logger.info("Format host information updated");
}
if (args.preferences) {
Expand All @@ -1486,7 +1490,7 @@ semver exclusivity >=4.3 <4.4
this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences);
if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) {
// Load configured projects for external projects that are pending reload
@@ -161824,6 +162075,8 @@ var ts;
@@ -161824,6 +162077,8 @@ var ts;
if (args.watchOptions) {
this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions;
this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches.");
Expand All @@ -1495,7 +1499,7 @@ semver exclusivity >=4.3 <4.4
}
}
};
@@ -162801,6 +163054,25 @@ var ts;
@@ -162801,6 +163056,25 @@ var ts;
});
};
/*@internal*/
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-compat/sources/patches/typescript.patch.ts

Large diffs are not rendered by default.

Loading

0 comments on commit b259015

Please sign in to comment.