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

Can you support ES Module mode, meaning that the .cz-config.js configuration file should also work if renamed to .cz-config.cjs? #241

Open
cwjbjy opened this issue Jul 31, 2024 · 3 comments

Comments

@cwjbjy
Copy link

cwjbjy commented Jul 31, 2024

In the read-config-file.js file, the readConfigFile function has a parameter CZ_CONFIG_NAME that defaults to .cz-config.js and does not support .cz-config.cjs.

@PabloBagliere
Copy link

Hello, maybe it's a bit late, but in case someone else has the same issue where the file isn't read if it's .cjs, and you don't want/can't change the type: "module" in your package.json, here is my solution based on your code.

Rename the file to include .json at the end, and convert the module.exports content to a regular JSON structure. I named my file .cz-config.js.json, and with this, it works because their readConfigFile function, if it doesn't find a .js file, will try with .json.

I hope this helps someone facing the same issue.

Best regards.

@aushamim
Copy link

aushamim commented Jan 24, 2025

Hello, maybe it's a bit late, but in case someone else has the same issue where the file isn't read if it's .cjs, and you don't want/can't change the type: "module" in your package.json, here is my solution based on your code.

Rename the file to include .json at the end, and convert the module.exports content to a regular JSON structure. I named my file .cz-config.js.json, and with this, it works because their readConfigFile function, if it doesn't find a .js file, will try with .json.

I hope this helps someone facing the same issue.

Best regards.

Finally, was able to run it. Thanks, man!

@Aresnine
Copy link

Aresnine commented Feb 7, 2025

you alose set "config": {
"commitizen": {
"path": "node_modules/cz-customizable/standalone.js"
},
"cz-customizable": {
"config": "./.cz-config.cjs"
}
}

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

4 participants