13
13
14
14
'use strict' ;
15
15
16
+ const ProfilerContext = require ( './ProfilerContext' ) ;
16
17
const React = require ( 'react' ) ;
17
18
18
19
const preloadQuery_DEPRECATED = require ( './preloadQuery_DEPRECATED' ) ;
19
20
const useRelayEnvironment = require ( './useRelayEnvironment' ) ;
20
21
21
- const { useMemo} = require ( 'react' ) ;
22
+ const { useContext , useEffect , useMemo} = require ( 'react' ) ;
22
23
const { stableCopy} = require ( 'relay-runtime' ) ;
23
24
25
+ import type { JSResourceReference } from 'JSResourceReference' ;
26
+
24
27
type PreloadedEntryPoint < TEntryPointComponent > = $ReadOnly < { |
25
28
entryPoints : $PropertyType <
26
29
React . ElementConfig < TEntryPointComponent > ,
@@ -32,6 +35,7 @@ type PreloadedEntryPoint<TEntryPointComponent> = $ReadOnly<{|
32
35
> ,
33
36
getComponent : ( ) => TEntryPointComponent ,
34
37
queries : $PropertyType < React . ElementConfig < TEntryPointComponent > , 'queries' > ,
38
+ rootModuleReference : JSResourceReference < TEntryPointComponent > ,
35
39
| } > ;
36
40
37
41
import type {
@@ -150,6 +154,8 @@ function prepareEntryPoint<
150
154
return ( component : TEntryPointComponent ) ;
151
155
} ,
152
156
queries : ( preloadedQueries : TPreloadedQueries ) ,
157
+ // $FlowFixMe[incompatible-cast] - trust me Flow, its entryPoint component
158
+ rootModuleReference : ( entryPoint . root : JSResourceReference < TEntryPointComponent > ) ,
153
159
} ;
154
160
}
155
161
@@ -177,7 +183,13 @@ function LazyLoadEntryPointContainer_DEPRECATED<
177
183
// *must* be computed first to fetch the component's data-dependencies in
178
184
// parallel with the component itself (the code).
179
185
const entryPointParamsHash = stableStringify ( entryPointParams ) ;
180
- const { getComponent, queries, entryPoints, extraProps} = useMemo ( ( ) => {
186
+ const {
187
+ getComponent,
188
+ queries,
189
+ entryPoints,
190
+ extraProps,
191
+ rootModuleReference,
192
+ } = useMemo ( ( ) => {
181
193
return prepareEntryPoint (
182
194
environmentProvider ?? {
183
195
getEnvironment : ( ) => environment ,
@@ -191,6 +203,15 @@ function LazyLoadEntryPointContainer_DEPRECATED<
191
203
const Component = useMemo ( ( ) => {
192
204
return getComponent ( ) ;
193
205
} , [ getComponent ] ) ;
206
+
207
+ const profilerContext = useContext ( ProfilerContext ) ;
208
+ useEffect ( ( ) => {
209
+ environment . __log ( {
210
+ name : 'entrypoint.root.consume' ,
211
+ profilerContext,
212
+ rootModuleID : rootModuleReference . getModuleId ( ) ,
213
+ } ) ;
214
+ } , [ environment , profilerContext , rootModuleReference ] ) ;
194
215
return (
195
216
< Component
196
217
entryPoints = { entryPoints }
0 commit comments