Skip to content

feat: convert project from CommonJS to ESM#186

Open
scottschreckengaust wants to merge 7 commits intoaws-actions:mainfrom
scottschreckengaust:feature/update-to-esm
Open

feat: convert project from CommonJS to ESM#186
scottschreckengaust wants to merge 7 commits intoaws-actions:mainfrom
scottschreckengaust:feature/update-to-esm

Conversation

@scottschreckengaust
Copy link
Copy Markdown
Contributor

@scottschreckengaust scottschreckengaust commented Apr 13, 2026

Depends on: #185 (should merge first)

Description of changes

Convert the project from CommonJS to ECMAScript Modules (ESM).

What changed

  • Added "type": "module" to package.json
  • Converted all require()/module.exports to import/export
  • Replaced @vercel/ncc bundler with esbuild — produces a single dist/index.js (ncc code-splits ESM into unreliable chunks)
  • Injected github.context as a parameter into githubInputs() for testability — tests now pass plain context objects instead of mutating the shared @actions/github singleton
  • Updated ESLint config: sourceType: "module", ecmaVersion: 2022
  • CI now tests against both Node.js 22 and 24

Dependencies upgraded

Package From To Reason
@actions/core ^1.10.0 ^3.0.0 ESM-only from v3
@actions/github ^8.0.1 ^9.1.0 ESM-only from v9
uuid ^3.4.0 ^9.0.0 ESM support, new import path
yargs ^15.3.1 ^17.7.2 ESM support
chai ^4.2.0 ^6.2.2 ESM-native (named exports)
@vercel/ncc ^0.36.1 removed Replaced by esbuild
esbuild ^0.28.0 Single-file ESM bundling

Verification

  • All 23 tests passing
  • esbuild produces a single dist/index.js (no chunks)
  • npm run lint clean
  • npm audit — 0 vulnerabilities
  • CI matrix: Node.js 22 + 24

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

- Add "type": "module" to package.json
- Convert all require()/module.exports to import/export
- Upgrade @actions/core ^1.10.0 -> ^3.0.0 (ESM-only)
- Upgrade @actions/github ^8.0.1 -> ^9.1.0 (ESM-only)
- Upgrade uuid ^3.4.0 -> ^9.0.0 (ESM import path)
- Upgrade yargs ^15.3.1 -> ^17.7.2 (ESM support)
- Upgrade @vercel/ncc ^0.36.1 -> ^0.38.4 (ESM input)
- Upgrade chai ^4.2.0 -> ^6.2.2 (ESM-native)
- Update ESLint config for ESM (sourceType: module)
- Rework test context mutation for ESM live bindings

All 23 tests passing, 0 audit vulnerabilities, ncc build succeeds.
ncc v0.38 code-splits ESM output into chunks, which is unreliable
for GitHub Actions runners. esbuild produces a single dist/index.js
with a createRequire banner shim for CJS interop.
Accept an optional context parameter (defaults to github.context)
so tests can pass plain objects instead of mutating the shared
@actions/github singleton.
@scottschreckengaust scottschreckengaust marked this pull request as ready for review April 14, 2026 18:19
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