@@ -256,57 +256,62 @@ function computeIOSOutputDir(outputPath, appRootDir) {
256256 return path . join ( outputPath ? outputPath : appRootDir , 'build/generated/ios' ) ;
257257}
258258
259- function generateSchema ( library ) {
259+ function generateSchemaInfo ( library ) {
260260 const pathToJavaScriptSources = path . join (
261261 library . libraryPath ,
262262 library . config . jsSrcsDir ,
263263 ) ;
264264 console . log ( `\n\n[Codegen] >>>>> Processing ${ library . config . name } ` ) ;
265265 // Generate one schema for the entire library...
266- return utils
267- . getCombineJSToSchema ( )
268- . combineSchemasInFileList ( [ pathToJavaScriptSources ] , 'ios' ) ;
266+ return {
267+ library : library ,
268+ schema : utils
269+ . getCombineJSToSchema ( )
270+ . combineSchemasInFileList ( [ pathToJavaScriptSources ] , 'ios' ) ,
271+ } ;
269272}
270273
271- function generateCode ( iosOutputDir , library , tmpDir , schema ) {
272- // ...then generate native code artifacts.
273- const libraryTypeArg = library . config . type ? ` ${ library . config . type } ` : '' ;
274-
274+ function generateCode ( iosOutputDir , schemaInfo ) {
275+ const tmpDir = fs . mkdtempSync (
276+ path . join ( os . tmpdir ( ) , schemaInfo . library . config . name ) ,
277+ ) ;
275278 const tmpOutputDir = path . join ( tmpDir , 'out' ) ;
276279 fs . mkdirSync ( tmpOutputDir , { recursive : true } ) ;
277280
278281 generateSpecsCLIExecutor . generateSpecFromInMemorySchema (
279282 'ios' ,
280- schema ,
283+ schemaInfo . schema ,
281284 tmpOutputDir ,
282- library . config . name ,
285+ schemaInfo . library . config . name ,
283286 'com.facebook.fbreact.specs' ,
284- libraryTypeArg ,
287+ schemaInfo . library . config . type ,
285288 ) ;
286289
287290 // Finally, copy artifacts to the final output directory.
288291 const outputDir =
289- CORE_LIBRARIES_WITH_OUTPUT_FOLDER [ library . config . name ] ?? iosOutputDir ;
292+ CORE_LIBRARIES_WITH_OUTPUT_FOLDER [ schemaInfo . library . config . name ] ??
293+ iosOutputDir ;
290294 fs . mkdirSync ( outputDir , { recursive : true } ) ;
295+ // TODO: Fix this. This will not work on Windows.
291296 execSync ( `cp -R ${ tmpOutputDir } /* "${ outputDir } "` ) ;
292- console . log ( `[Codegen] Generated artifacts: ${ iosOutputDir } ` ) ;
297+ console . log ( `[Codegen] Generated artifacts: ${ outputDir } ` ) ;
293298}
294299
295- function generateNativeCodegenFiles ( libraries , iosOutputDir ) {
296- const schemas = { } ;
297- libraries . forEach ( library => {
298- const tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , library . config . name ) ) ;
299- const schema = generateSchema ( library ) ;
300- generateCode ( iosOutputDir , library , tmpDir , schema ) ;
301-
302- // Filter the react native core library out.
303- // In the future, core library and third party library should
304- // use the same way to generate/register the fabric components.
305- if ( ! isReactNativeCoreLibrary ( library . config . name ) ) {
306- schemas [ library . config . name ] = schema ;
307- }
300+ function generateSchemaInfos ( libraries ) {
301+ return libraries . map ( generateSchemaInfo ) ;
302+ }
303+
304+ function generateNativeCode ( iosOutputDir , schemaInfos ) {
305+ return schemaInfos . map ( schemaInfo => {
306+ generateCode ( iosOutputDir , schemaInfo ) ;
308307 } ) ;
309- return schemas ;
308+ }
309+
310+ function needsThirdPartyComponentProvider ( schemaInfo ) {
311+ // Filter the react native core library out.
312+ // In the future, core library and third party library should
313+ // use the same way to generate/register the fabric components.
314+ return ! isReactNativeCoreLibrary ( schemaInfo . library . config . name ) ;
310315}
311316
312317function createComponentProvider ( schemas ) {
@@ -409,8 +414,12 @@ function execute(appRootDir, outputPath, baseCodegenConfigFileDir) {
409414
410415 const iosOutputDir = computeIOSOutputDir ( outputPath , appRootDir ) ;
411416
412- const schemas = generateNativeCodegenFiles ( libraries , iosOutputDir ) ;
417+ const schemaInfos = generateSchemaInfos ( libraries ) ;
418+ generateNativeCode ( iosOutputDir , schemaInfos ) ;
413419
420+ const schemas = schemaInfos
421+ . filter ( needsThirdPartyComponentProvider )
422+ . map ( schemaInfo => schemaInfo . schema ) ;
414423 createComponentProvider ( schemas ) ;
415424 cleanupEmptyFilesAndFolders ( iosOutputDir ) ;
416425 } catch ( err ) {
0 commit comments