chore: update @actions/core to v3 and migrate to ESM #73

Merged
Philipp merged 1 commits from update-actions-core-v3 into main 2026-02-23 03:59:13 +01:00
Owner

This PR updates the @actions/core dependency from v2 to v3.0.0.

Major Changes:

  • Dependency Update: Updated @actions/core to v3.0.0 in package.json.
  • ESM Migration: Converted the entire project to ECMAScript Modules (ESM). This was necessary because @actions/core v3 is an ESM-only package and does not provide CommonJS exports.
  • package.json updates: Added "type": "module" and updated the dependency version.
  • Code Refactor:
    • Converted index.js to use import and export.
    • Updated the main execution check to use import.meta.url for ESM compatibility.
    • Converted __tests__/index.test.js to use ESM imports for compatibility with the updated source code.
  • Production Build: Re-generated the dist/index.js bundle using ncc to reflect the changes.
  • Node.js Version: The project continues to use Node 20 (node20 in action.yaml), which is fully compatible with these changes.

Why these changes are needed:

  • @actions/core v3 brings latest improvements and fixes from the GitHub Actions toolkit.
  • Migrating to ESM is the modern standard for Node.js development and is required to consume ESM-only packages like the new @actions/core v3.

Verified with npm test and npm run build.

This PR updates the `@actions/core` dependency from v2 to v3.0.0. ### Major Changes: - **Dependency Update**: Updated `@actions/core` to `v3.0.0` in `package.json`. - **ESM Migration**: Converted the entire project to ECMAScript Modules (ESM). This was necessary because `@actions/core` v3 is an ESM-only package and does not provide CommonJS exports. - **`package.json` updates**: Added `"type": "module"` and updated the dependency version. - **Code Refactor**: - Converted `index.js` to use `import` and `export`. - Updated the main execution check to use `import.meta.url` for ESM compatibility. - Converted `__tests__/index.test.js` to use ESM imports for compatibility with the updated source code. - **Production Build**: Re-generated the `dist/index.js` bundle using `ncc` to reflect the changes. - **Node.js Version**: The project continues to use Node 20 (`node20` in `action.yaml`), which is fully compatible with these changes. ### Why these changes are needed: - `@actions/core` v3 brings latest improvements and fixes from the GitHub Actions toolkit. - Migrating to ESM is the modern standard for Node.js development and is required to consume ESM-only packages like the new `@actions/core` v3. Verified with `npm test` and `npm run build`.
Philipp added 1 commit 2026-02-23 03:51:27 +01:00
chore: update @actions/core to v3 and convert to ESM
All checks were successful
Lint / pre-commit Linting (push) Successful in 31s
Test / Run Tests (push) Successful in 39s
cebff45aa7
This commit updates the @actions/core dependency from v2 to v3.
The primary change in @actions/core v3 is that it is now an ESM-only package.
To maintain compatibility, the following changes were made:
- Added "type": "module" to package.json to switch the project to ESM.
- Converted index.js from CommonJS to ESM, replacing require with import/export.
- Converted __tests__/index.test.js to ESM to support testing the updated index.js.
- Re-built the production bundle in dist/ using ncc to reflect the changes.
- Updated the main entry point check in index.js to use import.meta.url for ESM compatibility.

This ensures the action continues to function correctly with the latest GitHub Actions toolkit library.
Member

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵
🧪 PR contains tests
🔒 No security concerns identified
 Recommended focus areas for review

Main execution check

The ESM-based invocation guard if (process.argv[1] === __filename) may not reliably detect module execution in all scenarios (e.g., bundled output, symlinked paths, or when running from dist/index.js). Consider using a pattern based on comparing import.meta.url or explicitly converting and normalizing paths with fileURLToPath(import.meta.url) for consistency.

const __filename = fileURLToPath(import.meta.url);
if (process.argv[1] === __filename) {
  postCode();
}
Missing import

The call to fileURLToPath(import.meta.url) requires importing it from the 'url' module. Ensure you have import { fileURLToPath } from 'url'; at the top, or else __filename will be undefined and break the execution guard.

const __filename = fileURLToPath(import.meta.url);
if (process.argv[1] === __filename) {
Root module type

The PR adds "type": "module" in dist/package.json but the root package.json diff doesn't show it. Verify that the root manifest declares "type": "module" so Node treats all source files as ESM.

  "build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil"
},
"dependencies": {
  "@actions/core": "^3.0.0",
## PR Reviewer Guide 🔍 Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 2 🔵🔵⚪⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>PR contains tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/update-actions-core-v3/index.js#L179-L182'><strong>Main execution check</strong></a> The ESM-based invocation guard `if (process.argv[1] === __filename)` may not reliably detect module execution in all scenarios (e.g., bundled output, symlinked paths, or when running from `dist/index.js`). Consider using a pattern based on comparing `import.meta.url` or explicitly converting and normalizing paths with `fileURLToPath(import.meta.url)` for consistency. </summary> ```javascript const __filename = fileURLToPath(import.meta.url); if (process.argv[1] === __filename) { postCode(); } ``` </details> <details><summary><a href='https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/update-actions-core-v3/index.js#L179-L180'><strong>Missing import</strong></a> The call to `fileURLToPath(import.meta.url)` requires importing it from the `'url'` module. Ensure you have `import { fileURLToPath } from 'url';` at the top, or else `__filename` will be undefined and break the execution guard. </summary> ```javascript const __filename = fileURLToPath(import.meta.url); if (process.argv[1] === __filename) { ``` </details> <details><summary><a href='https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/update-actions-core-v3/package.json#L10-L13'><strong>Root module type</strong></a> The PR adds `"type": "module"` in `dist/package.json` but the root `package.json` diff doesn't show it. Verify that the root manifest declares `"type": "module"` so Node treats all source files as ESM. </summary> ```json "build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil" }, "dependencies": { "@actions/core": "^3.0.0", ``` </details> </td></tr> </table>
Author
Owner

Probably correct should be tested directly after merge!

Probably correct should be tested directly after merge!
Philipp reviewed 2026-02-23 03:58:03 +01:00
@@ -0,0 +1,3 @@
{
Author
Owner

Is this file needed? I need an explation about it.

Is this file needed? I need an explation about it.
Philipp marked this conversation as resolved
Philipp merged commit 2be5b2a1bc into main 2026-02-23 03:59:13 +01:00
Philipp deleted branch update-actions-core-v3 2026-02-23 03:59:13 +01:00
Sign in to join this conversation.