Skip to content

Commit

Permalink
Editor SDK support for resolving portaled dependencies (#4091)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkells committed Feb 21, 2022
1 parent b1e0e64 commit 43a35de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .yarn/versions/88da1151.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
releases:
"@yarnpkg/sdks": patch
3 changes: 2 additions & 1 deletion packages/yarnpkg-sdks/sources/sdks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
const pnpApi = require(\`pnpapi\`);
const isVirtual = str => str.match(/\\/(\\$\\$virtual|__virtual__)\\//);
const isPortal = str => str.startsWith("portal:/");
const normalize = str => str.replace(/\\\\/g, \`/\`).replace(/^\\/?/, \`/\`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
Expand All @@ -71,7 +72,7 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
if (resolved) {
const locator = pnpApi.findPackageLocator(resolved);
if (locator && dependencyTreeRoots.has(\`\${locator.name}@\${locator.reference}\`)) {
if (locator && (dependencyTreeRoots.has(\`\${locator.name}@\${locator.reference}\`) || isPortal(locator.reference))) {
str = resolved;
}
}
Expand Down

0 comments on commit 43a35de

Please sign in to comment.