Skip to content

chore: delete all old node module collector and legacy nativeRebuilder (BREAKING) #8889

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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/mean-beers-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"app-builder-lib": major
"electron-builder": major
---

delete all old node module collector and legacy nativeRebuilder
3 changes: 1 addition & 2 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -7328,7 +7328,6 @@
"anyOf": [
{
"enum": [
"legacy",
"parallel",
"sequential"
],
Expand All @@ -7339,7 +7338,7 @@
}
],
"default": "sequential",
"description": "Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes."
"description": "Use `@electron/rebuild` in `sequential` or `parallel` compilation modes."
},
"nodeGypRebuild": {
"default": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ export interface CommonConfiguration {
*/
readonly npmRebuild?: boolean
/**
* Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.
* Use `@electron/rebuild` in `sequential` or `parallel` compilation modes.
* @default sequential
*/
readonly nativeRebuilder?: "legacy" | "sequential" | "parallel" | null
readonly nativeRebuilder?: "sequential" | "parallel" | null

/**
* The build number. Maps to the `--iteration` flag for builds using FPM on Linux.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export async function getNodeModules(rootDir: string): Promise<NodeModuleInfo[]>
return collector.getNodeModules()
}

export { detect, getPackageManagerVersion, PM }
export { detect, getPackageManagerVersion, PM, NodeModuleInfo }
22 changes: 0 additions & 22 deletions packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { ProtonFramework } from "./ProtonFramework"
import { computeArchToTargetNamesMap, createTargets, NoOpTarget } from "./targets/targetFactory"
import { computeDefaultAppDirectory, getConfig, validateConfiguration } from "./util/config/config"
import { expandMacro } from "./util/macroExpander"
import { createLazyProductionDeps, NodeModuleDirInfo, NodeModuleInfo } from "./util/packageDependencies"
import { checkMetadata, readPackageJson } from "./util/packageMetadata"
import { getRepositoryInfo } from "./util/repositoryInfo"
import { resolveFunction } from "./util/resolve"
Expand Down Expand Up @@ -142,26 +141,6 @@ export class Packager {
return this._repositoryInfo.value
}

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

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)
if (excludedDependencies != null) {
key += `-${platform.name}`
}
}

let result = this.nodeDependencyInfo.get(key)
if (result == null) {
result = createLazyProductionDeps(this.appDir, excludedDependencies, flatten)
this.nodeDependencyInfo.set(key, result)
}
return result
}

stageDirPathCustomizer: (target: Target, packager: PlatformPackager<any>, arch: Arch) => string = (target, packager, arch) => {
return path.join(target.outDir, `__${target.name}-${getArtifactArchName(arch, target.name)}`)
}
Expand Down Expand Up @@ -575,7 +554,6 @@ export class Packager {
frameworkInfo,
platform: platform.nodeName,
arch: Arch[arch],
productionDeps: this.getNodeDependencyInfo(null, false) as Lazy<Array<NodeModuleDirInfo>>,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import asyncPool from "tiny-async-pool"
import { excludedNames, FileMatcher } from "../fileMatcher"
import { Packager } from "../packager"
import { FileCopyHelper } from "./AppFileWalker"
import { NodeModuleInfo } from "./packageDependencies"
import { NodeModuleInfo } from "../node-module-collector"
import { resolveFunction } from "./resolve"

const excludedFiles = new Set(
Expand Down
14 changes: 0 additions & 14 deletions packages/app-builder-lib/src/util/appBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { executeAppBuilder } from "builder-util"
import { SpawnOptions } from "child_process"

export function executeAppBuilderAsJson<T>(args: Array<string>): Promise<T> {
return executeAppBuilder(args).then(rawResult => {
Expand All @@ -15,19 +14,6 @@ export function executeAppBuilderAsJson<T>(args: Array<string>): Promise<T> {
})
}

export function executeAppBuilderAndWriteJson(args: Array<string>, data: any, extraOptions: SpawnOptions = {}): Promise<string> {
return executeAppBuilder(
args,
childProcess => {
childProcess.stdin!.end(JSON.stringify(data))
},
{
...extraOptions,
stdio: ["pipe", "pipe", process.stdout],
}
)
}

export function objectToArgs(to: Array<string>, argNameToValue: Record<string, string | null>): void {
for (const name of Object.keys(argNameToValue)) {
const value = argNameToValue[name]
Expand Down
3 changes: 1 addition & 2 deletions packages/app-builder-lib/src/util/appFileCopier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { Packager } from "../packager"
import { PlatformPackager } from "../platformPackager"
import { AppFileWalker } from "./AppFileWalker"
import { NodeModuleCopyHelper } from "./NodeModuleCopyHelper"
import { NodeModuleInfo } from "./packageDependencies"
import { getNodeModules } from "../node-module-collector"
import { getNodeModules, NodeModuleInfo } from "../node-module-collector"

const BOWER_COMPONENTS_PATTERN = `${path.sep}bower_components${path.sep}`
/** @internal */
Expand Down
27 changes: 0 additions & 27 deletions packages/app-builder-lib/src/util/packageDependencies.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/app-builder-lib/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { getProjectRootPath } from "@electron/rebuild/lib/search-module"
import { RebuildMode } from "@electron/rebuild/lib/types"
import { asArray, log, spawn } from "builder-util"
import { pathExists } from "fs-extra"
import { Lazy } from "lazy-val"
import { homedir } from "os"
import * as path from "path"
import { Configuration } from "../configuration"
import { executeAppBuilderAndWriteJson } from "./appBuilder"
import { PM, detect, getPackageManagerVersion } from "../node-module-collector"
import { NodeModuleDirInfo } from "./packageDependencies"
import { rebuild as remoteRebuild } from "./rebuild/rebuild"

export async function installOrRebuild(config: Configuration, appDir: string, options: RebuildOptions, forceInstall = false) {
Expand Down Expand Up @@ -160,8 +157,6 @@ function isRunningYarn(pm: PM) {

export interface RebuildOptions {
frameworkInfo: DesktopFrameworkInfo
productionDeps: Lazy<Array<NodeModuleDirInfo>>

platform?: NodeJS.Platform
arch?: string

Expand All @@ -173,7 +168,6 @@ export interface RebuildOptions {
/** @internal */
export async function rebuild(config: Configuration, appDir: string, options: RebuildOptions) {
const configuration = {
dependencies: await options.productionDeps.value,
nodeExecPath: process.execPath,
platform: options.platform || process.platform,
arch: options.arch || process.arch,
Expand All @@ -183,11 +177,6 @@ export async function rebuild(config: Configuration, appDir: string, options: Re
}
const { arch, buildFromSource, platform } = configuration

if (config.nativeRebuilder === "legacy") {
const env = getGypEnv(options.frameworkInfo, platform, arch, buildFromSource)
return executeAppBuilderAndWriteJson(["rebuild-node-modules"], configuration, { env, cwd: appDir })
}

const {
frameworkInfo: { version: electronVersion },
} = options
Expand Down
2 changes: 0 additions & 2 deletions packages/electron-builder/src/cli/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"
import { computeDefaultAppDirectory, getConfig } from "app-builder-lib/out/util/config/config"
import { orNullIfFileNotExist } from "app-builder-lib/out/util/config/load"
import { createLazyProductionDeps } from "app-builder-lib/out/util/packageDependencies"
import { installOrRebuild } from "app-builder-lib/out/util/yarn"
import { PACKAGE_VERSION } from "app-builder-lib/out/version"
import { getArchCliNames, log, printErrorAndExit, use } from "builder-util"
Expand Down Expand Up @@ -62,7 +61,6 @@ export async function installAppDeps(args: any) {
frameworkInfo: { version, useCustomDist: true },
platform: args.platform,
arch: args.arch,
productionDeps: createLazyProductionDeps(appDir, null, false),
},
appDir !== projectDir
)
Expand Down