feat: migrate to ESM and upgrade all dependencies#514
Conversation
|
I am not a total NodeJs/JavaScript/TypeScript expert, so I hope Claude hasn't produced too much slop. I challenged some of the suspicious looking configs, so Claude attempted a few things to reduce the size of the change, but did not succeed. So I did a bit of research regarding some of the changes myself, it looks like Claude is right as is. This PR should be independent from #513. |
Migrate the project from CommonJS to ESM to support @actions/core v3, which is ESM-only. Also upgrades all other pending dependabot bumps. Changes: - package.json: add "type": "module", update test script to use --experimental-vm-modules for Jest ESM support - tsconfig.json: switch to module/moduleResolution NodeNext, add isolatedModules: true (required by ts-jest with NodeNext) - jest.config.js: enable useESM in ts-jest, add extensionsToTreatAsEsm and moduleNameMapper to resolve .js imports to .ts source files - src/main.ts: use ./asdf.js extension (required by ESM) - __tests__/asdf.test.ts: replace __dirname with import.meta.url, update import to use .js extension - __tests__/main.test.ts: update import to use .js extension - .eslintrc.json: disable import/no-unresolved (false positives from .js→.ts ESM convention) - .github/workflows/check-dist.yml: bump actions/upload-artifact v6→v7 Dependency upgrades: - @actions/core 2.0.2 → 3.0.1 - @typescript-eslint/eslint-plugin 8.53.1 → 8.59.4 - @typescript-eslint/parser 8.53.1 → 8.59.4 - @types/node 25.0.10 → 25.9.1 - eslint-plugin-jest 29.12.1 → 29.15.2 Closes endorama#507, endorama#508, endorama#509, endorama#510, endorama#511, endorama#505 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
a92bb8b to
89b6bf7
Compare
|
Thanks! I'll break this down into smaller and more focused PRs. The changelog is easier to follow that way, considering this is something people install in their CI. I should be able to push on this branch, no action should be needed from your side. |
Hi @endorama, do you need help with splitting up the PR? |
Summary
@actions/corev3, which is ESM-onlyBreaking change:
@actions/corev3 is ESM-onlyTo support it, the following migration was required:
package.json: added"type": "module", updatedtestscript to usenode --experimental-vm-modulesfor Jest ESM supporttsconfig.json: switched tomodule/moduleResolution: NodeNext, addedisolatedModules: true(required by ts-jest with NodeNext)jest.config.js: enableduseESMin ts-jest transform, addedextensionsToTreatAsEsm: ['.ts']andmoduleNameMapperto resolve.jsimports to.tssource filessrc/main.ts: updated relative import to./asdf.js(required by ESM)__tests__/asdf.test.ts: replaced__dirnamewithimport.meta.url-based equivalent, updated import to.jsextension__tests__/main.test.ts: updated import to.jsextension.eslintrc.json: disabledimport/no-unresolved(produces false positives for the.js→.tsESM convention)Dependency upgrades
Resolves all pending dependabot PRs:
@actions/coreeslint-plugin-jest@types/node@typescript-eslint/eslint-pluginactions/upload-artifact@typescript-eslint/parserTest plan
npm run build— TypeScript compiles without errorsnpm run format— no formatting changes needednpm run lint— no lint errorsnpm run package— ncc bundles successfully (auto-detected ESM output)npm test— all 4 tests pass (2 suites)Closes #507, #508, #509, #510, #511, #505
🤖 Generated with Claude Code