Skip to content

Convert the action to ESM to consume @actions/core 3 and @actions/github 9 #131

Description

@jeefy

@actions/core 3.x and @actions/github 9.x are ESM-only: their exports maps expose only an import condition. Our build is CommonJS (tsconfig module: commonjs, ncc emits CJS), so webpack fails with

"." is not exported under the conditions ["require","node","production"] from package @actions/core

and skipLibCheck does not help — it is a bundling constraint, not a type-checking one. #123 therefore landed on the last CommonJS majors (@actions/github 8.0.1, @actions/core 2.0.3), which are current-generation in every other respect (octokit core 7, http-client 3, undici 6).

To go further the action itself needs to become ESM:

  • package.json "type": "module"; tsconfig module/moduleResolutionnodenext
  • Replace the 26 import type { Context } from '@actions/github/lib/context' (subpath not in the v9 exports map) with a local alias such as type Context = typeof github.context, and WebhookPayload with typeof github.context.payload
  • __tests__/testUtils.ts MockContext extends Context needs the class via github.context.constructor
  • __tests__/bundle/runBundle.ts uses __dirnameimport.meta.dirname
  • Confirm ncc emits an ESM bundle and action.yml (node24) runs dist/index.js as ESM given the root package.json type
  • Re-run the bundle harness; check for webpackMissingModule

Dependabot will keep proposing the v3/v9 bumps; close them referencing this issue until it is done.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions