protobuf-es icon indicating copy to clipboard operation
protobuf-es copied to clipboard

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

Open mcmxcdev opened this issue 1 year ago • 2 comments

[email protected] 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

mcmxcdev avatar Mar 27 '24 02:03 mcmxcdev

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).

timostamm avatar Mar 27 '24 11:03 timostamm

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.

mcmxcdev avatar Mar 27 '24 13:03 mcmxcdev

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.

timostamm avatar Jun 06 '24 14:06 timostamm