Skip to content

perf: remove node:assert import#5309

Merged
chenjiahan merged 1 commit intomainfrom
remove_assert_0526
May 26, 2025
Merged

perf: remove node:assert import#5309
chenjiahan merged 1 commit intomainfrom
remove_assert_0526

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Replacing an assert statement with a TypeScript type assertion and removing the imports accordingly.

Checklist

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

Copilot AI review requested due to automatic review settings May 26, 2025 07:27
@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit ea72498
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/683417ca174a820008585518
😎 Deploy Preview https://deploy-preview-5309--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: 75 (🟢 up 1 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (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

This PR removes the runtime assertion by replacing it with a TypeScript type assertion to improve performance.

  • Removes the node:assert import and the corresponding runtime check in favor of a compile-time type assertion.
  • Updates the destructuring assignment for userConfig in splitChunks.ts.
Comments suppressed due to low confidence (1)

packages/core/src/plugins/splitChunks.ts:153

  • Replacing the runtime assertion with a type assertion removes runtime validation for the userConfig strategy. Please ensure that this invariant is verified elsewhere or add a clarifying comment to explain why it's safe to rely solely on TypeScript's type checking here.
const { override, forceSplittingGroups, defaultConfig, userConfig } =
   ctx as SplitChunksContext & { userConfig: SplitBySize };

@chenjiahan chenjiahan merged commit bab33a8 into main May 26, 2025
12 checks passed
@chenjiahan chenjiahan deleted the remove_assert_0526 branch May 26, 2025 07:34
@chenjiahan chenjiahan mentioned this pull request May 27, 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