Skip to content

Conversation

chenjiahan
Copy link
Member

Summary

  • Replace custom OutputFileSystem type with Rspack's built-in type
  • Remove redundant type assertions
  • Improve type safety in middleware stream handling

Related Links

#6092

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings September 9, 2025 09:26
Copy link

netlify bot commented Sep 9, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit aace282
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68bff2b7c5539200080e636a
😎 Deploy Preview https://deploy-preview-6098--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: 69 (🟢 up 8 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
Contributor

@Copilot 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 refactors the dev-middleware to improve type safety by replacing custom OutputFileSystem types with Rspack's built-in types and removing redundant type assertions throughout the middleware code.

  • Replace custom OutputFileSystem type with Rspack's built-in Rspack.OutputFileSystem type
  • Remove numerous type assertions (as any, as unknown) and improve type safety
  • Simplify filesystem setup logic and stream handling

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/core/src/dev-middleware/utils/setupOutputFileSystem.ts Replaces custom type with Rspack's OutputFileSystem, simplifies logic and removes type assertions
packages/core/src/dev-middleware/utils/getFilenameFromUrl.ts Updates type assertions for statSync calls to use cleaner unknown casting
packages/core/src/dev-middleware/middleware.ts Removes multiple type assertions throughout stream handling and HTTP header processing
packages/core/src/dev-middleware/index.ts Updates type definitions to use Rspack.OutputFileSystem instead of custom type

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +11 to +16
if (context.options.writeToDisk) {
const firstCompiler = isMultiCompiler(context.compiler)
? context.compiler.compilers[0]
: context.compiler;
outputFileSystem = firstCompiler.outputFileSystem || fs;
} else {

Choose a reason for hiding this comment

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

[P1] Preserve in-memory FS when writeToDisk is a callback

The new condition treats any truthy options.writeToDisk as a signal to use the real filesystem. When writeToDisk is a function (supported for selectively writing files), dev middleware previously kept an in-memory memfs and only flushed assets matching the callback via setupWriteToDisk. After this change the middleware always uses the disk filesystem whenever a callback is provided, so every asset is written to disk and the callback is effectively ignored. This regresses selective write-to-disk behavior.

Useful? React with 👍 / 👎.

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