3 ms·
> ESM can use CJS packages True. Everything is a default import, but it does work. > I have authored API SDK packages that can be used in FE and BE code. FE
by paulddraper 2y ago
> ESM can use CJS packages
True. Everything is a default import, but it does work.
> I have authored API SDK packages that can be used in FE and BE code.
FE code can't use CJS. You need to have an extra step to convert to ESM (or AMD, webpack chucks, etc).
And the general consensus is that frontend JS has too much complexity.
---
CJS works pretty well for Node.js.
If it didn't, it wouldn't have been adopted.
The primary advantage is authors can write and distribute isomorphic code. (Again, without relying on heavy or kludgy module system conversations.)