Skip to content

feat: Migrate codebase from CommonJS to ES modules#17

Merged
mbevc1 merged 1 commit intomainfrom
claude/fix-github-actions-KiXUm
Apr 28, 2026
Merged

feat: Migrate codebase from CommonJS to ES modules#17
mbevc1 merged 1 commit intomainfrom
claude/fix-github-actions-KiXUm

Conversation

@mbevc1
Copy link
Copy Markdown
Contributor

@mbevc1 mbevc1 commented Apr 27, 2026

Summary

This PR migrates the entire codebase from CommonJS (require/module.exports) to ES modules (import/export), modernizing the project's module system. This is required in order to bump dependencies.

Key Changes

  • Converted all require() statements to import statements across src/index.js, src/download.js, and test/download.test.js
  • Replaced module.exports with export keyword for named exports in src/download.js
  • Removed unused path import from src/download.js
  • Simplified entry point in src/index.js by removing the require.main === module check and directly calling setup()
  • Added "type": "module" to package.json to enable ES module support
  • Updated import paths to include .js file extensions as required by ES modules

Implementation Details

  • The module exports in src/download.js are now declared inline with the function definitions using export keyword
  • The main entry point now directly executes setup() instead of conditionally checking if it's the main module
  • All imports use explicit file extensions (.js) to comply with ES module resolution requirements

@actions/tool-cache 4.0.0 is ESM-only (per its 4.0.0 changelog,
"CommonJS consumers must use dynamic import() instead of require()"),
so the existing CommonJS source breaks ncc bundling once that bump
lands. Switching the project to native ESM unblocks the dependabot
upgrade in #13 while remaining backward-compatible with tool-cache@2.x
already in the lockfile.
@mbevc1 mbevc1 requested a review from a team April 27, 2026 15:53
@mbevc1 mbevc1 merged commit bd460ac into main Apr 28, 2026
6 checks passed
@mbevc1 mbevc1 deleted the claude/fix-github-actions-KiXUm branch April 28, 2026 08:58
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.

3 participants