Skip to content

fix(build): strip comments from generated executables - #861

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
fix/860-strip-bundled-comments
Sep 25, 2026
Merged

ScriptedAlchemy merged 3 commits into
mainfrom
fix/860-strip-bundled-comments

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Why

Generated executables compiled with output.minify: false, so Rspack kept every comment from every bundled dependency. For Effect v4 that meant full JSDoc with import … from "effect" examples, 52 to 61 percent of each cargo-hauler bin, and text that reads like unbundled externals.

composeEntryLibConfig now runs the SWC minimizer only to drop comments. compress, mangle, and SWC's whitespace minify stay off, so the output keeps its formatting and names. legalComments: 'inline' now takes effect and keeps /*! … */ license headers.

Closes #860

Scope

  • packages/agent-bundle/src/build/rslib.ts. The executable profile sets minify.js with minimizerOptions: { compress: false, mangle: false, minify: false }. The one-use generatedExecutableLegalComments export is inlined.
  • packages/agent-bundle/tests/build.test.ts. The hatch test that injects a broken banner now injects it at PROCESS_ASSETS_STAGE_REPORT. At the default stage the minimizer rejects it before the AB6005 walk the test exists to prove.
  • packages/agent-bundle/tests/self-contained-bundler-config.test.ts. The real build test asserts the shebang, formatted output, a kept /*! header, dropped fixture and yaml JSDoc, and runs the bin. The config-constant test is removed.
  • website/docs/{en,zh}/reference/configuration.mdx and docs/framework-mode.md describe the new output.

Tradeoffs

The issue proposed format: { beautify: true }. Rspack 2.2.3 documents beautify as a no-op for its SWC minimizer, and a probe build collapsed to a 123 kB line. minimizerOptions.minify: false keeps SWC's formatted codegen instead.

Blast Radius

Every generated executable changes bytes, so artifact digests change on the next build. Code is not compressed or renamed, and authors can restore comments with tools.rsbuild.output.minify: false.

Verification

  • Probe bin importing effect and yaml: 1,598,260 → 851,744 bytes, 930 → 0 commented from "effect" lines, same stdout, 17,236 formatted lines.
  • Probe build time with and without the minify pass is unchanged (509 to 786 ms before, 526 to 706 ms after, interleaved).
  • pnpm test at load average near 200. Unit passed 4,295 of 4,296; the one timeout (playground-service) passed on rerun. Route-unit and projection passed. Integration passed 1,155 of 1,164. build.test.ts exposed the banner-stage issue above, fixed and green (38/38). The other eight passed on rerun except examples-real.e2e "drives the host-test routes", which fails the same way on untouched main in the same four-file run.

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 36de748

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agent-bundle Patch
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-09-25T22:59:51.092096Z 14d21d4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@861
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@861
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@861
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@861

commit: 14d21d4

@ScriptedAlchemy
ScriptedAlchemy merged commit b4e3840 into main Sep 25, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 26, 2026
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.

composeEntryLibConfig minify: false ships every bundled dependency's comments (52-61% of each generated bin)

1 participant