Skip to content

Commit b418aef

Browse files
committed
[compiler][entrypoint] Fix edgecases for noEmit and opt-outs (#33148)
Title --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33148). * #33149 * __->__ #33148 DiffTrain build for [3820740](3820740)
1 parent 66ad834 commit b418aef

35 files changed

+104
-92
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56083,6 +56083,7 @@ function compileProgram(program, pass) {
5608356083
filename: pass.filename,
5608456084
code: pass.code,
5608556085
suppressions,
56086+
hasModuleScopeOptOut: findDirectiveDisablingMemoization(program.node.directives) != null,
5608656087
});
5608756088
const queue = findFunctionsToCompile(program, pass, programContext);
5608856089
const compiledFns = [];
@@ -56113,7 +56114,16 @@ function compileProgram(program, pass) {
5611356114
});
5611456115
}
5611556116
}
56116-
if (findDirectiveDisablingMemoization(program.node.directives) != null) {
56117+
if (programContext.hasModuleScopeOptOut) {
56118+
if (compiledFns.length > 0) {
56119+
const error = new CompilerError();
56120+
error.pushErrorDetail(new CompilerErrorDetail({
56121+
reason: 'Unexpected compiled functions when module scope opt-out is present',
56122+
severity: ErrorSeverity.Invariant,
56123+
loc: null,
56124+
}));
56125+
handleError(error, programContext, null);
56126+
}
5611756127
return null;
5611856128
}
5611956129
applyCompiledFunctions(program, compiledFns, pass, programContext);
@@ -56197,10 +56207,7 @@ function processFn(fn, fnType, programContext) {
5619756207
prunedMemoBlocks: compiledFn.prunedMemoBlocks,
5619856208
prunedMemoValues: compiledFn.prunedMemoValues,
5619956209
});
56200-
if (directives.optIn != null) {
56201-
return compiledFn;
56202-
}
56203-
else if (programContext.opts.compilationMode === 'annotation') {
56210+
if (programContext.hasModuleScopeOptOut) {
5620456211
return null;
5620556212
}
5620656213
else if (programContext.opts.noEmit) {
@@ -56211,6 +56218,10 @@ function processFn(fn, fnType, programContext) {
5621156218
}
5621256219
return null;
5621356220
}
56221+
else if (programContext.opts.compilationMode === 'annotation' &&
56222+
directives.optIn == null) {
56223+
return null;
56224+
}
5621456225
else {
5621556226
return compiledFn;
5621656227
}
@@ -56664,7 +56675,7 @@ function validateRestrictedImports(path, { validateBlocklistedImports }) {
5666456675
}
5666556676
}
5666656677
class ProgramContext {
56667-
constructor({ program, suppressions, opts, filename, code, }) {
56678+
constructor({ program, suppressions, opts, filename, code, hasModuleScopeOptOut, }) {
5666856679
this.alreadyCompiled = new (WeakSet !== null && WeakSet !== void 0 ? WeakSet : Set)();
5666956680
this.knownReferencedNames = new Set();
5667056681
this.imports = new Map();
@@ -56676,6 +56687,7 @@ class ProgramContext {
5667656687
this.code = code;
5667756688
this.reactRuntimeModule = getReactCompilerRuntimeModule(opts.target);
5667856689
this.suppressions = suppressions;
56690+
this.hasModuleScopeOptOut = hasModuleScopeOptOut;
5667956691
}
5668056692
isHookName(name) {
5668156693
if (this.opts.environment.hookPattern == null) {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5069e18060e00d7c07b2b04ebc8a3fa21e2d810a
1+
3820740a7fbfc3b27a5127b43bdad44382ff3ce0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5069e18060e00d7c07b2b04ebc8a3fa21e2d810a
1+
3820740a7fbfc3b27a5127b43bdad44382ff3ce0

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-5069e180-20250509";
1540+
exports.version = "19.2.0-www-classic-3820740a-20250509";
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-5069e180-20250509";
1540+
exports.version = "19.2.0-www-modern-3820740a-20250509";
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-5069e180-20250509";
638+
exports.version = "19.2.0-www-classic-3820740a-20250509";

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-5069e180-20250509";
638+
exports.version = "19.2.0-www-modern-3820740a-20250509";

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-5069e180-20250509";
642+
exports.version = "19.2.0-www-classic-3820740a-20250509";
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-5069e180-20250509";
642+
exports.version = "19.2.0-www-modern-3820740a-20250509";
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
@@ -19065,10 +19065,10 @@ __DEV__ &&
1906519065
(function () {
1906619066
var internals = {
1906719067
bundleType: 1,
19068-
version: "19.2.0-www-classic-5069e180-20250509",
19068+
version: "19.2.0-www-classic-3820740a-20250509",
1906919069
rendererPackageName: "react-art",
1907019070
currentDispatcherRef: ReactSharedInternals,
19071-
reconcilerVersion: "19.2.0-www-classic-5069e180-20250509"
19071+
reconcilerVersion: "19.2.0-www-classic-3820740a-20250509"
1907219072
};
1907319073
internals.overrideHookState = overrideHookState;
1907419074
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19102,7 +19102,7 @@ __DEV__ &&
1910219102
exports.Shape = Shape;
1910319103
exports.Surface = Surface;
1910419104
exports.Text = Text;
19105-
exports.version = "19.2.0-www-classic-5069e180-20250509";
19105+
exports.version = "19.2.0-www-classic-3820740a-20250509";
1910619106
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1910719107
"function" ===
1910819108
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)