-
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
|
View your CI Pipeline Execution ↗ for commit 8da1b65
☁️ Nx Cloud last updated this comment at |
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.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the syntax error in the handleCallback function that was preventing Prettier from formatting the file. The malformed conditional logic with an orphaned else-if statement has been restructured to properly handle stdout and stderr within the correct if/else if blocks, resolving the format:check failure.
We verified this fix by re-running nx-cloud record -- nx format:check.
Suggested Fix changes
diff --git a/packages/js/src/utils/swc/compile-swc.ts b/packages/js/src/utils/swc/compile-swc.ts
index ba124df796..aaf0b4bef2 100644
--- a/packages/js/src/utils/swc/compile-swc.ts
+++ b/packages/js/src/utils/swc/compile-swc.ts
@@ -161,22 +161,15 @@ export async function* compileSwcWatch(
handleCallback = async (type: string, data?: string) => {
if (type === 'stdout') {
- process.stdout.write(data);
- if (data.includes('Successfully')) {
- // Handle success case
- }
- } else if (type === 'stderr') {
- // Process stderr data appropriately
- }
process.stdout.write(data);
if (!data.startsWith('Watching')) {
const swcStatus = data.includes('Successfully');
-
+
if (initialPostCompile) {
await postCompilationCallback();
initialPostCompile = false;
}
-
+
if (
normalizedOptions.skipTypeCheck ||
normalizedOptions.isTsSolutionSetup
@@ -184,11 +177,11 @@ export async function* compileSwcWatch(
next(getResult(swcStatus));
return;
}
-
+
if (!typeCheckOptions) {
typeCheckOptions = getTypeCheckOptions(normalizedOptions);
}
-
+
const delayed = delay(5000);
next(
getResult(
@@ -196,22 +189,24 @@ export async function* compileSwcWatch(
delayed
.start()
.then(() => ({ tscStatus: false, type: 'timeout' })),
- runTypeCheck(typeCheckOptions).then(({ errors, warnings }) => {
- const hasErrors = errors.length > 0;
- if (hasErrors) {
- printDiagnostics(errors, warnings);
+ runTypeCheck(typeCheckOptions).then(
+ ({ errors, warnings }) => {
+ const hasErrors = errors.length > 0;
+ if (hasErrors) {
+ printDiagnostics(errors, warnings);
+ }
+ return {
+ tscStatus: !hasErrors,
+ type: 'tsc',
+ };
}
- return {
- tscStatus: !hasErrors,
- type: 'tsc',
- };
- }),
+ ),
]).then(({ type, tscStatus }) => {
if (type === 'tsc') {
delayed.cancel();
return tscStatus && swcStatus;
}
-
+
return swcStatus;
})
)
@@ -224,8 +219,8 @@ export async function* compileSwcWatch(
}
next(getResult(false));
}
- }
-
+ };
+
stdoutOnData = async (data?: string) => {
handleCallback('stdout', data);
};
Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.
Apply changes locally with:
npx nx-cloud apply-locally Swip-OTJz
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
…wc/cli version (#32685) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> 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 <!-- This is the behavior we should expect with the changes in this PR --> stdout and stderr are now handled more precisely, allowing you to update to the latest version of @swc/cli. --------- Co-authored-by: Colum Ferry <[email protected]>
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |

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.