-
-
Notifications
You must be signed in to change notification settings - Fork 242
refactor(dev-middleware): improve output filesystem typing #6098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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-inRspack.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.
There was a problem hiding this 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".
if (context.options.writeToDisk) { | ||
const firstCompiler = isMultiCompiler(context.compiler) | ||
? context.compiler.compilers[0] | ||
: context.compiler; | ||
outputFileSystem = firstCompiler.outputFileSystem || fs; | ||
} else { |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
OutputFileSystem
type with Rspack's built-in typeRelated Links
#6092
Checklist