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

feat: add CJS export for cz-commitlint #3963

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions @commitlint/cz-commitlint/package.json
Expand Up @@ -4,6 +4,10 @@
"version": "19.0.3",
"description": "Commitizen adapter using the commitlint.config.js",
"main": "./lib/index.js",
"exports": {
"import": "./lib/index.js",
"require": "./lib/index.cjs"
},
"files": [
"lib"
],
Expand Down
7 changes: 7 additions & 0 deletions @commitlint/cz-commitlint/src/index.cts
@@ -0,0 +1,7 @@
const esmPrompterPromise = import('./index.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking to use typeof import('./index.js') but I found there was a TypeScript error (I believe it's a bug), but considering this, I'm thinking to use <packageDir>/index.cjs which is plain js instead.

Basically it should be await import('./lib/index.js')

@frantic1048 How do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's weird and I'm trying to use cjs to workaround this.

I was thinking to use typeof import('./index.js') but I found there was a TypeScript error


export const prompter: Awaited<typeof esmPrompterPromise>['prompter'] = async (
...args
) => {
(await esmPrompterPromise).prompter(...args);
};