Skip to content

Commit ac9e62b

Browse files
committed
[compiler] Avoid failing builds when import specifiers conflict or shadow vars (#32663)
Avoid failing builds when imported function specifiers conflict by using babel's `generateUid`. Failing a build is very disruptive, as it usually presents to developers similar to a javascript parse error. ```js import {logRender as _logRender} from 'instrument-runtime'; const logRender = () => { /* local conflicting implementation */ } function Component_optimized() { _logRender(); // inserted by compiler } ``` Currently, we fail builds (even in `panicThreshold:none` cases) when import specifiers are detected to conflict with existing local variables. The reason we destructively throw (instead of bailing out) is because (1) we first generate identifier references to the conflicting name in compiled functions, (2) replaced original functions with compiled functions, and then (3) finally check for conflicts. When we finally check for conflicts, it's too late to bail out. ```js // import {logRender} from 'instrument-runtime'; const logRender = () => { /* local conflicting implementation */ } function Component_optimized() { logRender(); // inserted by compiler } ``` DiffTrain build for [c61e75b](c61e75b)
1 parent 7f9b639 commit ac9e62b

35 files changed

+467
-425
lines changed

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

Lines changed: 381 additions & 339 deletions
Large diffs are not rendered by default.

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7c908bcf4e6b46135164be961972f0d756378517
1+
c61e75b76d5ff6707ad75c8beb777e721d982207
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7c908bcf4e6b46135164be961972f0d756378517
1+
c61e75b76d5ff6707ad75c8beb777e721d982207

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.1.0-www-classic-7c908bcf-20250323";
1540+
exports.version = "19.1.0-www-classic-c61e75b7-20250324";
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.1.0-www-modern-7c908bcf-20250323";
1540+
exports.version = "19.1.0-www-modern-c61e75b7-20250324";
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
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-classic-7c908bcf-20250323";
644+
exports.version = "19.1.0-www-classic-c61e75b7-20250324";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-modern-7c908bcf-20250323";
644+
exports.version = "19.1.0-www-modern-c61e75b7-20250324";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-classic-7c908bcf-20250323";
648+
exports.version = "19.1.0-www-classic-c61e75b7-20250324";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
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
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-modern-7c908bcf-20250323";
648+
exports.version = "19.1.0-www-modern-c61e75b7-20250324";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
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
@@ -18483,10 +18483,10 @@ __DEV__ &&
1848318483
(function () {
1848418484
var internals = {
1848518485
bundleType: 1,
18486-
version: "19.1.0-www-classic-7c908bcf-20250323",
18486+
version: "19.1.0-www-classic-c61e75b7-20250324",
1848718487
rendererPackageName: "react-art",
1848818488
currentDispatcherRef: ReactSharedInternals,
18489-
reconcilerVersion: "19.1.0-www-classic-7c908bcf-20250323"
18489+
reconcilerVersion: "19.1.0-www-classic-c61e75b7-20250324"
1849018490
};
1849118491
internals.overrideHookState = overrideHookState;
1849218492
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -18520,7 +18520,7 @@ __DEV__ &&
1852018520
exports.Shape = Shape;
1852118521
exports.Surface = Surface;
1852218522
exports.Text = Text;
18523-
exports.version = "19.1.0-www-classic-7c908bcf-20250323";
18523+
exports.version = "19.1.0-www-classic-c61e75b7-20250324";
1852418524
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1852518525
"function" ===
1852618526
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)