3 ms·
I use the ESM dependency to load ESM modules as a CJS shim: https://www.npmjs.com/package/esm https://www.npmjs.com/package/esm I highly recommend it. Really
by no_wizard 6y ago
I use the ESM dependency to load ESM modules as a CJS shim:
https://www.npmjs.com/package/esm https://www.npmjs.com/package/esm
I highly recommend it. Really let’s you unify on ESM modules without much thought
- chrisweekly 6y agoHow did this escape my attention till now? Thanks for the link! :)
- jcheng 6y agoFor those who, like me, wondered how this is possible without hitting the top-level await obstacle mentioned in the article, the options doc includes this line (emphasis mine): > "await":false - A boolean for top-level await in modules without ESM exports. (Node 10+) So, yeah, seems to rely on "most ESM modules don't use top-level await". Seems like a useful option to have, thanks!
- jkrems 6y agoAnother similar option is `@babel/cli` which also allows using module syntax with require-like semantics. It's a bit more widely supported in other tools which can be an advantage.