Skip to content

Replace ncc with esbuild - #1755

Open
jeffwidman wants to merge 1 commit into
mainfrom
migrate-to-esbuild
Open

Replace ncc with esbuild#1755
jeffwidman wants to merge 1 commit into
mainfrom
migrate-to-esbuild

Conversation

@jeffwidman

@jeffwidman jeffwidman commented Aug 11, 2026

Copy link
Copy Markdown
Member

Why this is required

This is a prerequisite for updating the GitHub Actions toolkit dependencies, not just a build-tool cleanup. The next major versions of @actions/core, @actions/github, and @actions/http-client are ESM-only, and the current ncc build cannot package them into a self-contained action reliably.

The migration unblocks these open Dependabot PRs:

Under ncc, those updates currently fail build and runtime checks. For example, the @actions/core update leaves require("@actions/core") unresolved and fails on a clean runner with Cannot find module '@actions/core'. The @actions/github update also causes ncc to fail resolving the package's exported lib/context types. Esbuild understands the newer ESM package exports and still emits the CommonJS bundles required by this Node 24 action.

Benefits

  • unblocks current and future ESM-only @actions/* dependency updates, including security-related transitive updates
  • reduces committed dist output from 40 files and 17.3 MB to 2 files and 6.5 MB, a roughly 62% reduction
  • removes source maps that are not consumed by the action and runtime assets for unsupported Docker SSH, BuildKit, and gRPC capabilities
  • replaces two ncc invocations with one copy-and-pasteable esbuild command for both entry points
  • makes the supported runtime explicit with --platform=node --target=node24
  • keeps bundles unminified so generated failures remain easier to inspect

Implementation

  • replace @vercel/ncc with esbuild and bundle both Node 24 action entry points in one command
  • switch the action to flat dist/main.js and dist/cleanup.js entry points
  • remove ncc-specific source maps, native SSH binaries, protobuf files, and other generated assets
  • treat optional .node SSH accelerators as empty because this action supports local Unix Docker sockets, not remote Docker over SSH

Esbuild currently uses its bundled-output default for legal comments (eof), preserving recognized notices inside each JavaScript bundle while OSPO guidance is pending.

Validation

  • npm run format-check
  • npm run typecheck
  • npm run lint-check
  • 134 unit tests pass; the local command retains a pre-existing nonzero exit when the Actions environment is absent, reproduced on main
  • npm run fetch-images -- bundler && npm run test-integration (17 tests)
  • executed both generated bundles through deterministic no-op paths
  • clean install reproduces both bundles byte-for-byte
  • npm clean-install && npm run package && script/check-diff

Comment thread .gitignore

# Ignore optional native extensions for SSH
dist/*/build/Release/cpufeatures.node
dist/*/lib/protocol/crypto/build/Release/sshcrypto.node

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These can be safely ignored because they are no longer generated, they're skipped via passing the --loader:.node=empty flag to esbuild

@jeffwidman
jeffwidman marked this pull request as ready for review August 11, 2026 00:48
@jeffwidman
jeffwidman requested a review from a team as a code owner August 11, 2026 00:48
Copilot AI balanced review requested due to automatic review settings August 11, 2026 00:48

Copilot AI 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.

Pull request overview

Migrates action packaging from ncc to esbuild, enabling future ESM-only GitHub Actions toolkit upgrades.

Changes:

  • Builds flat Node 24 bundles with esbuild.
  • Updates action entry points and contributor documentation.
  • Removes obsolete ncc artifacts, runtime assets, and source maps.
Show a summary per file
File Description
.gitignore Removes native-extension exclusions.
README.md Updates generated-bundle example.
action.yml Uses flat bundle entry points.
dist/cleanup.js Adds esbuild cleanup bundle.
dist/cleanup/auth.proto Removes unused runtime asset.
dist/cleanup/buildkit_status.proto Removes unused BuildKit asset.
dist/cleanup/index.js Removes ncc cleanup bundle.
dist/cleanup/index.js.map Removes cleanup source map.
dist/cleanup/licenses.txt Removes ncc license aggregation.
dist/cleanup/pagent.exe Removes SSH helper.
dist/cleanup/proto/channelz.proto Removes gRPC asset.
dist/cleanup/proto/protoc-gen-validate/LICENSE Removes generated license asset.
dist/cleanup/proto/protoc-gen-validate/validate/validate.proto Removes validation schema.
dist/cleanup/proto/xds/LICENSE Removes generated license asset.
dist/cleanup/proto/xds/xds/data/orca/v3/orca_load_report.proto Removes ORCA schema.
dist/cleanup/proto/xds/xds/service/orca/v3/orca.proto Removes ORCA service schema.
dist/cleanup/protoc-gen-validate/LICENSE Removes duplicate license asset.
dist/cleanup/protoc-gen-validate/validate/validate.proto Removes duplicate validation schema.
dist/cleanup/sourcemap-register.js Removes source-map support.
dist/cleanup/xds/LICENSE Removes duplicate license asset.
dist/cleanup/xds/xds/data/orca/v3/orca_load_report.proto Removes duplicate ORCA schema.
dist/cleanup/xds/xds/service/orca/v3/orca.proto Removes duplicate ORCA service schema.
dist/main.js Adds esbuild main bundle.
dist/main/auth.proto Removes unused runtime asset.
dist/main/buildkit_status.proto Removes unused BuildKit asset.
dist/main/index.js Removes ncc main bundle.
dist/main/index.js.map Removes main source map.
dist/main/licenses.txt Removes ncc license aggregation.
dist/main/pagent.exe Removes SSH helper.
dist/main/proto/channelz.proto Removes gRPC asset.
dist/main/proto/protoc-gen-validate/LICENSE Removes generated license asset.
dist/main/proto/protoc-gen-validate/validate/validate.proto Removes validation schema.
dist/main/proto/xds/LICENSE Removes generated license asset.
dist/main/proto/xds/xds/data/orca/v3/orca_load_report.proto Removes ORCA schema.
dist/main/proto/xds/xds/service/orca/v3/orca.proto Removes ORCA service schema.
dist/main/protoc-gen-validate/LICENSE Removes duplicate license asset.
dist/main/protoc-gen-validate/validate/validate.proto Removes duplicate validation schema.
dist/main/sourcemap-register.js Removes source-map support.
dist/main/xds/LICENSE Removes duplicate license asset.
dist/main/xds/xds/data/orca/v3/orca_load_report.proto Removes duplicate ORCA schema.
dist/main/xds/xds/service/orca/v3/orca.proto Removes duplicate ORCA service schema.
package-lock.json Locks esbuild dependencies.
package.json Replaces ncc packaging with esbuild.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/43 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread package.json
"lint-check": "eslint **/*.ts",
"typecheck": "tsc --noEmit",
"package": "ncc build -o dist/main src/main.ts --source-map --license licenses.txt && ncc build -o dist/cleanup src/cleanup.ts --source-map --license licenses.txt",
"package": "esbuild src/main.ts src/cleanup.ts --bundle --platform=node --target=node24 --outdir=dist --loader:.node=empty",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I've got an open discussion internally with the licensing team about this. That is expected to be resolved in a few days.

In the meantime, the default is sufficient for now and whatever they tell us will be a fast-follow PR before we cut our next release.

I do not want to block this PR on ☝️ because there's some other additional PR's (like the :dependabot: ones) that are blocked on the migration to esbuild.

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