joshbolduc / vscode-commitlint

commitlint integration for VS Code
MIT License
11 stars 1 forks source link

`commitlint >= 19` breaks the extension #753

Closed paduszyk closed 3 months ago

paduszyk commented 5 months ago

Hi!

My .commitlintrc.js:

/**
 * Commitlint
 * https://commitlint.js.org/#/reference-configuration
 */

const Configuration = {
  extends: ["@commitlint/config-conventional"],
};

module.exports = Configuration;

Everything went smoothly until I upgraded commitlint to v19 (19.0.3, to be more specific).

Now my output (as I am typing anything into commit message field of the Git panel) is as follows:[^1]

loading @commitlint/parse dynamically via /Users/kamil/GitHub/reactor/node_modules/@commitlint/parse/lib/index.js
Uncaught exception: Error: require() of ES Module /Users/kamil/GitHub/reactor/node_modules/@commitlint/parse/lib/index.js from /Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js not supported.
Instead change the require of index.js in /Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js to a dynamic import() which is available in all CommonJS modules.
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kamil/GitHub/reactor/node_modules/@commitlint/parse/lib/index.js from /Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js not supported.
Instead change the require of index.js in /Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js to a dynamic import() which is available in all CommonJS modules.
    at Function.<anonymous> (node:electron/js2c/node_init:2:13357)
    at h._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:173:5634)
    at n._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:170:29786)
    at t._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:35289)
    at Module.require (/Users/kamil/.vscode/extensions/github.copilot-chat-0.13.0/dist/extension.js:9:42349)
    at h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:647)
    at pt (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:1:3186)
    at j (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:1:3289)
    at xt (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:1:3665)
    at wt (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:4:1249)
    at re (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:6:1234)
    at async ne (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:6:629)
    at async Rt (/Users/kamil/.vscode/extensions/joshbolduc.commitlint-2.4.7/dist/extension.js:6:1510)

[^1]: I have checked that downgrading to cli==18.6.1 and conventional-config==18.6.2 fixes the problem.

paduszyk commented 5 months ago

Potentially related to alessandrojcm/commitlint-pre-commit-hook#152.

joshbolduc commented 5 months ago

Thanks for the report! Yes, it looks like this is due to commitlint v19 supporting ESM only. The fix seems straightforward; I'll look to have this fixed in the next day or so.

joshbolduc commented 5 months ago

Unfortunately this did not work the way I thought it did and I had to revert it due to the issue raised in #755. I have an idea to resolve this again, but will require some more work.

joshbolduc commented 3 months ago

2.6.0 is now out and should take care of this. Thanks for your patience!

skwde commented 3 months ago

@joshbolduc, I hate to bring the bad news, but it still seems broken for v19. https://github.com/joshbolduc/vscode-commitlint/issues/784 still doesn't work with extension version 2.6.0

# npm list -g
/opt/conda/lib
├── @commitlint/cli@19.3.0
├── @commitlint/config-conventional@19.2.2

And the extension output:

loading @commitlint/parse dynamically via /opt/conda/lib/node_modules/@commitlint/cli/node_modules/@commitlint/parse/lib/index.js
loading @commitlint/load dynamically via /opt/conda/lib/node_modules/@commitlint/cli/node_modules/@commitlint/load/lib/load.js
loading @commitlint/lint dynamically via /opt/conda/lib/node_modules/@commitlint/cli/node_modules/@commitlint/lint/lib/lint.js
Load config error stack:
Error: Cannot find module "@commitlint/config-conventional" from "/workspaces/docs"

The downgrade to v18.6.3 still works.

ChristopherBull commented 3 months ago

I wanted to add that it worked for me. I checked the extension had updated to v2.6.0, restarted it under the Extensions tab, updated my commitlint dependencies to v19.x.x, and it started working. I then updated my repo config to a module (details here: ChristopherBull/demo-semantic-release/issues/2) and that also worked.

Thanks.