@@ -67,12 +67,20 @@ export type LazyComponent<T, P> = {
6767
6868function lazyInitializer < T > (payload: Payload< T > ): T {
6969 if ( payload . _status === Uninitialized ) {
70+ let resolveDebugValue : ( void | T ) = > void = ( null : any ) ;
71+ let rejectDebugValue : mixed => void = ( null : any ) ;
7072 if ( __DEV__ && enableAsyncDebugInfo ) {
7173 const ioInfo = payload . _ioInfo ;
7274 if ( ioInfo != null ) {
7375 // Mark when we first kicked off the lazy request.
7476 // $FlowFixMe[cannot-write]
7577 ioInfo. start = ioInfo . end = performance . now ( ) ;
78+ // Stash a Promise for introspection of the value later.
79+ // $FlowFixMe[cannot-write]
80+ ioInfo . value = new Promise ( ( resolve , reject ) => {
81+ resolveDebugValue = resolve ;
82+ rejectDebugValue = reject ;
83+ } ) ;
7684 }
7785 }
7886 const ctor = payload . _result ;
@@ -98,6 +106,14 @@ function lazyInitializer<T>(payload: Payload<T>): T {
98106 // Mark the end time of when we resolved.
99107 // $FlowFixMe[cannot-write]
100108 ioInfo. end = performance . now ( ) ;
109+ // Surface the default export as the resolved "value" for debug purposes.
110+ const debugValue =
111+ moduleObject == null ? undefined : moduleObject . default ;
112+ resolveDebugValue ( debugValue ) ;
113+ // $FlowFixMe
114+ ioInfo . value . status = 'fulfilled' ;
115+ // $FlowFixMe
116+ ioInfo . value . value = debugValue ;
101117 }
102118 // Make the thenable introspectable
103119 if (thenable.status === undefined) {
@@ -124,6 +140,11 @@ function lazyInitializer<T>(payload: Payload<T>): T {
124140 // Mark the end time of when we rejected.
125141 // $FlowFixMe[cannot-write]
126142 ioInfo. end = performance . now ( ) ;
143+ rejectDebugValue ( error ) ;
144+ // $FlowFixMe
145+ ioInfo . value . status = 'rejected' ;
146+ // $FlowFixMe
147+ ioInfo . value . reason = error ;
127148 }
128149 // Make the thenable introspectable
129150 if ( thenable . status === undefined ) {
@@ -139,9 +160,6 @@ function lazyInitializer<T>(payload: Payload<T>): T {
139160 if ( __DEV__ && enableAsyncDebugInfo ) {
140161 const ioInfo = payload . _ioInfo ;
141162 if ( ioInfo != null ) {
142- // Stash the thenable for introspection of the value later.
143- // $FlowFixMe[cannot-write]
144- ioInfo. value = thenable ;
145163 const displayName = thenable . displayName ;
146164 if ( typeof displayName === 'string' ) {
147165 // $FlowFixMe[cannot-write]
0 commit comments