Switch to ESM for source and test, use CommonJS for dist#806
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the repository’s source and unit test environment to ESM while keeping the published GitHub Action artifacts in dist/ bundled as CommonJS (.cjs) for runtime compatibility.
Changes:
- Switch TypeScript/Jest configuration to an ESM-oriented setup (
type: module, ESM ts-jest preset, updated TS compiler options). - Replace
nccpackaging with anesbuild-based bundling script that emits CommonJS.cjsentrypoints. - Update action metadata, workflows, and scripts to reference the new
dist/**/index.cjsoutputs.
Reviewed changes
Copilot reviewed 14 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Moves TS config to ESM/bundler-oriented compiler settings and narrows compilation to src/**. |
| src/update-known-checksums.ts | Updates CLI usage text to reference .cjs dist entrypoint. |
| src/setup-uv.ts | Adjusts matcher path construction (introduces sourceDir). |
| scripts/build-dist.mjs | New esbuild-based bundler emitting CommonJS .cjs outputs and removing stale .mjs files. |
| package.json | Sets type: module, updates scripts for ESM Jest, swaps packaging to esbuild script, updates deps. |
| jest.config.mjs | Adds ESM Jest configuration via ts-jest ESM preset. |
| jest.config.js | Removes old CommonJS Jest configuration. |
| action.yml | Points main/post to dist/**/index.cjs for the Node 24 action runtime. |
| tests/version/tool-versions-file.test.ts | Converts mocks/imports to ESM-friendly jest.unstable_mockModule + dynamic import. |
| tests/utils/inputs.test.ts | Converts core mocking to ESM-friendly jest.unstable_mockModule + dynamic import helper. |
| tests/download/versions-client.test.ts | Updates mocking/import style for ESM Jest execution. |
| tests/download/version-manifest.test.ts | Updates mocking/import style for ESM Jest execution. |
| tests/download/download-version.test.ts | Updates mocking/import style for ESM Jest execution; adjusts @actions/tool-cache mock surface. |
| AGENTS.md | Documents the intended split: ESM-friendly source/tests vs CommonJS bundled dist artifacts. |
| .github/workflows/update-known-checksums.yml | Uses .nvmrc and updates invocation to .cjs. |
| .github/workflows/test.yml | Adjusts ad-hoc tsc invocation to emit runnable output under type: module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.