-
Notifications
You must be signed in to change notification settings - Fork 9
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
Distribute CommonJS for projects that cannot use ESM #444
Conversation
hey @ReallyBadNews Thanks for the PR. import {Cloudinary} from '@cloudinary/url-gen/bundles/umd/base.js' In fact, if you're using a modern NodeJS version and the |
Hi @patrick-tolosa, thanks for the response. I did get the UMD bundle working with our application. It does appear however that the typescript definitions are broken for those imports, and we obviously lose any ability to do tree-shaking with only a single entry point. The typescript defs work when importing from https://codesandbox.io/s/quiet-sound-453yf?file=/pages/index.tsx |
Please open an issue regarding the incorrect types for the UMD package, (since this PR doesn't discuss or resolve this issue) Regarding tree shaking, from what I understand your feature request is to add a CommonJS separate bundle to allow for individual imports. If you'd like to modify this PR to support that we'll be happy to take a look, in any case this is something we'll take internally to discuss and design the right approach. |
@patrick-tolosa I went ahead and opened #445 for the umd typescript definitions. I updated the PR to support both CommonJS and ESM via rollup . It keeps the same dist structure while changing the package.json's The package.json's conditional exports and the corresponding function that generates those have been updated to support the import / require syntax Thanks again, and please let me know if you folks have any concerns or code review. |
Right, so this PR does a few things (Not against it, just to keep track).
All in all this looks good, but can you please consider taking a look at the broken build? |
@patrick-tolosa to clarify
I assumed that the failing build was the bundle size tests, I'll look into that! EDIT: those tests are passing now. |
@ReallyBadNews we reviewed the latest changes and they look great but we would like for the bundle size to not increase. We would also prefer not to modify the original build process. |
Signed-off-by: Kenny Elshoff <[email protected]>
@strausr, I went back to using the typescript compiler for the esm output, so all the bundle size tests pass at their original thresholds and the esm build process remains unmodified. I've also updated the Rollup plugin packages to use the newer |
@ReallyBadNews - Thanks for your contribution! We've finished our review process and we'll release this addition in the next coming release. |
Thanks @patrick-tolosa and @strausr I appreciated the help! |
Pull request for @cloudinary/url-gen
What does this PR solve?
ES6 is great, and we all love writing it but we have several projects that cannot consume ESM and in which we cannot add additional build steps to transpile ES6 code to a suitable format.
This PR builds CommonJS in lieu of ESM via the Typescript compiler.
Final checklist