-
-
Notifications
You must be signed in to change notification settings - Fork 245
Fix TransformContext.code type to support Buffer when raw=true #6019
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
Conversation
|
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: chenjiahan <[email protected]>
@copilot finish this PR |
Co-authored-by: chenjiahan <[email protected]>
Fixed the Buffer type handling issue in transformLoader.ts and completed the PR. The fix adds proper type assertion |
@copilot but this loader does not set |
You're correct that |
@copilot The plugin author should expect to receive Buffer-type code when |
Co-authored-by: chenjiahan <[email protected]>
You're absolutely right. I reverted the incorrect Buffer-to-string conversion and instead fixed the type definition of |
Duplicated: #6017 |
Fixed a type definition issue in
TransformContext.code
where the type was defined asstring
but runtime behavior could passBuffer
objects when transform descriptors haveraw: true
.Problem
The
TransformContext.code
type was defined asstring
in the type system, but when a transform descriptor specifiesraw: true
, the system usestransformRawLoader.mjs
which passesBuffer
objects to transform handlers. This created a type mismatch where plugin authors expecting to handle Buffer objects when usingraw: true
would get TypeScript errors.Solution
Updated the type definition of
TransformContext.code
fromstring
tostring | Buffer
to accurately reflect the runtime behavior:This ensures that:
The fix maintains backward compatibility while providing accurate typing for the
raw: true
use case.💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.