feat(server): add compress.level option#5522
Merged
chenjiahan merged 1 commit intomainfrom Jul 3, 2025
Merged
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new compress.level configuration option for controlling zlib compression intensity.
- Introduce
levelin both English and Chinese docs with type, default values, and examples - Extend
CompressOptionstype to include thelevelproperty - Update server startup and middleware to use
zlibconstants instead of hard-coded values
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/config/server/compress.mdx | Add “level” section and update headings/formatting in Chinese docs |
| website/docs/en/config/server/compress.mdx | Add “level” section and update headings/formatting in English docs |
| packages/core/src/types/config.ts | Define level?: number in CompressOptions with JSDoc defaults |
| packages/core/src/server/prodServer.ts | Import node:zlib constants and replace hard-coded level for gzip |
| packages/core/src/server/gzipMiddleware.ts | Simplify signature to accept full CompressOptions |
Comments suppressed due to low confidence (3)
packages/core/src/server/gzipMiddleware.ts:26
- Add tests to verify that the
compress.leveloption is respected and applied correctly in the middleware for both development and preview/production servers.
level = zlib.constants.Z_BEST_SPEED,
packages/core/src/types/config.ts:434
- [nitpick] The JSDoc
@defaulttag is used with a multi-line list; consider using individual@defaultannotations or a single descriptive value to ensure documentation generators render the defaults correctly.
* @default
packages/core/src/server/gzipMiddleware.ts:26
- Consider validating or clamping the
levelvalue from user configuration to the supported range (0–9) before passing it tozlib.createGzipto prevent invalid inputs and potential runtime errors.
level = zlib.constants.Z_BEST_SPEED,
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.

Summary
compress.leveloption to set the level of zlib compression to apply to responses.leveloption, including its type, default values, and usage examples.Related Links
Checklist