Skip to content

@actions/core support tree shaking when bundled in a GitHub Action. #1436

Open

Description

@andykenward

Describe the enhancement
At the moment, when using @actions/core npm package in your own bundled GitHub action, the bundler is unable to tree shake unused code from @actions/core.

Additional information

If we do the below, it should help most bundlers to determine what can be removed from @actions/core when bundling.

Add to packages/core/package.json

"sideEffects": false,

Arrow Functions

Along with using arrow functions instead of the traditional function expression

export function getInput() {
...
}

to

export const getInput = () => {
...
} 

Entry point

Add a packages/core/src/index.ts entry point that individuals exports.

For example

export {
  addPath,
  exportVariable,
  getBooleanInput,
  getInput,
  getMultilineInput,
  setCommandEcho,
  setOutput,
  setSecret
} from './core'

Circular dependency issue

The 'import' structure also has a circular dependency issue, where files sometimes import each other.

For example core.ts and oidc-utils.ts import each other.

Refactoring the structure of files and function usage would resolve this issue and help with tree shaking when bundling.

Activity

  1. andykenward commented on Jun 22, 2023

    @andykenward
    Author

    While waiting for this issue to be addressed, I've published a fork of @actions/core as @unlike/github-actions-core that supports

    • NodeJS ^18
    • ES module package.
    • Tree shaking
    • Replaced uuid with node:crypto
  2. kamontat commented on Mar 21, 2024

    @kamontat

    Hello @actions/actions-runtime, Is someone still working on this instead of using fork package?

  3. andykenward commented on Apr 21, 2024

    @andykenward
    Author

    @kamontat Should we submit a ADR as part of the Enhancements and Feature Requests to progress this issue?

  4. kamontat commented on Apr 24, 2024

    @kamontat

    Hi @robherley, I saw that you is a @actions engineers.
    Do you have any suggestion to improve this issue.

  5. added 3 commits that reference this issue on Sep 8, 2025
    c9269d6
    4d05e28
    9e75787
  6. added 2 commits that reference this issue on Mar 16, 2026
    68dbb73
    443c641
  7. justfalter commented on Mar 16, 2026

    @justfalter

    FWIW, I've refreshed a PR (#2125) now that toolkit packages have been converted to ESM. Hopefully someone at GitHub picks it up.

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