feat: Migrate codebase from CommonJS to ES modules#17
Merged
Conversation
@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.
dangrondahl
approved these changes
Apr 28, 2026
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.
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
require()statements toimportstatements acrosssrc/index.js,src/download.js, andtest/download.test.jsmodule.exportswithexportkeyword for named exports insrc/download.jspathimport fromsrc/download.jssrc/index.jsby removing therequire.main === modulecheck and directly callingsetup()"type": "module"topackage.jsonto enable ES module support.jsfile extensions as required by ES modulesImplementation Details
src/download.jsare now declared inline with the function definitions usingexportkeywordsetup()instead of conditionally checking if it's the main module.js) to comply with ES module resolution requirements