-
Notifications
You must be signed in to change notification settings - Fork 33
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
ESM and CJS outputs for packages #610
Comments
Angular 18 showing its 💔 to grpc and proto....
|
Actually, I have seen
Note that most of the other nice-grpc-* libraries are usable in both NodeJS and the browser. Only Considering targets, it's clear enough for me how to choose the target for NodeJS builds — just look at the NodeJS version support timeline. But for browsers, I've mostly followed the path of compiling to older targets to maximize browser support. However, this may be an outdated approach, because I've heard that people nowadays compile all of the |
I'd love to get a discussion going around build types (ESM, CJS, or hybrid) for the nice-grpc packages. ESM is the future, but not everyone has arrived yet. Part of arriving is getting ESM outputs everywhere. It seems that we can include both CJS and ESM builds in the same package.json when necessary.
I'm curious which packages need to support hybrid outputs, and which don't. For example,
nice-grpc-web
can probably be pure ESM as it's browser-based while the rest might benefit from having both outputs for the time being.As for figuring out the module and target, I have some data and survey of related dependencies:
all tracked
shows >= 97% support based on the lowest supported featureall tracked
shows >= 95%all tracked
shows >= 93%all tracked
shows >= 90%I think for the node case it's pretty clear we can use ES2023. Although grpc-js targets ES2017 (https://github.com/grpc/grpc-node/blob/a4c2106e63064070f3b9e580b2d1c74b0a9503a4/packages/grpc-js/tsconfig.json#L15) and that is "the" big heavy dependency. I'll say that in my own work I do custom build grpc-js on the server side to meet the same target as the rest of my software (above ES2017). I suspect others that care will do the same rather than take whatever is served on npm.
For the browser's nice-grpc-web case it is less clear. ES2020 is great and would bring some notable features. Sadly though the top web dependency is protobufjs, I think. And they compile to ES5 (https://github.com/protobufjs/protobuf.js). So our heaviest dep isn't itself compiled for the modern era: yuck. ES2020 also lacks BigInt support today (looking at you, long.js.. sigh). Though people have been bringing it up, citing similar stats as above(protobufjs/protobuf.js#1151). --- Emotionally at least, it would be nice to show solidarity in pushing the expectation of modern browser support and any potential performance benefits of not shipping ES polyfills.
So, I'd start the discussion with a proposal:
Hyrbridize all packages for ESM/CJS with ES2023 target, except nice-grpc-web. nice-grpc-web is ESM only targetting ES2020.
The text was updated successfully, but these errors were encountered: