-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(js): adjusted stdout and stderr handling to support the latest @swc/cli version #32685
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: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
await postCompilationCallback(); | ||
initialPostCompile = false; | ||
handleCallback = async (type: string, data?: string) => { | ||
if (type === 'stdout' || data.includes('Successfully')) { |
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.
The condition type === 'stdout' || data.includes('Successfully')
creates a logical issue where stderr output containing "Successfully" would be processed as stdout data. This could cause error messages to be misinterpreted as success indicators.
Consider restructuring the condition to first check the stream type, then check the content:
if (type === 'stdout') {
// Process stdout data
process.stdout.write(data);
if (data.includes('Successfully')) {
// Handle success case
}
} else if (type === 'stderr') {
// Process stderr data appropriately
}
This would maintain proper separation between stdout and stderr handling while still detecting success messages.
if (type === 'stdout' || data.includes('Successfully')) { | |
if (type === 'stdout') { | |
process.stdout.write(data); | |
if (data.includes('Successfully')) { | |
// Handle success case | |
} | |
} else if (type === 'stderr') { | |
// Process stderr data appropriately | |
} |
Spotted by Diamond
Is this helpful? React π or π to let us know.
await postCompilationCallback(); | ||
initialPostCompile = false; | ||
handleCallback = async (type: string, data?: string) => { | ||
if (type === 'stdout' || data.includes('Successfully')) { |
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.
There's a potential issue with the conditional logic in this line. If data
is undefined, calling data.includes('Successfully')
will throw an error. Consider adding a null check to prevent runtime errors:
if (type === 'stdout' || (data && data.includes('Successfully'))) {
This ensures the code safely handles cases where data
might be undefined or null.
if (type === 'stdout' || data.includes('Successfully')) { | |
if (type === 'stdout' || (data && data.includes('Successfully'))) { |
Spotted by Diamond
Is this helpful? React π or π to let us know.
Current Behavior
Due to this PR swc-project/pkgs#53 at SWC, it is not possible to use the latest version of @swc/cli in NX.
Expected Behavior
stdout and stderr are now handled more precisely, allowing you to update to the latest version of @swc/cli.