@actions/tool-cache: convert to an ESM module#2274
Merged
danwkennedy merged 3 commits intomainfrom Jan 29, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates @actions/tool-cache to be an ESM-only package, aligning it with other ESM-converted packages in the repo and updating its dependencies accordingly.
Changes:
- Configure the
tool-cacheTypeScript build for Node-style ESM (module/moduleResolutionset tonode16) and update internal imports to use.jsspecifiers and top-level@actions/execexports. - Refactor
manifest.tsto pure ESM imports and introduce an_internalhelper object for testability, while keeping_readLinuxVersionFileas a backwards-compatibility alias. - Mark the package as ESM-only in
package.json, add anexportsmap, bump to version4.0.0with updated dependency versions and lockfile, update Jest config and tests to work with the new ESM shape, and document the breaking change inRELEASES.md.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/tool-cache/tsconfig.json |
Sets module and moduleResolution to node16 for ESM-compatible builds while preserving existing outDir/rootDir layout. |
packages/tool-cache/src/tool-cache.ts |
Updates internal imports to use .js specifiers and the top-level @actions/exec ESM entrypoint, keeping public API and logic unchanged. |
packages/tool-cache/src/manifest.ts |
Converts from require-style imports to ESM imports, introduces _internal.readLinuxVersionFile for Jest mocking, and retains _readLinuxVersionFile() as a compatibility wrapper. |
packages/tool-cache/package.json |
Declares the package as ESM-only via "type": "module", adds an exports map for types/import, bumps to 4.0.0, and updates runtime and dev dependencies to current major versions. |
packages/tool-cache/package-lock.json |
Synchronizes lockfile with new dependency versions (including transitive dev tooling like nock and its dependencies). |
packages/tool-cache/__tests__/tool-cache.test.ts |
Adjusts imports to reference ../src/tool-cache.js so tests run against the ESM-shaped source with Jest’s .js mapper. |
packages/tool-cache/__tests__/retry-helper.test.ts |
Points the test to ../src/retry-helper.js to match ESM-style internal imports. |
packages/tool-cache/__tests__/manifest.test.ts |
Switches to ESM-style imports for tool-cache/manifest and updates spies to target mm._internal.readLinuxVersionFile, keeping the OS-version resolution tests working. |
packages/tool-cache/RELEASES.md |
Adds a 4.0.0 entry documenting that the package is now ESM-only and clarifies the require vs import() breaking change. |
jest.config.js |
Maps @actions/tool-cache to the built lib/tool-cache.js and ensures it and its dependencies are transpiled by ts-jest, mirroring the setup used for other ESM-converted packages. |
Files not reviewed (1)
- packages/tool-cache/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lokesh755
previously approved these changes
Jan 29, 2026
4f182be to
1f913ea
Compare
lokesh755
approved these changes
Jan 29, 2026
9 tasks
DariuszPorowski
added a commit
to raven-actions/actionlint
that referenced
this pull request
Jan 30, 2026
<!-- markdownlint-disable MD041 --> ## 💌 Description This change pins the installed version of `@actions/tool-cache` to major version 3. <!-- Add a more detailed description of the changes if needed. --> The `@actions/tool-cache` package was recently converted to an ESM module: actions/toolkit#2274. This is incompatible with the usage of `require` in the actionlint script: https://github.com/raven-actions/actionlint/blob/580b34edf3f0039a5691481c6081049971ecd530/action.yml#L217-L218 ## 🔗 Related issue <!-- If your PR refers to a related issue, link it here. --> Fixes: #51 ## 📚 Type of change <!-- Mark with an `x` all the checkboxes that apply (like `[x]`) --> - [ ] 📝 Examples / docs / tutorials - [x] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] 🥂 Improvement (non-breaking change which improves an existing feature) - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🚨 Security fix - [x] ⬆️ Dependencies update ## ✔️ Checklist <!-- Mark with an `x` all the checkboxes that apply (like `[x]`) --> - [x] I've read the [`Code of Conduct`](https://github.com/raven-actions/.workflows/blob/main/.github/CODE_OF_CONDUCT.md) document. - [x] I've read the [`Contributing`](https://github.com/raven-actions/.workflows/blob/main/.github/CONTRIBUTING.md) guide. --------- Co-authored-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
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.
Description
We're upgrading all the packages in this repo to ESM modules.
@actions/tool-cachecan go next since all its dependencies are ESM modules.