fix(build): strip comments from generated executables - #861
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 36de748 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Generated executables compiled with
output.minify: false, so Rspack kept every comment from every bundled dependency. For Effect v4 that meant full JSDoc withimport … from "effect"examples, 52 to 61 percent of each cargo-hauler bin, and text that reads like unbundled externals.composeEntryLibConfignow runs the SWC minimizer only to drop comments.compress,mangle, and SWC's whitespaceminifystay 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 setsminify.jswithminimizerOptions: { compress: false, mangle: false, minify: false }. The one-usegeneratedExecutableLegalCommentsexport is inlined.packages/agent-bundle/tests/build.test.ts. The hatch test that injects a broken banner now injects it atPROCESS_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 andyamlJSDoc, and runs the bin. The config-constant test is removed.website/docs/{en,zh}/reference/configuration.mdxanddocs/framework-mode.mddescribe the new output.Tradeoffs
The issue proposed
format: { beautify: true }. Rspack 2.2.3 documentsbeautifyas a no-op for its SWC minimizer, and a probe build collapsed to a 123 kB line.minimizerOptions.minify: falsekeeps 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
effectandyaml: 1,598,260 → 851,744 bytes, 930 → 0 commentedfrom "effect"lines, same stdout, 17,236 formatted lines.pnpm testat 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.tsexposed the banner-stage issue above, fixed and green (38/38). The other eight passed on rerun exceptexamples-real.e2e"drives the host-test routes", which fails the same way on untouchedmainin the same four-file run.