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

fix: ESM / CJS interoperability issues with dependencies #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jorenbroekema
Copy link

Older versions of:

  • onetime
  • restore-cursor

Are CJS-only. These are transitive dependencies caused by log-update. Upgrading this one to latest, also ensures the latest versions of the above transitive dependencies are installed, and all of them publish ESM as well in these versions, so that's an easy fix.

The other issue is sisteransi which is CJS only and does not have an ESM publish, so we can just use createRequire trick to import them in a manner that's compatible with NodeJS out of the box, not requiring build tools / bundlers to handle the interoperability by transforming the module from CJS -> ESM (which is error-prone)

Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 09b8b80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/cli-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jorenbroekema! I’m not 100% sure if we’ll accept this (it’s not code I’m familiar with so will leave that decision to someone else), but left some queries.

Just for transparency: AFAIK @astrojs/cli-kit is not really intended to be used outside of Astro, so it could well be that we decide not to accept changes if they don’t resolve issues we are ourselves facing. It might be worth checking out https://github.com/bombshell-dev/clack as an alternative tool.

@@ -100,7 +102,6 @@ async function gradient(
stop() {
done = true;
stdin.removeListener("keypress", keypress);
clearInterval(interval);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? I’d expect it to be required still.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interval property was only initialized as let interval: NodeJS.Timeout; and then never used anywhere.
I'm assuming this was just a leftover of some old code that got removed.
TypeScript was complaining about it, I'm assuming the older version of TypeScript was slightly more lenient on it.

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

Successfully merging this pull request may close these issues.

2 participants