Skip to content

build(check-changelog): bundle the script with esbuild - #32

Open
rekmarks-consensys-1 wants to merge 6 commits into
ocap/check-changelog-fixesfrom
ocap/check-changelog-bundle
Open

rekmarks-consensys-1 wants to merge 6 commits into
ocap/check-changelog-fixesfrom
ocap/check-changelog-bundle

Conversation

@rekmarks-consensys-1

@rekmarks-consensys-1 rekmarks-consensys-1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Lines added, by type

Code Tests Docs Generated Lockfiles Config Total
112 (3%) 18 (0%) 33 3548 620 5 4336

Generated: dist/check-changelog.js and dist/LICENSES.txt, written by npm run build. Lockfiles: the action's package-lock.json.

Bundles the check-changelog script with esbuild into a committed dist/check-changelog.js, and runs that instead of installing dependencies at run time. The action no longer runs npm ci; its inputs and behavior are otherwise unchanged from #31.

Stacked on #31.

To review: the first commit adds the build and dist/; the second switches the action, tests and README to the bundle; the rest are fixes to the build and the usage text. dist/check-changelog.js is generated and can be skipped.

Implementation

  • The action runs dist/check-changelog.js, a committed, unminified esbuild (0.28.2) bundle of the script and the code it uses from its dependencies: semver and @metamask/auto-changelog's parseChangelog (the package's dist/parse-changelog.js and the modules it imports). scripts/build.ts resolves @metamask/auto-changelog to that module, which the package's exports map doesn't expose, instead of its index, so the bundle contains none of the package's CLI dependencies (@yarnpkg/core, Octokit, execa, yargs).
  • The build fails if the bundle imports anything other than node: built-ins at run time. esbuild leaves an import it can't resolve in the bundle without a warning, and the action has no node_modules to load it from.
  • Nothing is installed at run time; the action doesn't run npm ci. All dependencies, pinned by package-lock.json, are now devDependencies, used only to build, typecheck and test.
  • The bundled packages' licenses are in dist/LICENSES.txt, written by the same build.
  • After changing the script or a dependency, run npm run build and commit dist/. CI rebuilds the bundle and fails if dist/ would change. The build empties dist/ first, so a committed file there that the build doesn't write also fails that check.
  • The script's usage text names check-changelog.js, the entry point the action runs.

Differences from upstream

Security

The action installs and resolves no packages at run time: it runs the committed bundle, built from the versions in package-lock.json.

Tests

  • test/fixtures.sh now runs the bundle, dist/check-changelog.js, which is what the action ships, and needs only Node.js. SCRIPT=<path> runs another script, such as the source.
  • .github/workflows/test_check-changelog.yml runs npm run build and fails if dist/ differs from what is committed, as after a dependency bump without a rebuild. The ocap-kernel job runs the bundled script, without npm ci.

🤖 Generated with Claude Code

@socket-security

socket-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedesbuild@​0.28.2921007385100

View full report

@rekmarks-consensys-1
rekmarks-consensys-1 removed this pull request from stack #33 November 25, 2026 01:07
@rekmarks-consensys-1 rekmarks-consensys-1 changed the title ocap/check changelog bundle build(check-changelog): bundle the script with esbuild Nov 25, 2026
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog-bundle branch from 923e190 to 9b57241 Compare November 25, 2026 01:14
@rekmarks-consensys-1
rekmarks-consensys-1 marked this pull request as ready for review November 25, 2026 01:22
@rekmarks-consensys-1
rekmarks-consensys-1 requested review from a team as code owners November 25, 2026 01:22

@joshuafernandes joshuafernandes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joshuafernandes joshuafernandes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

rekmarks-consensys-1 and others added 6 commits December 2, 2026 11:01
The action installs about 133 production packages at run time, most of
them @metamask/auto-changelog's CLI dependencies, though the script only
uses parseChangelog and semver. `npm run build` bundles the script into a
committed dist/check-changelog.js with only that code: a plugin resolves
@metamask/auto-changelog to its parse-changelog.js module, which the
package's exports map doesn't expose. The bundled packages' licenses go
to dist/LICENSES.txt. All dependencies are now devDependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndencies

The action runs dist/check-changelog.js and no longer runs npm ci, so no
package is installed or resolved at run time. The fixture tests and the
ocap-kernel job run the bundle, so the shipped artifact is what is
tested, and CI rebuilds the bundle and fails if dist/ is out of date, so
a dependency bump without a rebuild doesn't pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t-in

esbuild leaves an import it cannot resolve, such as a dynamic import in a
try block, in the bundle as a run-time import without a warning. The
action has no node_modules at run time, so such an import would fail only
when reached. The build now reads the metafile and fails if the output
imports anything other than node: built-ins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build overwrote its outputs but left any other file in dist/, so a
stale file committed there passed the CI check that dist/ matches a
fresh build. Emptying dist/ first makes such a file show up as deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The action runs dist/check-changelog.js, not the TypeScript source, so
the usage message and header comment now name check-changelog.js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog-bundle branch from 6b65d5a to 1b5aa77 Compare December 2, 2026 19:01

This branch has not been deployed

No deployments
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