Open francois-roseberry opened 3 months ago
@francois-roseberry Sorry! Wasn't updating this package, adding ESM/CJS support with update to commitment in v9, an update should come by EOD today! 🎉
Run kevintyj/prlint@v2
node:internal/modules/esm/resolve:854
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@commitlint/load' imported from /home/runner/work/_actions/kevintyj/prlint/v2/dist/index.js
at packageResolve (node:internal/modules/esm/resolve:854:9)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1157:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v20.13.1
this is after adding npm i @commitlint/load
to the workflow prior to prlint
# This workflow will validate the title of a PR to ensure it meets conventional commit standards
name: Validate conventional commit syntax
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
pull_request_review:
types:
- submitted
permissions:
pull-requests: read
env:
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Separate jobs can run concurrently
jobs:
prTitle:
name: Validate conventional commit format for title
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci --prefer-offline
- run: npm i @commitlint/load
- id: commitlint
uses: kevintyj/prlint@v2
# ...
Run kevintyj/prlint@v2 node:internal/modules/esm/resolve:854 throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null); ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@commitlint/load' imported from /home/runner/work/_actions/kevintyj/prlint/v2/dist/index.js at packageResolve (node:internal/modules/esm/resolve:854:9) at moduleResolve (node:internal/modules/esm/resolve:927:18) at defaultResolve (node:internal/modules/esm/resolve:1157:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39) at link (node:internal/modules/esm/module_job:86:36) { code: 'ERR_MODULE_NOT_FOUND' } Node.js v20.13.1
this is after adding
npm i @commitlint/load
to the workflow prior to prlint# This workflow will validate the title of a PR to ensure it meets conventional commit standards name: Validate conventional commit syntax on: pull_request: types: - opened - edited - synchronize - reopened pull_request_target: types: - opened - edited - synchronize - reopened pull_request_review: types: - submitted permissions: pull-requests: read env: TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Separate jobs can run concurrently jobs: prTitle: name: Validate conventional commit format for title runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - run: npm ci --prefer-offline - run: npm i @commitlint/load - id: commitlint uses: kevintyj/prlint@v2 # ...
Hey! So sorry it took so long to get to your question. What kind of configuration are you using? Are you using ESM or CJS in your project? Did you migrate from v1?
Is there an existing issue for this?
Current Behavior
Running the prlint action in a project with the commitlint dependency at v19 does not work and returns the following log in GitHub actions
Error: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/project/node_modules/@commitlint/config-conventional/lib/index.js from /home/runner/work/_actions/kevintyj/prlint/main/dist/index.js not supported. Instead change the require of /home/runner/work/project/node_modules/@commitlint/config-conventional/lib/index.js in /home/runner/work/_actions/kevintyj/prlint/main/dist/index.js to a dynamic import() which is available in all CommonJS modules.
Having the commitlint dependency at v18 does work. Looking at commitlint v19 changelog, they have this
Expected Behavior
The prlint action should be able to import ESM modules to support commitlint v19
Steps To Reproduce
Create a nodejs project with commitlint v19 dependency. Create a github workflow that uses the prlint action. Open a PR and look at github action logs
Environment
Anything else?
I reproduced a minimal sample here: https://github.com/francois-roseberry/prlint-reproduce/actions/runs/8344686094/job/22837740415?pr=1