Skip to content

Commit

Permalink
fix(compat): typescript - handle files not covered by pnp
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Dec 2, 2021
1 parent 8481855 commit 3a816b6
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 146 deletions.
130 changes: 65 additions & 65 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
23 changes: 23 additions & 0 deletions .yarn/versions/7639258b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-compat": patch

declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,28 @@ const SLICES = [
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.2
{
from: `8e0e8703b9c95013aec7819e4593d099cdf7763a`,
to: `545d5a8c5409dac447a668d4e7d315702fd115d6`,
to: `178a67b4663d80b0fcbea542e7255b4499b51708`,
onto: `bfc55b5762443c37ecdef08a3b5a4e057b4d1e85`,
range: `>=4.2 <4.3`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.3
{
from: `530aad19e4ac19d35cb6b200168c91ce86cb0050`,
to: `6d7d4d2ce0df8e65a2c86a20c014c053ef530ea3`,
to: `ffa54c5a104e7940b5c23666ddffbf44878f9d9f`,
onto: `28e3e6ff2f49f1dbf06d31809ec73dbe42f1aa63`,
range: `>=4.3 <4.4`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.4
{
from: `793bfe32745bf6797924354b0fd5be62cf01950c`,
to: `88a10595c32309fc26eb4a7f5a858d98e883dae0`,
to: `20ffca2f3c48591c971e6606a55b7b1820d8a64f`,
onto: `a10409ccaa3604790dc45f52ef0402eb49015dcf`,
range: `>=4.4 <4.5`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.5
{
from: `79fe5d206f89e5f1585807bdcd7feeb567a69646`,
to: `79fe5d206f89e5f1585807bdcd7feeb567a69646`,
to: `fff89a12766fa485e35b1c65d8631d109c4e2c0e`,
onto: `7893f689fedcfe28a499d119d34844840bce9160`,
range: `>=4.5.2`,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/lib/tsc.js b/lib/tsc.js
index 7f46cc9d8..7cbce60e4 100644
index 7f46cc9d8..fd2e81687 100644
semver exclusivity >=4.2 <4.3
--- a/lib/tsc.js
+++ b/lib/tsc.js
Expand Down Expand Up @@ -189,8 +189,8 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ if (locator !== null) {
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ if (locator === sourceLocator) {
+ return undefined;
Expand Down Expand Up @@ -300,7 +300,7 @@ semver exclusivity >=4.2 <4.3
ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
synchronizeProgram();
diff --git a/lib/tsserver.js b/lib/tsserver.js
index a1d0a7a17..d91fc7268 100644
index a1d0a7a17..a85af606d 100644
semver exclusivity >=4.2 <4.3
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
Expand Down Expand Up @@ -509,9 +509,9 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -935,7 +935,7 @@ semver exclusivity >=4.2 <4.3
* @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 e8537e466..a9b26d7bc 100644
index e8537e466..499df472c 100644
semver exclusivity >=4.2 <4.3
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
Expand Down Expand Up @@ -1144,9 +1144,9 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -1548,7 +1548,7 @@ semver exclusivity >=4.2 <4.3
* @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/typescript.js b/lib/typescript.js
index 8539f89fd..1a23b4f8d 100644
index 8539f89fd..ae4dbaa64 100644
semver exclusivity >=4.2 <4.3
--- a/lib/typescript.js
+++ b/lib/typescript.js
Expand Down Expand Up @@ -1757,9 +1757,9 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -2058,7 +2058,7 @@ semver exclusivity >=4.2 <4.3
* @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/typescriptServices.js b/lib/typescriptServices.js
index 6b08bfe23..26108a400 100644
index 6b08bfe23..5019e423b 100644
semver exclusivity >=4.2 <4.3
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
Expand Down Expand Up @@ -2267,9 +2267,9 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -2555,7 +2555,7 @@ semver exclusivity >=4.2 <4.3
return statement;
});
diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js
index 9fa096358..79265c286 100644
index 9fa096358..0c97fc3ff 100644
semver exclusivity >=4.2 <4.3
--- a/lib/typingsInstaller.js
+++ b/lib/typingsInstaller.js
Expand Down Expand Up @@ -2764,9 +2764,9 @@ semver exclusivity >=4.2 <4.3
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/lib/tsc.js b/lib/tsc.js
index d425ad1b5..0f7fe5cd1 100644
index d425ad1b5..4261d27cd 100644
semver exclusivity >=4.4 <4.5
--- a/lib/tsc.js
+++ b/lib/tsc.js
Expand Down Expand Up @@ -189,8 +189,8 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ if (locator !== null) {
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ if (locator === sourceLocator) {
+ return undefined;
Expand Down Expand Up @@ -300,7 +300,7 @@ semver exclusivity >=4.4 <4.5
ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
synchronizeProgram();
diff --git a/lib/tsserver.js b/lib/tsserver.js
index 6e4ee30b7..561057665 100644
index 6e4ee30b7..779172b83 100644
semver exclusivity >=4.4 <4.5
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
Expand Down Expand Up @@ -509,9 +509,9 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -922,7 +922,7 @@ semver exclusivity >=4.4 <4.5
* @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 5fa1cd290..a7852ed52 100644
index 5fa1cd290..9253c6ff4 100644
semver exclusivity >=4.4 <4.5
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
Expand Down Expand Up @@ -1131,9 +1131,9 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -1522,7 +1522,7 @@ semver exclusivity >=4.4 <4.5
* @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/typescript.js b/lib/typescript.js
index 44462973f..3f5a196de 100644
index 44462973f..dec9f5a1e 100644
semver exclusivity >=4.4 <4.5
--- a/lib/typescript.js
+++ b/lib/typescript.js
Expand Down Expand Up @@ -1731,9 +1731,9 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -2019,7 +2019,7 @@ semver exclusivity >=4.4 <4.5
* @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/typescriptServices.js b/lib/typescriptServices.js
index 20a6fc52e..c7d12009d 100644
index 20a6fc52e..662551c39 100644
semver exclusivity >=4.4 <4.5
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
Expand Down Expand Up @@ -2228,9 +2228,9 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down Expand Up @@ -2503,7 +2503,7 @@ semver exclusivity >=4.4 <4.5
return statement;
});
diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js
index a0e7177a1..1a61d3009 100644
index a0e7177a1..c3f471586 100644
semver exclusivity >=4.4 <4.5
--- a/lib/typingsInstaller.js
+++ b/lib/typingsInstaller.js
Expand Down Expand Up @@ -2712,9 +2712,9 @@ semver exclusivity >=4.4 <4.5
+ if (!parts && typeof process.versions.pnp !== "undefined") {
+ var findPnpApi = require("module").findPnpApi;
+ var pnpApi = findPnpApi(path);
+ var locator = pnpApi.findPackageLocator(path);
+ var locator = pnpApi === null || pnpApi === void 0 ? void 0 : pnpApi.findPackageLocator(path);
+ // eslint-disable-next-line no-null/no-null
+ if (locator !== null) {
+ if (locator != null) {
+ var sourceLocator = pnpApi.findPackageLocator(sourceDirectory + "/");
+ // Don't use the package name when the imported file is inside
+ // the source directory (prefer a relative path instead)
Expand Down
Loading

0 comments on commit 3a816b6

Please sign in to comment.