4 ms·
Awesome that this is in Node. I created require-esm-in-cjs[1] two years ago when I needed to require ESM modules in a commonJS (regular legacy) page. It is on
by sam_goody 3y ago
Awesome that this is in Node.
I created require-esm-in-cjs[1] two years ago when I needed to require ESM modules in a commonJS (regular legacy) page.
It is only a few bytes long and is simple - it effectively causes ESM modules to load synchronously by checking every 100ms if the JS has loaded before allowing the page to continue.
I have been meaning to improve it, such as adding a timeout and whatnot but never got around to it (it is good enough for my needs) - but always thought it was odd that something so (relatively) simple to hack around and so low in the stack can not be supported natively.
It gets a fair amount of downloads even though it doesn't get much visibility so I guess I am not the only one who felt the need. But native is MUCH better!
[1]: https://www.npmjs.com/package/require-esm-in-cjs https://www.npmjs.com/package/require-esm-in-cjs
- paulddraper 3y agoI read your readme, clever