Skip to content

feat: narrow Rspack configuration type for tools.rspack#5230

Merged
chenjiahan merged 1 commit intomainfrom
narrow_rspack_config_type_0513
May 13, 2025
Merged

feat: narrow Rspack configuration type for tools.rspack#5230
chenjiahan merged 1 commit intomainfrom
narrow_rspack_config_type_0513

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented May 13, 2025

Summary

This PR aims to improve DX by narrow the type of Rspack.Configuration to make it easier to use tools.rspack function.

These properties are set by Rsbuild by default so they are non-nullable. A possible edge case is that a plugin removes these fields, but this is unlikely to happen.

  • With Rspack.Configuration, the plugins property is nullable:
tools: {
  rspack(config) {
    if (!config.plugins) {
      config.plugins = [];
    }
    config.plugins.push(new SomePlugin());
  }
}
  • With NarrowedRspackConfig, the plugins property is non-nullable:
tools: {
  rspack(config) {
    config.plugins.push(new SomePlugin());
  }
}

Checklist

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

@netlify
Copy link
Copy Markdown

netlify bot commented May 13, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 800a8dc
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/68230ebfb3cbda0008a649c9
😎 Deploy Preview https://deploy-preview-5230--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: 64 (🔴 down 6 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 site configuration.

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.

1 participant