@@ -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}
5666656677class 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) {
0 commit comments