-
Notifications
You must be signed in to change notification settings - Fork 1.7k
@actions/cache: convert to an ESM module
#2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts the @actions/cache package from CommonJS to ESM-only, marking it as a major breaking change with version 6.0.0. The conversion aligns with the broader ESM migration across the GitHub Actions toolkit packages.
Changes:
- Package converted to ESM with
"type": "module"and exports configuration - TypeScript configured for ESM output with
module: "node16"andmoduleResolution: "node16" - All relative imports updated with
.jsextensions for ESM compatibility - Dependencies upgraded to ESM-compatible versions (@actions/core 3.0.0, @actions/exec 3.0.0, etc.)
- Created
package-version.cjsCommonJS wrapper to read package.json version in ESM context - Removed direct dependency on
@azure/abort-controllerin favor of global AbortController (Node.js 18+) - Jest configuration updated to handle ESM cache module
Reviewed changes
Copilot reviewed 13 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cache/package.json | Updated to version 6.0.0, added ESM configuration, upgraded dependencies to latest ESM-compatible versions, updated build script |
| packages/cache/tsconfig.json | Added ESM module settings (node16) for proper module resolution |
| packages/cache/src/cache.ts | Updated all relative imports to include .js extensions |
| packages/cache/src/internal/*.ts | Updated all relative imports to include .js extensions across all internal modules |
| packages/cache/src/internal/shared/user-agent.ts | Refactored to import version from new package-version.cjs file |
| packages/cache/src/internal/shared/package-version.cjs | New CommonJS module to provide package version to ESM modules |
| packages/cache/src/generated/**/*.ts | Updated generated protobuf code with .js extensions in relative imports |
| packages/cache/package-lock.json | Updated all dependency versions consistently with package.json changes |
| packages/cache/RELEASES.md | Added 6.0.0 release notes documenting ESM-only breaking change |
| jest.config.js | Added @actions/cache module mapping and transform patterns for ESM testing |
Files not reviewed (1)
- packages/cache/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ae07f21 to
73faff4
Compare
Description
We're converting all packages in this repo to ESM modules.
@actions/cacheis one of leaf packages and can be converted now.