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

Error running commitlint require() of ES Module #758

Closed
VictorPulzz opened this issue Mar 3, 2024 · 2 comments
Closed

Error running commitlint require() of ES Module #758

VictorPulzz opened this issue Mar 3, 2024 · 2 comments

Comments

@VictorPulzz
Copy link

Problem description
When tried to run the action received the follow error:
require() of ES Module /github/workspace/node_modules/@commitlint/config-conventional/lib/index.js from /node_modules/@commitlint/resolve-extends/lib/index.js not supported...

Screenshot:
image

Adicional info
My workflow file:

name: Release

#on:
#  push:
#    branches:
#      - master

on:
  workflow_dispatch:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install dependencies
        run: npm ci

      - name: Unit tests
        run: npm test

      - name: Reset changes from integration unit tests
        run: git reset --hard HEAD

      - name: Build
        run: npm run build

      - name: Type check
        run: npm run check-types

      - name: Code linting check
        run: npm run lint

      - name: Code formatting
        run: npm run prettier

      - name: Commit formatting check
        uses: wagoid/commitlint-github-action@v5
@baumac
Copy link

baumac commented Mar 6, 2024

Per the package.json files it seems that this action is coupled to commitlint v18 https://github.com/wagoid/commitlint-github-action/blob/master/package.json#L27-L34

The underlying issue in commitlint v19 of that you report is that require imports needed to be replaced with dynamic imports.

For example in the commitlint.config.js file v18 works with:

const {
  utils: { getPackages }
} = require('@commitlint/config-lerna-scopes')

module.exports = {
  extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes'],
  rules: {
    'scope-enum': async (ctx) =>  { 
        return [2, 'always', [...(await getPackages(ctx)), 'release', 'deps', '*']]
    }
  }
}

And commitlint v19 needs this updated to be:

module.exports = {
  extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes'],
  rules: {
    'scope-enum': async (ctx) => {
      const {
        default: {
          utils: { getPackages }
        }
      } = await import('@commitlint/config-lerna-scopes')

      return [2, 'always', [...(await getPackages(ctx)), 'release', 'deps', '*']]
    }
  }
}

jdbruijn added a commit to vidavidorra/github-action-app-user that referenced this issue Mar 25, 2024
jdbruijn added a commit to vidavidorra/create-project that referenced this issue Mar 25, 2024
jdbruijn added a commit to vidavidorra/commitlint-config that referenced this issue Mar 25, 2024
jdbruijn added a commit to vidavidorra/.github that referenced this issue Mar 26, 2024
jdbruijn pushed a commit to vidavidorra/.github that referenced this issue Mar 26, 2024
jdbruijn added a commit to vidavidorra/renovate that referenced this issue Mar 26, 2024
jdbruijn pushed a commit to vidavidorra/renovate that referenced this issue Mar 26, 2024
@wagoid
Copy link
Owner

wagoid commented Mar 29, 2024

v6 of this action now runs on commitlint v19, closing the issue 👌

@wagoid wagoid closed this as completed Mar 29, 2024
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

3 participants