bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
328 stars 85 forks source link

Allow user to have custom package.json inside electron app #156

Closed dhrn closed 2 years ago

dhrn commented 2 years ago

Describe the bug Build size 120 MB with hello world app.

To Reproduce Create Electron with angular hello world app

Expected behavior

As a user, i should be able to control the dependency along with lock file.

Desktop (please complete the following information):

Additional context

bennymeg commented 2 years ago

It is possible, just use the --generatePackageJson option. Also, unused libs should get pruned automatically. The app size sound OK, only electron uses around 100MB.

dhrn commented 2 years ago

I have tried to unpack the build, it looks like it is taking all the deps from the angular app. Ideally we don't need any angular dependency

We should allow the user to have more control over what they are doing. i.e If we generate the package json and we also should consider package-lock.json

apps
  - ng-app
  -  electron-app
      - package.json
      - package-lock.json

Allow the to user to provide the the own package.json, some thing like this, In angular json



{

   "package": {
     "options": {
         "generatePackageJson": false,
         "packageJsonPath":  "path to package with lock file" 
     }
    }

   "make": {
     "options": {
         "generatePackageJson": false,
         "packageJsonPath":  "path to package with lock file" 
     }
    }

}```
bennymeg commented 2 years ago

The path is the dist/apps/[app-name]/. You can manually edit the package.json file in the build folder before you package your application (if you do not wish to use the automatic generator).

dhrn commented 2 years ago

wait, I would like to configure the pipeline for builds, doing it manually is not correct option. I would like to address it from the NX way, It is great if this is handled from the library side.

bennymeg commented 2 years ago

generatePackageJson generates a slim package.json automatically for the project, moreover, the packaging process prunes any unused packages automatically. If both of them include some library that is not needed in the final package, you will need to write a script that does this on you behalf before you package the application.

theryansmee commented 2 years ago

It seems like the slim package.json is generated but then ignored. It looks like it just bundles in every dependency that isn't dev dependencies.. This means that I end up with a 446mb make rather than 120mb make that I get with a non-nx project I created. Is there any way to define which packages get put in? (Sorry I know this is closed)