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

cli: how to generate static code only for necessary types? #1781

Open
mahnunchik opened this issue Jul 28, 2022 · 3 comments
Open

cli: how to generate static code only for necessary types? #1781

mahnunchik opened this issue Jul 28, 2022 · 3 comments

Comments

@mahnunchik
Copy link

protobuf.js version: 7.0.0
protobufjs-cli version: 1.0.0

How to generate static code only for necessary types from big definitions?

Current version generates static code for all types defined in protocol.proto:

pbjs --es6 --wrap=es6 --target=static-module --out=lib/protocol.js protocol.proto

I'd like to have an option like --types=Transaction,Contract to generate static code only for Transaction and Contract types.

Motivation: reduce javascript bundle size.

@imirkin
Copy link

imirkin commented Aug 2, 2022

There's a --sparse option which will only generate the protos defined/used in protocol.proto. So if you split things up so that all your js-needed protos were referenced in some file, you could use that as the input. The --sparse option has some issues with nested types sometimes, but there's a PR here #1528 which address them.

@vpluschen
Copy link
Contributor

vpluschen commented Dec 25, 2022

I found a solution, Eventually I cut myfile from 100,000 lines to 10,000.
and i think it's more easy to use than --sparse.

pr here: #1840

@mescoalex
Copy link

mescoalex commented Dec 27, 2022

I found a solution, Eventually I cut myfile from 100,000 lines to 10,000. and i think it's more easy to use than --sparse.

pr here: #1840

Nice job, I have been waiting this feature for 6 months.

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

No branches or pull requests

4 participants