Skip to content

Conversation

@justfalter
Copy link

This change eliminates two import cycles found in @actions/core. These import cycles would prevent rollupjs from removing unused code within @actions/core, bloating the resultant packaged js. Anecdotally, with these changes, a project I work on that only uses core's info and setState was reduced in size from 1.0MiB to approximately 244KiB.

  • core.ts <-> oidc-utils.ts:
    • core.ts importing from oidc-utils.ts for the purpose of forming and exporting getIDToken().
    • oidc-utils.ts was importing debug() and setSecret from core.ts.
    • Resolved by:
      • Moving getIDToken into oidc-utils.ts.
      • Moving all package exports into index.ts, including the export of getIDToken.
  • core.ts <-> utils.ts:
    • core.ts importing toCommandProperties and toCommandValue from utils.ts.
    • utils.ts importing AnnotationProperties from core.ts.
    • Resolved by moving the definition of AnnotationProperties into core-type.ts, and having utils.ts import from there.

Partially fixes #1436, where one of the import cycles were first described.

@justfalter justfalter requested a review from a team as a code owner September 8, 2025 19:04
This change eliminates two import cycles found in `@actions/core`.
These import cycles would prevent rollupjs from removing unused code
within `@actions/core`, bloating the resultant packaged js. Anecdotally,
with these changes, a project I work on that only uses core's `info` and
`setState` was reduced in size from 1.0MiB to approximately 244KiB.

- `core.ts` <-> `oidc-utils.ts`:
  - `core.ts` importing from `oidc-utils.ts` for the purpose of
    forming and exporting `getIDToken()`.
  - `oidc-utils.ts` was importing `debug()` and `setSecret` from
    `core.ts`.
  - Resolved by:
    - Moving `getIDToken` into `oidc-utils.ts`.
    - Moving all package exports into `index.ts`, including the export
      of `getIDToken`.
- `core.ts` <-> `utils.ts`:
  - `core.ts` importing `toCommandProperties` and `toCommandValue` from
    `utils.ts`.
  - `utils.ts` importing `AnnotationProperties` from `core.ts`.
  - Resolved by moving the definition of `AnnotationProperties` into
    `core-type.ts`, and having `utils.ts` import from there.

Partially fixes actions#1436, where one of the import cycles were first
described.
@justfalter justfalter force-pushed the core-eliminate-import-loop branch from 4d05e28 to 9e75787 Compare September 8, 2025 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant