next.js
869b45ef - Resolve local variable references in error code SWC plugin (#89596)

Commit
1 day ago
Resolve local variable references in error code SWC plugin (#89596) The error code plugin now resolves local variable references in error constructors to their string literal initializers. Previously, `const msg = 'Error text'; throw new Error(msg)` would produce `"%s"` as the error message, preventing it from being tracked in `errors.json`. A pre-pass `BindingCollector` now collects variable declarations before the transformation pass, enabling error code assignment for these patterns. This adds 50 new error codes to `errors.json`. Variable references that still can't be resolved include imported constants (cross-module), function return values, object property access, and function parameters. These continue to produce `"%s"` as before. Also fixes `rcstr!()` to `.into()`. The `rcstr!` macro was introduced by a bulk Turbopack refactor (#80552), but was never available as a dependency of this standalone crate. `turbo-rcstr` can't be added as a dependency because it uses workspace-level dependency references that aren't resolvable from this standalone crate's `Cargo.lock`.
Author
Parents
Loading