Skip to content
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

Fix error code check in windows #73981

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/next-error-code-swc-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct NewError {
}

fn is_error_class_name(name: &str) -> bool {
// Error classes are collected by https://gist.github.com/eps1lon/6cce3059dfa061f2a7dc28305fdaddae#file-collect-error-constructors-mjs
name == "AggregateError"
// built-in error classes
|| name == "Error"
Expand Down Expand Up @@ -150,9 +151,13 @@ impl VisitMut for TransformVisitor {
}

let new_error_expr: NewExpr = new_error_expr.unwrap();
let error_message = error_message.unwrap();

// Normalize line endings by converting Windows CRLF (\r\n) to Unix LF (\n)
// This ensures the comparison works consistently across different operating systems
let error_message = error_message.unwrap().replace("\r\n", "\n");

let code = self.errors.iter().find_map(|(key, value)| {
// We assume `errors.json` uses Unix LF (\n) as line endings
if *value == error_message {
Some(key)
} else {
Expand Down
Binary file modified packages/next/next_error_code_swc_plugin.wasm
Binary file not shown.
Loading