@samitouri / QOS-React / commits / ba2214e571

Apply build script changes for RN to main (#34640)

This was merged into the 19.1.1 patch release branch in https://github.com/facebook/react/pull/33972 but we never upstreamed it to main. This should merge to main to make it easier to sync versions to RN after future releases. --------- Co-authored-by: Riccardo Cipolleschi <cipolleschi@meta.com>

Jack Pope committed Sep 29, 2025 at 20:40 UTC ba2214e571268a2e826f7ccec6a32e59d7a911d0
1 file changed +23 -32
scripts/rollup/build-all-release-channels.js
+23 -32
@@ -231,9 +231,16 @@ function processStable(buildDir) {
231 }
232
233 if (fs.existsSync(buildDir + '/react-native')) {
234 - updatePlaceholderReactVersionInCompiledArtifactsFb(
234 + updatePlaceholderReactVersionInCompiledArtifacts(
235 buildDir + '/react-native',
236 - rnVersionString
236 + rnVersionString,
237 + filename => filename.endsWith('.fb.js')
238 + );
239 +
240 + updatePlaceholderReactVersionInCompiledArtifacts(
241 + buildDir + '/react-native',
242 + ReactVersion,
243 + filename => !filename.endsWith('.fb.js') && filename.endsWith('.js')
244 );
245 }
246
@@ -340,9 +347,16 @@ function processExperimental(buildDir, version) {
347 }
348
349 if (fs.existsSync(buildDir + '/react-native')) {
343 - updatePlaceholderReactVersionInCompiledArtifactsFb(
350 + updatePlaceholderReactVersionInCompiledArtifacts(
351 buildDir + '/react-native',
345 - rnVersionString
352 + rnVersionString,
353 + filename => filename.endsWith('.fb.js')
354 + );
355 +
356 + updatePlaceholderReactVersionInCompiledArtifacts(
357 + buildDir + '/react-native',
358 + ReactVersion,
359 + filename => !filename.endsWith('.fb.js') && filename.endsWith('.js')
360 );
361 }
362
@@ -437,38 +451,15 @@ function updatePackageVersions(
451
452 function updatePlaceholderReactVersionInCompiledArtifacts(
453 artifactsDirectory,
440 - newVersion
454 + newVersion,
455 + filteringClosure
456 ) {
457 // Update the version of React in the compiled artifacts by searching for
458 // the placeholder string and replacing it with a new one.
444 - const artifactFilenames = String(
445 - spawnSync('grep', [
446 - '-lr',
447 - PLACEHOLDER_REACT_VERSION,
448 - '--',
449 - artifactsDirectory,
450 - ]).stdout
451 - )
452 - .trim()
453 - .split('\n')
454 - .filter(filename => filename.endsWith('.js'));
455 -
456 - for (const artifactFilename of artifactFilenames) {
457 - const originalText = fs.readFileSync(artifactFilename, 'utf8');
458 - const replacedText = originalText.replaceAll(
459 - PLACEHOLDER_REACT_VERSION,
460 - newVersion
461 - );
462 - fs.writeFileSync(artifactFilename, replacedText);
459 + if (filteringClosure == null) {
460 + filteringClosure = filename => filename.endsWith('.js');
461 }
464 -}
462
466 -function updatePlaceholderReactVersionInCompiledArtifactsFb(
467 - artifactsDirectory,
468 - newVersion
469 -) {
470 - // Update the version of React in the compiled artifacts by searching for
471 - // the placeholder string and replacing it with a new one.
463 const artifactFilenames = String(
464 spawnSync('grep', [
465 '-lr',
@@ -479,7 +470,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
470 )
471 .trim()
472 .split('\n')
482 - .filter(filename => filename.endsWith('.fb.js'));
473 + .filter(filteringClosure);
474
475 for (const artifactFilename of artifactFilenames) {
476 const originalText = fs.readFileSync(artifactFilename, 'utf8');