Skip to content

Commit e0d5f74

Browse files
committed
[compiler][patch] Emit unary expressions instead of negative numbers (#33383)
This is a babel bug + edge case. Babel compact mode produces invalid JavaScript (i.e. parse error) when given a `NumericLiteral` with a negative value. See https://codesandbox.io/p/devbox/5d47fr for repro. DiffTrain build for [526dd34](526dd34)
1 parent 457e990 commit e0d5f74

35 files changed

+92
-87
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44961,7 +44961,12 @@ function codegenLValue(cx, pattern) {
4496144961
}
4496244962
function codegenValue(cx, loc, value) {
4496344963
if (typeof value === 'number') {
44964-
return libExports$1.numericLiteral(value);
44964+
if (value < 0) {
44965+
return libExports$1.unaryExpression('-', libExports$1.numericLiteral(-value), false);
44966+
}
44967+
else {
44968+
return libExports$1.numericLiteral(value);
44969+
}
4496544970
}
4496644971
else if (typeof value === 'boolean') {
4496744972
return libExports$1.booleanLiteral(value);

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14094f80cbf52cad4024211080d8491f3334ef61
1+
526dd340b3e77193846fe5eed02b9bb89d7c2d15
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14094f80cbf52cad4024211080d8491f3334ef61
1+
526dd340b3e77193846fe5eed02b9bb89d7c2d15

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ __DEV__ &&
15371537
exports.useTransition = function () {
15381538
return resolveDispatcher().useTransition();
15391539
};
1540-
exports.version = "19.2.0-www-classic-14094f80-20250529";
1540+
exports.version = "19.2.0-www-classic-526dd340-20250602";
15411541
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15421542
"function" ===
15431543
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ __DEV__ &&
15371537
exports.useTransition = function () {
15381538
return resolveDispatcher().useTransition();
15391539
};
1540-
exports.version = "19.2.0-www-modern-14094f80-20250529";
1540+
exports.version = "19.2.0-www-modern-526dd340-20250602";
15411541
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15421542
"function" ===
15431543
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function (
635635
exports.useTransition = function () {
636636
return ReactSharedInternals.H.useTransition();
637637
};
638-
exports.version = "19.2.0-www-classic-14094f80-20250529";
638+
exports.version = "19.2.0-www-classic-526dd340-20250602";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function (
635635
exports.useTransition = function () {
636636
return ReactSharedInternals.H.useTransition();
637637
};
638-
exports.version = "19.2.0-www-modern-14094f80-20250529";
638+
exports.version = "19.2.0-www-modern-526dd340-20250602";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ exports.useSyncExternalStore = function (
639639
exports.useTransition = function () {
640640
return ReactSharedInternals.H.useTransition();
641641
};
642-
exports.version = "19.2.0-www-classic-14094f80-20250529";
642+
exports.version = "19.2.0-www-classic-526dd340-20250602";
643643
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
644644
"function" ===
645645
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ exports.useSyncExternalStore = function (
639639
exports.useTransition = function () {
640640
return ReactSharedInternals.H.useTransition();
641641
};
642-
exports.version = "19.2.0-www-modern-14094f80-20250529";
642+
exports.version = "19.2.0-www-modern-526dd340-20250602";
643643
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
644644
"function" ===
645645
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19080,10 +19080,10 @@ __DEV__ &&
1908019080
(function () {
1908119081
var internals = {
1908219082
bundleType: 1,
19083-
version: "19.2.0-www-classic-14094f80-20250529",
19083+
version: "19.2.0-www-classic-526dd340-20250602",
1908419084
rendererPackageName: "react-art",
1908519085
currentDispatcherRef: ReactSharedInternals,
19086-
reconcilerVersion: "19.2.0-www-classic-14094f80-20250529"
19086+
reconcilerVersion: "19.2.0-www-classic-526dd340-20250602"
1908719087
};
1908819088
internals.overrideHookState = overrideHookState;
1908919089
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19117,7 +19117,7 @@ __DEV__ &&
1911719117
exports.Shape = Shape;
1911819118
exports.Surface = Surface;
1911919119
exports.Text = Text;
19120-
exports.version = "19.2.0-www-classic-14094f80-20250529";
19120+
exports.version = "19.2.0-www-classic-526dd340-20250602";
1912119121
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1912219122
"function" ===
1912319123
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)