Skip to content

Commit 04be569

Browse files
beyondkmpbeyondkmp
and
beyondkmp
authored
feat: switch app-builder-bin to node-module-collector to get all production node modules (#8571)
change app-builder-bin to node-module-collector(typescript) ## Design 1. Get node modules tree from "npm list"(npm & yarn) or "pnpm list" 2. Transform the tree to dependency graph 3. Transform the graph to hoisted tree 4. Hoisted tree to node modules array ## Support - [x] npm - [x] pnpm - [x] pnpm with hosited - [x] yarn1 - [x] yarn berry(with node-modules) ## Performance vs app-builder-bin This is an IO-intensive task, primarily involving reading files and traversing the entire dependency tree. Node.js is capable of handling such IO-intensive tasks without issues. Based on my personal testing, there's essentially no difference in performance ## Advantages 1. Perfectly supports pnpm 2. Optimize packages in the node_modules within the asar file unlike the previous app-builder-bin which only searched for all node_modules without optimizing. For example, if a module has one version in the dev node_modules dependencies, another in the root node_modules, and yet another version with multiple dependencies in the production node_modules, it results in multiple duplicate modules in the production node_modules. Now, hoisting is applied in such situations, reducing these duplicate packages. --------- Co-authored-by: beyondkmp <[email protected]>
1 parent 638d3a7 commit 04be569

33 files changed

+2529
-58
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
fail-fast: false
7272
matrix:
7373
testFiles:
74-
- ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configurationValidationTest,filenameUtilTest,filesTest,globTest,ignoreTest,macroExpanderTest,mainEntryTest,urlUtilTest,extraMetadataTest,linuxArchiveTest,linuxPackagerTest,HoistedNodeModuleTest,MemoLazyTest
74+
- ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configurationValidationTest,filenameUtilTest,filesTest,globTest,ignoreTest,macroExpanderTest,mainEntryTest,urlUtilTest,extraMetadataTest,linuxArchiveTest,linuxPackagerTest,HoistedNodeModuleTest,MemoLazyTest,HoistTest
7575
- snapTest,debTest,fpmTest,protonTest
7676
- winPackagerTest,BuildTest,winCodeSignTest,webInstallerTest
7777
- oneClickInstallerTest,assistedInstallerTest

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,6 @@ See the full documentation on [electron.build](https://www.electron.build).
100100

101101
`yarn add electron-builder --dev`
102102

103-
### Note for PNPM
104-
105-
In order to use with `pnpm`, you'll need to adjust your `.npmrc` to use any one the following approaches in order for your dependencies to be bundled correctly (ref: [#6389](https://github.com/electron-userland/electron-builder/issues/6289#issuecomment-1042620422)):
106-
```
107-
node-linker=hoisted
108-
```
109-
```
110-
public-hoist-pattern=*
111-
```
112-
```
113-
shamefully-hoist=true
114-
```
115-
116-
Note: Setting shamefully-hoist to true is the same as setting public-hoist-pattern to *.
117-
118103
### Note for Yarn 3
119104

120105
Yarn 3 use PnP by default, but electron-builder still need node-modules(ref: [yarnpkg/berry#4804](https://github.com/yarnpkg/berry/issues/4804#issuecomment-1234407305)). Add configuration in the `.yarnrc.yaml` as follows:

0 commit comments

Comments
 (0)