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

Drop default import of global Command (for CommonJS) #2016

Closed
shadowspawn opened this issue Sep 15, 2023 · 1 comment
Closed

Drop default import of global Command (for CommonJS) #2016

shadowspawn opened this issue Sep 15, 2023 · 1 comment
Labels
semver: major Releasing requires a major version bump, not backwards compatible

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Sep 15, 2023

The default import of a global Command object (aka program) has been out of favour since Commander v5, deprecated since v7, removed from the TypeScript in v8, and never implemented for the explicit esm support (#1440).

In general with the deprecated features and behaviours, I am willing to leave them alone until they cause problems rather than aggressively remove them, to minimise breaking changes when people upgrade from old versions of Commander.

The global Command object was involved in recent problems with TypeScript (#2013 #2014), so I am suggesting removing it while I am still annoyed! 😠

To be clear, this will still work:

const { program } = require('commander');
program.parse();

And this:

const commander = require('commander');
const program = new commander.Command();
program.parse();

But this won't work anymore:

const commander = require('commander');
commander.parse();
@shadowspawn shadowspawn added the semver: major Releasing requires a major version bump, not backwards compatible label Sep 15, 2023
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Sep 15, 2023
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Feb 3, 2024
@shadowspawn
Copy link
Collaborator Author

Released in Commander v12.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: major Releasing requires a major version bump, not backwards compatible
Projects
None yet
Development

No branches or pull requests

1 participant