chore!: migrate to ESM, adopt node24 runtime, roll up open Dependabot PRs - #121
Conversation
|
Follow-up commit
|
… PRs Summary: ======= Three Dependabot PRs (#108, #114, #120) were all stuck on a red `check-dist` because Dependabot only edits `package.json` / `package-lock.json` and never rebuilds the checked-in `dist/` bundle. #108 was additionally red on `units`: `@actions/core` 3.0.0 is ESM-only and its `exports` map declares no `require` condition, so `require("@actions/core")` fails outright with `ERR_PACKAGE_PATH_NOT_EXPORTED` on any Node version. Taking that bump therefore required converting the action from CommonJS to ESM, which pairs naturally with moving the published runtime to node24. Two latent CI defects surfaced while verifying the above and are fixed here: - `node-version-file: package.json` never resolved, because the manifest had no `engines.node`. setup-node logged "Could not determine node version ... Falling back" and silently built `dist/` on the runner's Node 22, so CI was not exercising the runtime the action declares. - The `check-dist` comparison used `git diff`, which cannot see files the build newly adds. ncc 0.44 emits `dist/package.json` and renames `sourcemap-register.js` to `.cjs`; without the untracked-file check, shipping the action with a missing `sourcemap-register.cjs` would have passed CI and failed at runtime. Actions: ======= - Convert `index.js` and `find-python-projects.js` to ESM named exports and set `"type": "module"`. - Rewrite the test suite to mock via `jest.unstable_mockModule`, since frozen ESM namespaces cannot be patched by `jest.spyOn`; run jest under `--experimental-vm-modules`. All 12 tests and 4 snapshots pass unchanged, confirming the migration is behavior-neutral. - Bump `@actions/core` to ^3.0.1 (#108) and `@vercel/ncc` to ^0.44.0 (#114). - Apply the npm_and_yarn security group (#120): brace-expansion 1.1.12 -> 1.1.18 and 2.1.0 -> 2.1.4, flatted 3.3.3 -> 3.4.4, undici 5.29.0 -> 6.28.0. - Set `runs.using` to node24 in `action.yml` and add `engines.node: ^24.0.0` so `node-version-file: package.json` resolves. - Add setup-node to the `units` job so unit tests run on the same pinned Node. - Harden the `check-dist` comparison to also fail on untracked files in `dist/`. - Repair `npm run lint`, broken since the eslint 10 bump: the flat config imported `globals`, `@eslint/js` and `@eslint/eslintrc`, none of which were declared and which eslint 10 no longer provides transitively. Declare `globals` and `@eslint/js`, and drop the `FlatCompat`/eslintrc shim in favor of `js.configs.recommended`. - Rebuild `dist/`; add `dist/package.json` and `dist/sourcemap-register.cjs`, remove the now-stale `dist/sourcemap-register.js`. BREAKING CHANGE: the action now runs on the node24 runtime and its sources are ESM. Consumers referencing the action by tag are unaffected, but GitHub Actions runners must support `runs.using: node24`. ai-generated: true
Summary: ======= The ESM test suite imports `jest`, `describe`, `it`, `expect` and `beforeEach` from `@jest/globals`, but that package was only reachable transitively through `jest`. That is the same undeclared-import bug class that had already broken `npm run lint` on main, so declare it explicitly before it bites. Also aligns the test script with the sibling action repos (pipx-install-action, python-test-matrix-generator-action), which additionally silences the VM-modules ExperimentalWarning. Actions: ======= - Add `@jest/globals` ^30.4.2 to devDependencies. - Change the `test` script to `NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest`. ai-generated: true
91a4a89 to
142713a
Compare
|
Rebased onto How the conflicts were resolved
Verified nothing Re-ran locally on Node 24.19.0: lint clean, 12/12 tests + 4/4 snapshots, Since #114 and #120 are now merged, this PR's remaining dependency delta is just #108 ( |
Summary
Closes out all three open Dependabot PRs in one change, fixes the CI failures that were blocking them, and moves the published action to the node24 runtime.
@actions/core2.0.2 → 3.0.1^3.0.1)@vercel/ncc0.38.4 → 0.44.0^0.44.0, resolves 0.44.1)brace-expansion1.1.12→1.1.18 & 2.1.0→2.1.4,flatted3.3.3→3.4.4,undici5.29.0→6.28.0Why those PRs were red
All three failed
check-dist. Dependabot only editspackage.json/package-lock.json; it never runsnpm run prepare, so the checked-indist/bundle drifts from the sources. That check is working as designed — it just can't be satisfied by a bot.#108 also failed
units, and that one is not cosmetic.@actions/core3.0.0 is ESM-only and itsexportsmap declares only animportcondition:With no
requirecondition,require("@actions/core")fails on every Node version — Node 22/24'srequire(esm)support doesn't help, because resolution fails before module-format detection:So taking #108 requires converting this action from CommonJS to ESM. That pairs naturally with the requested node24 move, so both are here.
Two latent CI defects found while verifying this
Both were pre-existing on
mainand are fixed in this PR.1.
node-version-file: package.jsonnever resolved. The manifest had noengines.node, so setup-node silently fell back to the runner's preinstalled Node. From thecheck-distlog on #120:CI was building
dist/on Node 22 whileaction.ymldeclarednode20— the declared runtime was never exercised. Fixed by addingengines.node: "^24.0.0"(setup-node readsvolta.node→devEngines.runtime→engines.node, and accepts semver ranges).2.
check-distcould not see files the build newly adds. The comparison usedgit diff, which ignores untracked files. ncc 0.44 emits a newdist/package.jsonand renamessourcemap-register.js→sourcemap-register.cjs. Without an untracked check, this very PR could have shipped adist/index.jswhose first line isimport './sourcemap-register.cjs';while that file was untracked — green CI, broken action. Now the step also fails on untracked files underdist/.Changes
ESM migration
index.js/find-python-projects.jsconverted toimport+ namedexports;"type": "module"added.jest.unstable_mockModule. ESM module namespaces are frozen, so the previousjest.spyOn(core, "info")pattern now throwsTypeError: Cannot assign to read only property 'info' of object '[object Module]'. Jest runs under--experimental-vm-modules.node24
action.yml:runs.using: node20→node24.engines.node: ^24.0.0, which also makesnode-version-file: package.jsonwork.unitsjob gains asetup-nodestep so unit tests run on the same pinned Node ascheck-dist(previously it used whatever the runner shipped).npm run lintrepaired — broken onmainsince the eslint 10 bump (#113), and invisible because no CI job runs lint:The flat config imported
globals,@eslint/jsand@eslint/eslintrc, none of which were ever declared as devDependencies; they used to be hoisted out of eslint's own tree, and eslint 10 no longer provides them. Nowglobalsand@eslint/jsare declared explicitly, and the legacyFlatCompat/eslintrcshim is replaced withjs.configs.recommended. Per repo convention this fixes the linter rather than suppressing it.Verification
Run locally on Node 24.19.0:
npm run all→ lint clean, ncc build clean, 12/12 tests + 4/4 snapshots pass.check-distlogic replayed locally against the committed tree →dist/is byte-reproducible and in sync.node_modules) and rannode dist/index.jswithINPUT_ROOT-DIR=./test-fixtures/multi-projectand aGITHUB_OUTPUTfile. It emitted all three outputs and produced exactly the four matrix entries theTest: *jobs expect —sub-project-1,sub-project-2,project-5,sub-project-6— with unchangedinstall/testcommands.node24confirmed a validruns.usingvalue, andengines.nodeconfirmed as a setup-nodenode-version-filesource, against upstream docs/source rather than assumed.Notes for the reviewer
npm audit --omit=devstill reports one high-severity advisory in shipped code —picomatch <=2.3.1, reached viaglobby@11 → fast-glob → micromatch. There is no in-range fix; it needs aglobbymajor bump (12+ is ESM-only, so this PR unblocks that) and that changes glob behavior, so it belongs in its own PR with its own testing. Remainingnpm auditfindings are dev-toolchain-only.@vercel/nccis pinned at^0.44.0to match Bump @vercel/ncc from 0.38.4 to 0.44.0 #114 exactly, even though 0.45.0 has since shipped. Dependabot will offer 0.45.0 separately.unitssetup-node) are the only edits here that go beyond the literal dependency bumps. Both are load-bearing for this PR's correctness, but say the word and I'll split them out.#120,#114and#108can be closed once this merges.🤖 Generated with Claude Code