Skip to content

Commit

Permalink
Merge pull request #97 from mansona/optional-peer-deps
Browse files Browse the repository at this point in the history
don't error about missing optional peer deps
  • Loading branch information
ef4 authored May 14, 2024
2 parents c89d99a + 7654463 commit 698f313
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,22 @@ export class Project {
}
}

// collect a list of optional peers
let optionalPeers = [];
for (let depName of Object.keys(targetPkg['peerDependenciesMeta'] ?? {})) {
if (targetPkg['peerDependenciesMeta'][depName]?.optional === true) {
optionalPeers.push(depName);
}
}

for (let depName of depsToLink) {
let depTarget = resolvePackagePath(depName, target, this.resolutionCache);

if (!depTarget && optionalPeers.includes(depName)) {
// don't link or error about missing optional peer deps
continue;
}

if (!depTarget) {
throw new Error(
`[FixturifyProject] package ${name} in ${target} depends on ${depName} but we could not resolve it`
Expand Down

0 comments on commit 698f313

Please sign in to comment.