7979 * module members are fine: they import the owning module, so declarations
8080 * stay single-owned.
8181 * R12. A namespace module's OWN umbrella (ReactCommon/<ns...>/React/<Name>.h,
82- * natural path React/<Name>.h) ships in ReactNativeHeaders — it is NOT
83- * hoisted into React.framework by R1. ReactNativeHeaders is the LOWER
84- * layer (React.framework imports it: RCTCallInvoker.h pulls
82+ * natural path React/<Name>.h) is hoisted into React.framework by R1, but
83+ * declared `exclude header` in the React module map. ReactNativeHeaders
84+ * is the LOWER layer (React.framework imports it: RCTCallInvoker.h pulls
8585 * <ReactCommon/CallInvoker.h>), so a framework-owned umbrella turns every
8686 * `#include <React/X.h>` inside a lowercase-namespace header into an import
8787 * of module React and closes a cycle:
8888 * React -> ReactNativeHeaders_react -> React
89- * Found empirically: react/timing/primitives.h -> <React/Debug.h>. Kept in
90- * ReactNativeHeaders the same spelling still resolves — framework lookup
91- * misses and clang falls back to the header search path — textually and
92- * within one artifact, so no module edge is created. These umbrellas are
93- * objc-blocked by construction (they re-export their module's C++
94- * surface), so they were never R4 umbrella or R5 module members anyway.
89+ * Found empirically: react/timing/primitives.h -> <React/Debug.h>. An
90+ * excluded header is included textually, so no module edge is created.
91+ * It cannot ship in ReactNativeHeaders instead: a `React/` dir next to
92+ * `react/` merges with it on a case-insensitive filesystem.
9593 * R13. The C++ stable API guards (react/cxxstableapi/*Guard.h) are
9694 * `textual header` members of their R5 module, as is every R5 member that
9795 * reaches one through unguarded includes. A guard decides at each
@@ -139,6 +137,8 @@ export type HeadersSpecPlan = {
139137 namespaceUmbrellas: Array<{relPath: string, content: string}>,
140138 // R9: private headers added to the React module map (allowlist).
141139 privateReactHeaders: {modular: Array<string>, textual: Array<string>},
140+ // R12: React.framework headers declared `exclude header`.
141+ excludedReactHeaders: Array<string>,
142142 collisions: Array<string>,
143143};
144144*/
@@ -362,6 +362,7 @@ function planFromInventory(
362362 const react /*: Array<SpecEntry> */ = [ ] ;
363363 const reactNativeHeaders /*: Array<SpecEntry> */ = [ ] ;
364364 const umbrella /*: Array<string> */ = [ ] ;
365+ const excludedReactHeaders /*: Array<string> */ = [ ] ;
365366 const namespaceModules /*: {[string]: Array<string>} */ = { } ;
366367 const textualNamespaceHeaders /*: Array<string> */ = [ ] ;
367368 const guardedHeaders = stableApiGuardedHeaders ( manifest ) ;
@@ -374,13 +375,7 @@ function planFromInventory(
374375 let bucketKey ;
375376 let entryList ;
376377 let relPath ;
377- if ( np . startsWith ( 'React/' ) && NS_MODULE_UMBRELLA_RE . test ( source ) ) {
378- // R12: a namespace module's own umbrella stays in the LOWER layer, so
379- // including it from that namespace cannot create a React module edge.
380- relPath = np ;
381- bucketKey = `ReactNativeHeaders/${ relPath } ` ;
382- entryList = reactNativeHeaders ;
383- } else if ( np . startsWith ( 'React/' ) ) {
378+ if ( np . startsWith ( 'React/' ) ) {
384379 relPath = np . slice ( 6 ) ; // R1: hoist React/ to the framework Headers root
385380 bucketKey = `React.framework/${ relPath } ` ;
386381 entryList = react ;
@@ -405,13 +400,18 @@ function planFromInventory(
405400 seen . set ( bucketKey , source ) ;
406401 entryList . push ( { relPath, source, naturalPath : np } ) ;
407402
408- // R4: React umbrella membership. Only headers the framework actually ships
409- // (R12 umbrellas carry a React/ natural path but live in ReactNativeHeaders).
410- if (
411- entryList === react &&
412- np . startsWith ( 'React/' ) &&
413- isUmbrellaSafe ( h , root )
414- ) {
403+ if ( np . startsWith ( 'React/' ) && NS_MODULE_UMBRELLA_RE . test ( source ) ) {
404+ // R12: fail closed, an umbrella member would bring the cycle back.
405+ if ( isUmbrellaSafe ( h , root ) ) {
406+ throw new Error (
407+ `R12: '${ np } ' is a modular candidate. As a React module member it ` +
408+ `would close the React -> ReactNativeHeaders_react -> React ` +
409+ `cycle. Keep it out of the modular surface.` ,
410+ ) ;
411+ }
412+ excludedReactHeaders . push ( relPath ) ;
413+ } else if ( np . startsWith ( 'React/' ) && isUmbrellaSafe ( h , root ) ) {
414+ // R4: React umbrella membership.
415415 umbrella . push ( np ) ;
416416 }
417417 // R5: namespace modules (only for ReactNativeHeaders namespaces). Every
@@ -424,19 +424,6 @@ function planFromInventory(
424424 if ( entryList === reactNativeHeaders ) {
425425 const ns = np . split ( '/' ) [ 0 ] ;
426426 if ( isUmbrellaSafe ( h , root ) ) {
427- // R12 assert: an R12-routed umbrella lands under the `React` namespace
428- // here, and renderNamespaceModuleMap only renames the lowercase `react`
429- // one — so its module would be named `React` and alias the framework
430- // module, reintroducing the cycle R12 exists to break. These umbrellas
431- // are objc-blocked today so they never reach this branch; fail closed
432- // if that ever changes.
433- if ( ns === 'React' ) {
434- throw new Error (
435- `R12: '${ np } ' is a modular candidate in ReactNativeHeaders. Its ` +
436- `namespace module would be named 'React' and alias the React ` +
437- `framework module. Keep it out of the modular surface.` ,
438- ) ;
439- }
440427 // R5 exemption assert: a namespace whose name is not a valid module
441428 // identifier cannot get a module, so a modular-candidate header in it
442429 // would be silently non-modular — consumers importing it from a
@@ -463,6 +450,7 @@ function planFromInventory(
463450 }
464451
465452 umbrella . sort ( ) ;
453+ excludedReactHeaders . sort ( ) ;
466454 for ( const ns of Object . keys ( namespaceModules ) ) {
467455 namespaceModules [ ns ] . sort ( ) ;
468456 }
@@ -539,23 +527,27 @@ function planFromInventory(
539527 textualNamespaceHeaders,
540528 namespaceUmbrellas,
541529 privateReactHeaders : PRIVATE_REACT_HEADERS ,
530+ excludedReactHeaders,
542531 collisions,
543532 } ;
544533}
545534
546535/**
547- * Renders React.framework's module map (R4 + R9). The umbrella covers the
536+ * Renders React.framework's module map (R4 + R9 + R12 ). The umbrella covers the
548537 * public modular surface; the allowlisted private headers (R9) are appended as
549538 * explicit `header` (modular) / `textual header` (objc-blocked) entries so
550539 * `#import <React/...>` of them stays modular without polluting the umbrella.
540+ * The R12 umbrellas are appended as `exclude header` entries.
551541 */
552542function renderReactModuleMap (
553543 privateReactHeaders /*:: ?: {modular: Array<string>, textual: Array<string>} */ ,
544+ excludedReactHeaders /*: ReadonlyArray<string> */ = [ ] ,
554545) /*: string */ {
555546 const pv = privateReactHeaders ?? { modular : [ ] , textual : [ ] } ;
556547 const extra = [
557548 ...pv . modular . map ( h => ` header "${ h } "` ) ,
558549 ...pv . textual . map ( h => ` textual header "${ h } "` ) ,
550+ ...excludedReactHeaders . map ( h => ` exclude header "${ h } "` ) ,
559551 ] ;
560552 const extraBlock = extra . length > 0 ? '\n' + extra . join ( '\n' ) : '' ;
561553 return `framework module React {
0 commit comments