Skip to content
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

Add support for CommonJs #58

Closed
damartripamungkas opened this issue Dec 24, 2023 · 3 comments
Closed

Add support for CommonJs #58

damartripamungkas opened this issue Dec 24, 2023 · 3 comments

Comments

@damartripamungkas
Copy link

please add for support commonJs

@sindresorhus
Copy link
Owner

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Dec 25, 2023
@damartripamungkas
Copy link
Author

No plans for that.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

yes I know that, but await import(...) doesn't support compiling packages like vercel/pkg does

@jjangga0214
Copy link

jjangga0214 commented Dec 25, 2023

@damartripamungkas He knows that but already decided and migrated many packages from CJS to pure ESM.
Rolling back would not be an option from a realistic viewpoint..
It's a price to pay, and this discrepancy will encourage folks to move to ESM more rapidly than before, leading to the eventual progress of the entire ecosystem.
I also transformed my projects to ESM faster than I thought, because I wanted to use his latest packages.

If you need to use CJS without import(), then

  1. Use Timers Promises API as an alternative to delay, if your node's version supports it. (e.g. await setTimeout(1000) for sleeping 1 sec)
  2. Otherwise, just clone(or copy-paste) the delay package and convert it to CJS. It's just a single-file package. Maybe you can publish it like @damartripamungkas/delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants