Skip to content

fix(ci): rename pr-instructions scripts to .cjs so they load under type:module - #2221

Open
mvill025 wants to merge 1 commit into
developmentfrom
fix/pr-instructions-esm-cjs
Open

mvill025 wants to merge 1 commit into
developmentfrom
fix/pr-instructions-esm-cjs

Conversation

@mvill025

@mvill025 mvill025 commented Oct 2, 2026

Copy link
Copy Markdown
Member

What changes did you make and why did you make them ?

The Add Pull Request Instructions workflow fails on every PR opened against development:

ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension
and '/home/runner/work/VRMS/VRMS/package.json' contains "type": "module".

The root package.json declares "type": "module" (re-added in f42f6fce, the ESM test-suite migration), which makes Node treat every .js file in the repo root tree as an ES module. The two helper scripts under github-actions/pr-instructions/ were missed by that migration and still use CommonJS module.exports / require, so actions/github-script's require('./github-actions/...') blows up before the script runs.

  • Renamed create-instruction.js → create-instruction.cjs and post-comment.js → post-comment.cjs, which opts both files out of type: module and back into CommonJS.
  • Updated the two require() paths in .github/workflows/pr-instructions.yml and .github/workflows/wr-pr-instructions.yml to match.

No logic changes — the rename is the entire fix.

How to test

Opening this PR exercises the workflow directly: Add Pull Request Instructions should now pass and the follow-up workflow_run job should post the checkout-instructions comment.

Verified locally that both files load as CommonJS and produce the expected output:

$ node -e "console.log(require('./github-actions/pr-instructions/create-instruction.cjs')({g:{},c:fakeCtx}))"
git checkout -b mvill025-fix/foo development
git pull https://github.com/mvill025/VRMS.git fix/foo

Notes for reviewers

cypress/plugins/index.js and cypress/support/index.js are CommonJS under the same root "type": "module" and will hit the identical error whenever Cypress is run. They are not touched here because no CI job currently runs them — worth a separate issue.

Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)

No user-facing changes — CI configuration only.

🤖 Generated with Claude Code

…pe:module

The root package.json declares "type": "module", so Node treats the .js
scripts under github-actions/ as ES modules. Both use `module.exports`,
which is not defined in ESM scope, so the "Add Pull Request Instructions"
workflow failed with a ReferenceError on every PR opened against
development.

Rename both to .cjs and update the require() paths in the two workflows.
No logic changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant