-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add ESM wrapper to avoid dual package hazard #842
Conversation
Needs testing before we can continue.
For my findings re: general interop between bundlers, I tested Webpack, Parcel, Rollup, esbuild, and Vite. For Webpack, Parcel, Rollup, and esbuild, I can get the dual package hazard to occur and can confirm installing the fix tarball fixes the problem in all 4 bundlers. For Vite, I can't seem to get the dual package hazard to occur. I tried various incantations in my |
Investigations into tree shaking look good as well. No significant difference between bundle sizes between the current 1.0 and this version. Tried with both direct and intermediary examples, using webpack, esbuild, and parcel. Parcel was the only slight outlier in that I couldn't get tree shaking to work at all, regardless of which version I used |
Interesting. I see that too. But, when building a bundle with Vite, I can't get it to fail. I pushed up my changes to the |
Thanks, @paul-sachs. Can you push the code up? It does not need to be polished at all, just repeatable. |
@timostamm pushed up to your dual-package-hazard-example. Just need to run |
This is great! I appreciate all the work and research that went into this. Looking forward to the next release :) |
This fixes the dual package hazard with the solution proposed in bufbuild/protobuf-es#509 (comment).
We've tested the approach in connectrpc/examples-es#1002 in various versions of Node.js, esbuild, parcel, rollup, vite, and webpack. Tree-shaking continues to work as expected with the "module" condition, and the dual package hazard is resolved with the esm wrappers in the "import" condition.
Note that we bump dependencies on
@bufbuild/protobuf
to^1.3.3
with this PR, meaning that 1.3.3 or later needs to be installed. This is necessary because users are very likely to run into a dual package hazard otherwise.