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

Upgrade TypeScript to v5 in @bufbuild/protoplugin to reduce install size for users #763

Closed
mcmxcdev opened this issue Mar 27, 2024 · 3 comments

Comments

@mcmxcdev
Copy link

typescript@4.5.2 clocks in at 62 MB disk size after installation (biggest dependency in our node_modules) and leads to our project having both TypeScript v5 and v4 installed in parallel.

Please upgrade the dependency to reduce load on the end users, see: https://github.com/bufbuild/protobuf-es/blob/main/packages/protoplugin/package.json#L41

@timostamm
Copy link
Member

The dependency is used to transpile TypeScript code to the targets js and dts. This mechanism is used when a plugin only provides a generator function for TypeScript.

We're pinned to this specific version of TypeScript because TypeScript makes breaking changes in minor versions. Updating is likely to break users relying on the mechanism, and it would not solve the issue since we still have to pin a version, and end users will still end up with two versions of TypeScript installed if the versions don't match. We cannot relax the constraint because this means code generation results become unstable, depending on the version of TypeScript installed by the end user.

Going forward, we will change the behavior, and either 1) let plugin authors opt in to transpilation by bringing their own version of TypeScript, or 2) update to a later and smaller version of TypeScript, possibly bundled. Since this is a breaking change, it will need to wait for v2 (which we are already working on).

@mcmxcdev
Copy link
Author

Thanks for the detailed explanation, it makes sense!

Both proposed options sound reasonable, glad to hear that I asked for this in time for v2.

@timostamm
Copy link
Member

We've looked into making the typescript dependency optional, but couldn't find a good way to do that without hurting the experience for users who want to write their own plugin.

We've update to TypeScript 5.4.5 instead in #879, which has a much smaller install size (32.4MB instead of 62).

This change applies to the upcoming v2 because it is a breaking change.

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

2 participants