Publish TypeDORM packages in ESM & CJS instead of UMD
See original GitHub issueHello,
I am trying to use this nice library in some AWS lambda functions, but I am facing issues with bundling with both esbuild and webpack. Webpack is complaining with:
WARNING in ./node_modules/@typedorm/common/index.js 13:24-31
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
What is the reason of publishing this library as UMD?
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (10 by maintainers)
Top Results From Across the Web
Publish ESM and CJS in a single package
A short tutorial of shipping both ESM and CJS dual formats in a single NPM package.
Read more >What the heck are CJS, AMD, UMD, and ESM in Javascript?
When CJS imports, it will give you a copy of the imported object. CJS will not work in the browser. It will have...
Read more >How to Create a Hybrid NPM Module for ESM and ...
Creating a single NPM module that works in all environments.
Read more >What is the easiest way to pack and publish an npm module?
Bundle it to UMD with rollup (it creates smaller bundles then Webpack ... Publish compiled files as esm + cjs when in package.json...
Read more >Build a Modern JS Project - #5 Rollup with CJS, ESM & UMD
In this next episode, we'll configure a build setup in our project. Our source code will define React components and export them via...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mathieubrd This will get resolved soon and will be available in the Beta channel, latest by the end of the week next week.
Meanwhile, I would suggest skipping the TypeDORM packages from the bundle and installing it as external modules, when running in Lambda.
Thanks for your quick response, and the library in general.
If I may be so blunt: isn’t that a bit of an old way of thinking about it? By publishing like this you’re essentially making your code un-bundle-able by commonly used bundlers such as
esbuild
,swc
,rollup
,...
. Webpack does its very best but issues a gazillionCritical
warnings such asCritical dependency: require function is used in a way in which dependencies cannot be statically extracted
.I would argue that:
2017
: https://jakearchibald.com/2017/es-modules-in-browsers/ which is 5 years ago.Doesn’t it make more sense to make your library more bundle-able and tree-shake-able to help progress the web, while still allowing people that really need to support older browsers (but having the burden on them in that case)?