Error running commitlint require() of ES Module
VictorPulzz opened this issue · 2 comments
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...
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
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', '*']]
}
}
}
v6 of this action now runs on commitlint v19, closing the issue 👌