Skip to content

Migrate to ESM with esbuild/vitest and upgrade to node24 (v5.0.0)#260

Open
davidgamero wants to merge 1 commit intoAzure:mainfrom
davidgamero:esm-migration
Open

Migrate to ESM with esbuild/vitest and upgrade to node24 (v5.0.0)#260
davidgamero wants to merge 1 commit intoAzure:mainfrom
davidgamero:esm-migration

Conversation

@davidgamero
Copy link
Collaborator

Summary

  • ESM Migration: Add "type": "module" to package.json, enabling native ES module support
  • Bundler: Replace @vercel/ncc with esbuild (with createRequire banner for CJS compatibility)
  • Test Framework: Replace jest/ts-jest with vitest, using vi.mock() factory pattern for ESM-only module compatibility
  • Node Runtime: Update action.yml from node20 to node24
  • Major Version Bump: 4.3.15.0.0 (breaking change due to node runtime upgrade)

Dependency Upgrades

Package Before After
@actions/core ^2.0.2 ^3.0.0
@actions/exec ^2.0.0 ^3.0.0
@actions/io ^2.0.0 ^3.0.2
@actions/tool-cache 3.0.0 4.0.0

Why

The @actions/toolkit v3+ packages are ESM-only. Without this migration, Dependabot PRs that bump these packages fail with Cannot find module '@actions/core' because jest/ncc cannot resolve ESM-only packages. This migration follows the same pattern used successfully in k8s-deploy and aks-set-context.

Testing

  • All 19 existing unit tests pass under vitest
  • Build succeeds with esbuild producing ESM bundle
  • TypeScript type-checking passes with tsc --noEmit
  • No changes to CI workflow files needed (npm test and npm run build now invoke vitest/esbuild)

- Add "type": "module" to package.json for ESM support
- Replace ncc with esbuild for bundling (with createRequire banner for CJS compat)
- Replace jest/ts-jest with vitest for testing
- Upgrade @actions/core to ^3.0.0, @actions/exec to ^3.0.0, @actions/io to ^3.0.2, @actions/tool-cache to 4.0.0 (ESM-only versions)
- Update tsconfig.json to use NodeNext module resolution
- Convert all tests to use vi.mock() factory pattern for ESM-only module compatibility
- Update action.yml runtime from node20 to node24
- Bump version from 4.3.1 to 5.0.0 (major version bump for breaking node runtime change)
@davidgamero davidgamero requested a review from a team as a code owner March 13, 2026 13:43
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