Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove IIFE wrappers from dev invariant checks (#16963)
The error transform works by replacing calls to `invariant` with an `if` statement. Since we're replacing a call expression with a statement, Babel wraps the new statement in an immediately-invoked function expression (IIFE). This wrapper is unnecessary in practice because our `invariant` calls are always part of their own expression statement. In the production bundle, the function wrappers are removed by Closure. But they remain in the development bundles. This commit updates the transform to confirm that an `invariant` call expression's parent node is an expression statement. (If not, it throws a transform error.) Then, it replaces the expression statement instead of the expression itself, effectively removing the extraneous IIFE wrapper.
- Loading branch information
Showing
3 changed files
with
40 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters