Skip to content

Migrate to esm#363

Merged
pbrisbin merged 3 commits intomainfrom
pb/esm
Mar 31, 2026
Merged

Migrate to esm#363
pbrisbin merged 3 commits intomainfrom
pb/esm

Conversation

@pbrisbin
Copy link
Copy Markdown
Member

fix: migrate to esm module

825a3d6

In order to use dependencies that are esm modules (which @actions/*
just did), we have to be an esm module ourselves.

Note that this doesn't work yet; esm modules break jest's mocking.
This'll be addressed in future commits.

chore: replace jest mock with dep injection

ebe8dbd

We can't mock that way with esm dependencies1. There are some
workarounds, but nothing worked, so I decided to introduce my own
interface and dependency injection.

In the exec module, apparently, we used to do it this way; there was
an old (unused) ExecDelegate interface. When implementing withCache,
I tried to follow that naming and test definition style, balanced
against reducing the diff with main.

chore: introduce CacheOptions{silent} to avoid logging in tests

1be63c3

Now that it's an esm module, we can't mock core like we were.

Footnotes

  1. https://github.com/jestjs/jest/issues/10025

@pbrisbin pbrisbin changed the title chore: introduce CacheOptions{silent} to avoid logging in tests Migrate to esm Mar 27, 2026
@pbrisbin pbrisbin marked this pull request as ready for review March 27, 2026 14:34
@pbrisbin pbrisbin requested a review from a team as a code owner March 27, 2026 14:34
@pbrisbin pbrisbin requested review from mjgpy3 and removed request for a team March 27, 2026 14:34
mjgpy3
mjgpy3 previously approved these changes Mar 31, 2026
In order to use dependencies that are esm modules (which `@actions/*`
just did), we have to be an esm module ourselves.

Note that this doesn't work yet; esm modules break jest's mocking.
This'll be addressed in future commits.
We can't mock that way with esm dependencies[^1]. There are some
workarounds, but nothing worked, so I decided to introduce my own
interface and dependency injection.

In the `exec` module, apparently, we used to do it this way; there was
an old (unused) `ExecDelegate` interface. When implementing `withCache`,
I tried to follow that naming and test definition style, balanced
against reducing the diff with `main`.

[^1]: jestjs/jest#10025
Now that it's an esm module, we can't mock `core` like we were.
@pbrisbin
Copy link
Copy Markdown
Member Author

Had to deal with conflicts locally, so I'll need a re-approve.

@pbrisbin pbrisbin requested a review from mjgpy3 March 31, 2026 12:48
@pbrisbin pbrisbin merged commit cfdc147 into main Mar 31, 2026
20 checks passed
@pbrisbin pbrisbin deleted the pb/esm branch March 31, 2026 13:00
@pbrisbin
Copy link
Copy Markdown
Member Author

For future reference, migrating to vitest has been successful in keeping the module mocking working. I may come back and take that strategy here, and remove the explicit dep injection.

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.

2 participants