-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
Hi, We are using `protoc-gen-es` to generate TypeScript files for our protobuf messages. In our project, there are unused messages that get compiled into JavaScript files but are not imported anywhere. Since we're using Vite, which relies on Rollup for bundling, Rollup does not remove makeMessageType function calls from the output bundle, as seen in the example below: ```js f.makeMessageType("blacklist.SearchUnblacklistsByPhonesResponse", () => [{ no: 1, name: "unblacklisted_phones", kind: "scalar", T: 9, repeated: !0 }]); ``` Rollup assumes that `f.makeMessageType` may have side effects (such as mutating the global state), leading to unnecessary code being included in the final bundle. As a result, our bundle size has doubled, becoming significantly larger. To address this issue, I've added the `/*@__PURE__*/` annotation before `makeMessageType` function calls. This informs Rollup that these function calls do not have any side effects, as documented in the [Rollup configuration options](https://rollupjs.org/configuration-options/#treeshake-annotations). Adding this annotation will allow Rollup to better optimize the output bundle by eliminating unused code. If you have any suggestions for a better solution or improvements, please leave a comment. Thank you!
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.