Skip to content
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

fix: correct native dependency tree mismatch in app-builder rebuild #8450

Merged
merged 3 commits into from
Sep 13, 2024
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
6 changes: 6 additions & 0 deletions .changeset/chatty-rice-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"app-builder-lib": patch
"electron-builder": patch
---

fix: correct native dependency tree mismatch in app-builder rebuild
8 changes: 4 additions & 4 deletions packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export class Packager {

private nodeDependencyInfo = new Map<string, Lazy<Array<any>>>()

getNodeDependencyInfo(platform: Platform | null): Lazy<Array<NodeModuleInfo | NodeModuleDirInfo>> {
let key = ""
getNodeDependencyInfo(platform: Platform | null, flatten: boolean = true): Lazy<Array<NodeModuleInfo | NodeModuleDirInfo>> {
let key = "" + flatten.toString()
let excludedDependencies: Array<string> | null = null
if (platform != null && this.framework.getExcludedDependencies != null) {
excludedDependencies = this.framework.getExcludedDependencies(platform)
Expand All @@ -144,7 +144,7 @@ export class Packager {

let result = this.nodeDependencyInfo.get(key)
if (result == null) {
result = createLazyProductionDeps(this.appDir, excludedDependencies)
result = createLazyProductionDeps(this.appDir, excludedDependencies, flatten)
this.nodeDependencyInfo.set(key, result)
}
return result
Expand Down Expand Up @@ -542,7 +542,7 @@ export class Packager {
frameworkInfo,
platform: platform.nodeName,
arch: Arch[arch],
productionDeps: this.getNodeDependencyInfo(null) as Lazy<Array<NodeModuleDirInfo>>,
productionDeps: this.getNodeDependencyInfo(null, false) as Lazy<Array<NodeModuleDirInfo>>,
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions packages/app-builder-lib/src/util/packageDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Lazy } from "lazy-val"
import { executeAppBuilderAsJson } from "./appBuilder"

export function createLazyProductionDeps(projectDir: string, excludedDependencies: Array<string> | null) {
export function createLazyProductionDeps<T extends boolean>(projectDir: string, excludedDependencies: Array<string> | null, flatten: T) {
return new Lazy(async () => {
const args = ["node-dep-tree", "--flatten", "--dir", projectDir]
const args = ["node-dep-tree", "--dir", projectDir]
if (flatten) args.push("--flatten")
if (excludedDependencies != null) {
for (const name of excludedDependencies) {
args.push("--exclude-dep", name)
}
}
return executeAppBuilderAsJson<Array<any>>(args)
return executeAppBuilderAsJson<Array<T extends true ? NodeModuleInfo : NodeModuleDirInfo>>(args)
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/cli/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function installAppDeps(args: any) {
frameworkInfo: { version, useCustomDist: true },
platform: args.platform,
arch: args.arch,
productionDeps: createLazyProductionDeps(appDir, null),
productionDeps: createLazyProductionDeps(appDir, null, false),
},
appDir !== projectDir
)
Expand Down
Loading