-
Notifications
You must be signed in to change notification settings - Fork 914
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
require() of ES Module /xxx/commitlint.config.js from /xxx/node_modules/cosmiconfig/dist/loaders.js not supported. Instead change the require of commitlint.config.js in /xxx/node_modules/cosmiconfig/dist/loaders.js to a dynamic import() which is available in all CommonJS modules. #3768
Comments
@joberstein you got an idea? |
Can you try if this works with the latest node v18? (Node.js 18.18.2) |
Still not working in node 18.18.2
|
Maybe introduced in v18.4.0? |
I guess so, yes. 18.3 working for you? |
Strangely, I deleted the
The problem seems to be with |
That's weird. Does v17 work? |
It can be determined that the problem lies in |
a2b65fc#diff-3e90d2800eb60d709cca92472b333763ede7d37114de0ce47a0fd25593f214c2R98 When |
Thanks for the digging. Do you have time for a PR maybe? |
Sorry, PR3772 used the wrong email address |
@escapedcat @pfdgithub I'd like to simplify the original implementation for this - basically use the async loaders if dynamic await is supported (node > 20.8.0) OR config is an ESM module application. Otherwise, use the sync loaders. I almost have some additional tests ready to push to cover additional cases, and code changes are minor, similar to the PR. Unfortunately, this specific case can't be covered in the Jest tests; trying to use the dynamic import in node < 20.8.0 will cause a seg fault and prevent the test from finishing. But I was able to verify the change manually with linking to another repo. I also noticed that the resolve extends package doesn't do well with ESM since it uses require to load additional extended config, but I wasn't able to get something working for that. I can make a new issue to address it since it's unrelated. |
So people who use v20 should use at least use 20.8? Sounds good to me.
Is this part of or just #3705 maybe? Thanks for all your work! |
Technically the async loaders will work in source code with other node versions, but for the purposes of the tests, the sync loaders should be used (this was also the previous behavior because before cosmiconfig 8.2.0, the async loaders used commonJS like the sync loaders do now). I've set up the tests to skip the ones that would cause Jest to crash. The resolve-extends issue might be resolved by #3705; is that updating the entire package to use ESM? There may be similar test issues as the ones seen in the cosmiconfig update as a heads up. |
That issue is just a reminder that commitlint in general should be switched to ESM. I opened this up because we already have dep updates being blocked by this (at least I think that's the case). |
Expected Behavior
When I upgrade
commitlint
to the latest version in an ESModule project and trigger thecommit-msg
hook, the following error will appear:package.json
commit-msg
commitlint.config.js
cosmiconfig version
Current Behavior
No response
Affected packages
Possible Solution
No response
Steps to Reproduce
Context
No response
commitlint --version
@commitlint/cli@18.4.1
git --version
git version 2.39.2 (Apple Git-143)
node --version
v18.17.0
The text was updated successfully, but these errors were encountered: