Skip to content

feat(server): add compress.level option#5522

Merged
chenjiahan merged 1 commit intomainfrom
compress_level_0703
Jul 3, 2025
Merged

feat(server): add compress.level option#5522
chenjiahan merged 1 commit intomainfrom
compress_level_0703

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

  • Added a new compress.level option to set the level of zlib compression to apply to responses.
  • Updated the documentation to provide a detailed explanation of the level option, including its type, default values, and usage examples.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings July 3, 2025 03:05
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 3, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 1ae28cc
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/6865f393363cee0008b6d4d9
😎 Deploy Preview https://deploy-preview-5522--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 73 (🔴 down 2 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new compress.level configuration option for controlling zlib compression intensity.

  • Introduce level in both English and Chinese docs with type, default values, and examples
  • Extend CompressOptions type to include the level property
  • Update server startup and middleware to use zlib constants 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.level option 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 @default tag is used with a multi-line list; consider using individual @default annotations 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 level value from user configuration to the supported range (0–9) before passing it to zlib.createGzip to prevent invalid inputs and potential runtime errors.
    level = zlib.constants.Z_BEST_SPEED,

@chenjiahan chenjiahan merged commit 2800f99 into main Jul 3, 2025
13 checks passed
@chenjiahan chenjiahan deleted the compress_level_0703 branch July 3, 2025 03:13
@chenjiahan chenjiahan mentioned this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants