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

Partial 'package.json' support #88

Closed
bennymeg opened this issue Apr 11, 2021 · 4 comments
Closed

Partial 'package.json' support #88

bennymeg opened this issue Apr 11, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bennymeg
Copy link
Owner

bennymeg commented Apr 11, 2021

Description
Add support for packaging using automatically generated partial package.json support.
This should reduce greatly the artifact size in many cases.

Additional context
This should be used in conjunction with generatePackageJson option during build time.

Rational
NX-ELECTRON projects are mainly divided into two parts: frontend and backend.
Due to the nature of a monorepo project, only single 'package.json' file exists in the repository.
Modern front end platforms (e.g. angular) can overcome this issue by picking and bundling only the dependencies that are in use.
However, that's is not always the case with electron applications development.
Moreover, since electron application might use native dependencies, such tools can't be used since it is not recommended to bundle the backend project into single file.
Hence, we have a node_modules folder in the generated package, and since the dependencies tree can be huge, this reflects in the packaged app size.

On v11 we have added the functionality to dynamically generate dependencies tree to the electron backend project.
We can take leverage of this functionality in order to shake the dependency tree for the backend project.

@bennymeg bennymeg added the enhancement New feature or request label Apr 11, 2021
@bennymeg bennymeg added this to the v12 milestone Apr 11, 2021
@bennymeg bennymeg self-assigned this Apr 11, 2021
@ronnetzer
Copy link

To add to what you've wrote,
it is essential to merge the existing package.json with the auto-generated one, so it will be bundled with the correct name, author etc. And in order to correctly support auto-updates, the version should be taken from the root package.json

Thanks for the great plugin.

@zodiac1214
Copy link

i had this crazy idea and people still think i am crazy: use dev dep everywhere will significantly reduce your artifact size
how: you can let webpack pull all dependencies (i think some webpack plugin has abitlity to pull only required function in, anyone remember the size of momentjs? ) and put into the bundle. it is the smallest artifact you can get.
BUT, it will slow down your build a lot. however, i thnk that makes sense in a desktop app, who really needs to create 1000 builds per day? (I mean you definitely should for PR build but why would you create that many "prod" build)

@Crikey-Mikey
Copy link

This feature would be great. Are there any plans to add this? It would also allow a version from the partial package.json rather than using the nx root package.json for versioning. Unless I'm missing something?

@bennymeg
Copy link
Owner Author

Added on v12.
Take a look at generatePackageJson and impliciteDependencies options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants