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

conventional-changelog-conventionalcommits v8.0.0 no longer compatible #260

Open
djthornton1212 opened this issue May 14, 2024 · 1 comment

Comments

@djthornton1212
Copy link

Platform

GitHub Actions:
  os: ubuntu-latest
  node: v18.20.2 (default)
  npm: 10.5.0 (default)
  dependencies: conventional-changelog-conventionalcommits
  action: TriPSs/conventional-changelog-action@v5.2.1

The issue

After updating my pipeline today my changelog workflow failed with the following error:

Loading "/home/runner/work/github-actions/github-actions/.github/configs/conventional-commits/config.js" script
Error: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/github-actions/github-actions/node_modules/conventional-changelog-conventionalcommits/src/index.js from /home/runner/work/github-actions/github-actions/.github/configs/conventional-commits/config.js not supported.
Instead change the require of index.js in /home/runner/work/github-actions/github-actions/.github/configs/conventional-commits/config.js to a dynamic import() which is available in all CommonJS modules.

Troubleshooting

I began by trying to understand the nature of the error. I am by no means a JavaScript developer, so keep that in mind. As I understand it, some upstream dependency (I assumed conventional-changelog-conventionalcommits as it's the only thing I install) had changed. That change now requiring ESM rather than CommonJS... Either way I found that conventional-changelog recently updated from 7.0.2 -> 8.0.0. Searching through their changes I found conventional-changelog/conventional-changelog#1237

Next I updated my local config.js to be what I believe is ESM friendly:

'use strict'
const config = require('conventional-changelog-conventionalcommits');

module.exports = config({
    "types": [
        { type: 'ci', section: 'Continuous Integration' },
        { type: 'chore', section: 'Miscellaneous Chore' },
        { type: 'dependabot', section: 'Dependabot' },
        { type: 'deprecate', section: 'Deprecated' },
        { type: 'docs', section: 'Documentation' },
        { type: 'feat', section: 'Feature' },
        { type: 'feature', section: 'Feature' },
        { type: 'fix', section: 'Fixed' },
        { type: 'perf', section: 'Performance' },
        { type: 'refactor', section: 'Code Refactoring' },
        { type: 'release', hidden: true },
        { type: 'remove', section: 'Removed' },
        { type: 'revert', section: 'Reverts' },
        { type: 'security', section: 'Security' },
        { type: 'style', section: 'Styles' },
        { type: 'test', section: 'Tests', hidden: true },
    ]
})

->

'use strict'

async function getConfig() {
  const config = await import('conventional-changelog-conventionalcommits');

  return config.default({
    "types": [
        { type: 'ci', section: 'Continuous Integration' },
        { type: 'chore', section: 'Miscellaneous Chore' },
        { type: 'dependabot: 'Dependabot' },
        { type: 'deprecate', section: 'Deprecated' },
        { type: 'docs', section: 'Documentation' },
        { type: 'feat', section: 'Feature' },
        { type: 'feature', section: 'Feature' },
        { type: 'fix', section: 'Fixed' },
        { type: 'perf', section: 'Performance' },
        { type: 'refactor', section: 'Code Refactoring' },
        { type: 'release', hidden: true },
        { type: 'remove', section: 'Removed' },
        { type: 'revert', section: 'Reverts' },
        { type: 'security', section: 'Security' },
        { type: 'style', section: 'Styles' },
        { type: 'test', section: 'Tests', hidden: true },
    ]
  });
}

module.exports = getConfig;

This change partially worked as I no longer received any errors, however the markdown came out wonky & the version bumper wasn't working. I presume the reason that the version bumper isn't working is because the new new Bumper exported class.

Expected behavior/outcome

Honestly, I wouldn't expect this to work given the nature of the changes. However, it might be worth mentioning version compatibilities somewhere in the documentation when using a custom Config-File-Path; as I managed to get it all working again when I pinned conventional-changelog-conventionalcommits to 7.0.2.

For now, I'll leave this in place until I see an update for this action.

@TriPSs
Copy link
Owner

TriPSs commented May 15, 2024

It makes sense that it would stop breaking, the test file we have in the repo also still uses 7.0.2. Wil check when I have some time if we can update that to the latest version.

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

2 participants