diff --git a/.changeset/chatty-rice-hunt.md b/.changeset/chatty-rice-hunt.md new file mode 100644 index 00000000000..58969cbde6c --- /dev/null +++ b/.changeset/chatty-rice-hunt.md @@ -0,0 +1,6 @@ +--- +"app-builder-lib": patch +"electron-builder": patch +--- + +fix: correct native dependency tree mismatch in app-builder rebuild diff --git a/packages/app-builder-lib/src/packager.ts b/packages/app-builder-lib/src/packager.ts index cbecdf4c5c5..8fb8d38d544 100644 --- a/packages/app-builder-lib/src/packager.ts +++ b/packages/app-builder-lib/src/packager.ts @@ -133,8 +133,8 @@ export class Packager { private nodeDependencyInfo = new Map>>() - getNodeDependencyInfo(platform: Platform | null): Lazy> { - let key = "" + getNodeDependencyInfo(platform: Platform | null, flatten: boolean = true): Lazy> { + let key = "" + flatten.toString() let excludedDependencies: Array | null = null if (platform != null && this.framework.getExcludedDependencies != null) { excludedDependencies = this.framework.getExcludedDependencies(platform) @@ -145,7 +145,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 @@ -543,7 +543,7 @@ export class Packager { frameworkInfo, platform: platform.nodeName, arch: Arch[arch], - productionDeps: this.getNodeDependencyInfo(null) as Lazy>, + productionDeps: this.getNodeDependencyInfo(null, false) as Lazy>, }) } } diff --git a/packages/app-builder-lib/src/util/packageDependencies.ts b/packages/app-builder-lib/src/util/packageDependencies.ts index d7e00a2aaf9..907c452ec59 100644 --- a/packages/app-builder-lib/src/util/packageDependencies.ts +++ b/packages/app-builder-lib/src/util/packageDependencies.ts @@ -1,15 +1,16 @@ import { Lazy } from "lazy-val" import { executeAppBuilderAsJson } from "./appBuilder" -export function createLazyProductionDeps(projectDir: string, excludedDependencies: Array | null) { +export function createLazyProductionDeps(projectDir: string, excludedDependencies: Array | 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>(args) + return executeAppBuilderAsJson>(args) }) } diff --git a/packages/electron-builder/src/cli/install-app-deps.ts b/packages/electron-builder/src/cli/install-app-deps.ts index ae7779fb535..30f506bd7ae 100644 --- a/packages/electron-builder/src/cli/install-app-deps.ts +++ b/packages/electron-builder/src/cli/install-app-deps.ts @@ -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 )