Skip to content

fix: pnpm collection of optional dependencies #8957

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-queens-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: pnpm collection of optional dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,30 @@ export class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmDependenc
extractProductionDependencyTree(tree: PnpmDependency): DependencyTree {
const p = path.normalize(this.resolvePath(tree.path))
const packageJson: Dependency<string, string> = require(path.join(p, "package.json"))
const prodDependencies = { ...(packageJson.dependencies || {}), ...(packageJson.optionalDependencies || {}) }

const deps = { ...(tree.dependencies || {}), ...(tree.optionalDependencies || {}) }
const dependencies = Object.entries(deps).reduce<DependencyTree["dependencies"]>((acc, curr) => {
const [packageName, dependency] = curr
if (!prodDependencies[packageName]) {

let isOptional: boolean
if (packageJson.dependencies?.[packageName]) {
isOptional = false
} else if (packageJson.optionalDependencies?.[packageName]) {
isOptional = true
} else {
return acc
}
return {
...acc,
[packageName]: this.extractProductionDependencyTree(dependency),

try {
return {
...acc,
[packageName]: this.extractProductionDependencyTree(dependency),
}
} catch (error) {
if (isOptional) {
return acc
}
throw error
}
}, {})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ importers:
dependencies:
electron-clear-data:
specifier: ^1.0.5
version: 1.0.5(electron@34.2.0)
version: 1.0.5(electron@35.0.1)
optionalDependencies:
debug:
specifier: 3.1.0
Expand Down Expand Up @@ -39,8 +39,8 @@ packages:
'@types/[email protected]':
resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==}

'@types/node@20.17.19':
resolution: {integrity: sha512-LEwC7o1ifqg/6r2gn9Dns0f1rhK+fPFDoMiceTJ6kWmVk6bgXBI/9IOWfVan4WiAavK9pIVWdX0/e3J+eEUh5A==}
'@types/node@22.13.10':
resolution: {integrity: sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==}

'@types/[email protected]':
resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==}
Expand Down Expand Up @@ -108,8 +108,8 @@ packages:
peerDependencies:
electron: '>= 1.2.2'

electron@34.2.0:
resolution: {integrity: sha512-SYwBJNeXBTm1q/ErybQMUBZAYqEreBUqBwTrNkw1rV4YatDZk5Aittpcus3PPeC4UoI/tqmJ946uG8AKHTd6CA==}
electron@35.0.1:
resolution: {integrity: sha512-iQonj6lnPhqfqha2KXx6LzV1dnu6UPTCWK+b7f9Zvg828umGemi22DKbcJ3/q+Opn7iUVTWyqp9z1JQqkIi6OA==}
engines: {node: '>= 12.20.55'}
hasBin: true

Expand Down Expand Up @@ -280,8 +280,8 @@ packages:
resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==}
engines: {node: '>=10'}

undici-types@6.19.8:
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}

[email protected]:
resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}
Expand Down Expand Up @@ -319,26 +319,26 @@ snapshots:
dependencies:
'@types/http-cache-semantics': 4.0.4
'@types/keyv': 3.1.4
'@types/node': 20.17.19
'@types/node': 22.13.10
'@types/responselike': 1.0.3

'@types/[email protected]': {}

'@types/[email protected]':
dependencies:
'@types/node': 20.17.19
'@types/node': 22.13.10

'@types/node@20.17.19':
'@types/node@22.13.10':
dependencies:
undici-types: 6.19.8
undici-types: 6.20.0

'@types/[email protected]':
dependencies:
'@types/node': 20.17.19
'@types/node': 22.13.10

'@types/[email protected]':
dependencies:
'@types/node': 20.17.19
'@types/node': 22.13.10
optional: true

[email protected]:
Expand Down Expand Up @@ -394,14 +394,14 @@ snapshots:
[email protected]:
optional: true

[email protected](electron@34.2.0):
[email protected](electron@35.0.1):
dependencies:
electron: 34.2.0
electron: 35.0.1

electron@34.2.0:
electron@35.0.1:
dependencies:
'@electron/get': 2.0.3
'@types/node': 20.17.19
'@types/node': 22.13.10
extract-zip: 2.0.1
transitivePeerDependencies:
- supports-color
Expand Down Expand Up @@ -587,7 +587,7 @@ snapshots:
[email protected]:
optional: true

undici-types@6.19.8: {}
undici-types@6.20.0: {}

[email protected]: {}

Expand Down
Loading