feat!: migrate action to native ESM and upgrade @actions/* to ESM majors#210
Open
dhensby wants to merge 2 commits intotediousjs:masterfrom
Open
feat!: migrate action to native ESM and upgrade @actions/* to ESM majors#210dhensby wants to merge 2 commits intotediousjs:masterfrom
dhensby wants to merge 2 commits intotediousjs:masterfrom
Conversation
Migrate the action from CommonJS to native ESM so that it can consume the ESM-only majors of the `@actions/*` toolkit packages (and any future ESM-only dependencies) without a transpile-to-CJS step. Tooling changes: - Set `"type": "module"` and emit ESM throughout. - Replace `@vercel/ncc` (which cannot emit ESM) with Rollup (`@rollup/plugin-typescript`, `-node-resolve`, `-commonjs`, `-json`, `-terser`). Output is still `lib/main/index.js` so `action.yml` is unchanged. - Drop `ts-node`/`tsx` in favour of Node 24's native TypeScript type-stripping (`.ts` files execute directly under `node`). - Replace the Mocha + Chai + Sinon + sinon-chai test stack with Node's built-in `node:test` runner (using `--experimental-test-module-mocks` and `node:assert/strict`). Replace `nyc`/`c8` with Node's built-in `--experimental-test-coverage`. `.mocharc.json` and `.nycrc.json` are removed. - Switch relative imports throughout src/, test/, and misc/ to use `.ts` extensions and set `allowImportingTsExtensions` + `rewriteRelativeImportExtensions` in `tsconfig.json` so both Node and Rollup resolve them directly. - Update `misc/generate-docs.ts` to ESM (JSON import attribute, `import.meta.url` in place of `__dirname`). Source-code style: - Idiomatic ESM imports throughout: `import * as core from '@actions/core'`, named imports where appropriate, default-function exports for modules with a single primary export (e.g. `install-native-client.ts`). No default-object/re-export wrappers are needed for test stubbing; tests mock at the module-resolution layer using `node:test`'s `mock.module()`. Docs: - Update `.github/copilot-instructions.md` to describe the new toolchain (Rollup, Node 24 native TS, `node:test` + `mock.module()`, built-in coverage). BREAKING CHANGE: The action is now an ESM module and targets Node 24. Consumers pinning the action via commit SHA will need to re-pin; consumers using `@v3` or later will continue to work unchanged. Local development now requires Node 24+ (previously Node 20+). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bump the `@actions/*` runtime dependencies to their ESM-only major releases now that the action itself runs as a native ESM module: - `@actions/core` 1 → 3 - `@actions/exec` 1 → 3 - `@actions/glob` 0.5 → 0.6 - `@actions/http-client` 2 → 4 - `@actions/io` 1 → 3 - `@actions/tool-cache` 2 → 4 No source changes are required for this bump: the public surface we use (`core.getInput`, `core.platform`, `exec.exec`, `glob.create`, `HttpClient#get`, `io.mv`, `tc.downloadTool`/`cacheFile`/`cacheDir`/`find`) is unchanged across these majors, and tests mock the packages at the module-resolution layer via `node:test`'s `mock.module()`. Supersedes Dependabot tediousjs#206. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
244af72 to
2eed313
Compare
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.
Migrates the action to native ESM on Node 24 so it can consume the ESM-only majors of the
@actions/*toolkit (superseding Dependabot #206).Commits
feat!: rewrite as an ESM module"type": "module",tsconfigflipped tonodenextwithallowImportingTsExtensions+rewriteRelativeImportExtensions; all relative imports use explicit.tsextensions.@vercel/nccto Rollup (single-file ESM bundle atlib/main/index.js).mocha+ts-node+chai+sinon+sinon-chai+nyc/c8to Node's built-innode:test+node:assert/strict+--experimental-test-module-mocks+--experimental-test-coverage. No third-party test runner, assertion library, mocking library, or coverage tool remains.src/actions.tsre-export shim (originally introduced so sinon could stub toolkit calls) is gone — modules use idiomaticimport * as core from '@actions/core'etc., restoring Rollup tree-shaking.mock.module()rather than rebinding namespace imports.chore(deps): upgrade @actions/* toolkit to ESM majors@actions/core1→3,@actions/exec1→3,@actions/glob0.5→0.6,@actions/http-client2→4,@actions/io1→3,@actions/tool-cache2→4.Breaking changes
action.ymlalready pinnednode24).Closes #206.