mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
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>
This commit is contained in:
parent
ecb2ce6c5f
commit
ba2214e571
|
|
@ -231,9 +231,16 @@ function processStable(buildDir) {
|
|||
}
|
||||
|
||||
if (fs.existsSync(buildDir + '/react-native')) {
|
||||
updatePlaceholderReactVersionInCompiledArtifactsFb(
|
||||
updatePlaceholderReactVersionInCompiledArtifacts(
|
||||
buildDir + '/react-native',
|
||||
rnVersionString
|
||||
rnVersionString,
|
||||
filename => filename.endsWith('.fb.js')
|
||||
);
|
||||
|
||||
updatePlaceholderReactVersionInCompiledArtifacts(
|
||||
buildDir + '/react-native',
|
||||
ReactVersion,
|
||||
filename => !filename.endsWith('.fb.js') && filename.endsWith('.js')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -340,9 +347,16 @@ function processExperimental(buildDir, version) {
|
|||
}
|
||||
|
||||
if (fs.existsSync(buildDir + '/react-native')) {
|
||||
updatePlaceholderReactVersionInCompiledArtifactsFb(
|
||||
updatePlaceholderReactVersionInCompiledArtifacts(
|
||||
buildDir + '/react-native',
|
||||
rnVersionString
|
||||
rnVersionString,
|
||||
filename => filename.endsWith('.fb.js')
|
||||
);
|
||||
|
||||
updatePlaceholderReactVersionInCompiledArtifacts(
|
||||
buildDir + '/react-native',
|
||||
ReactVersion,
|
||||
filename => !filename.endsWith('.fb.js') && filename.endsWith('.js')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -437,38 +451,15 @@ function updatePackageVersions(
|
|||
|
||||
function updatePlaceholderReactVersionInCompiledArtifacts(
|
||||
artifactsDirectory,
|
||||
newVersion
|
||||
newVersion,
|
||||
filteringClosure
|
||||
) {
|
||||
// Update the version of React in the compiled artifacts by searching for
|
||||
// the placeholder string and replacing it with a new one.
|
||||
const artifactFilenames = String(
|
||||
spawnSync('grep', [
|
||||
'-lr',
|
||||
PLACEHOLDER_REACT_VERSION,
|
||||
'--',
|
||||
artifactsDirectory,
|
||||
]).stdout
|
||||
)
|
||||
.trim()
|
||||
.split('\n')
|
||||
.filter(filename => filename.endsWith('.js'));
|
||||
|
||||
for (const artifactFilename of artifactFilenames) {
|
||||
const originalText = fs.readFileSync(artifactFilename, 'utf8');
|
||||
const replacedText = originalText.replaceAll(
|
||||
PLACEHOLDER_REACT_VERSION,
|
||||
newVersion
|
||||
);
|
||||
fs.writeFileSync(artifactFilename, replacedText);
|
||||
if (filteringClosure == null) {
|
||||
filteringClosure = filename => filename.endsWith('.js');
|
||||
}
|
||||
}
|
||||
|
||||
function updatePlaceholderReactVersionInCompiledArtifactsFb(
|
||||
artifactsDirectory,
|
||||
newVersion
|
||||
) {
|
||||
// Update the version of React in the compiled artifacts by searching for
|
||||
// the placeholder string and replacing it with a new one.
|
||||
const artifactFilenames = String(
|
||||
spawnSync('grep', [
|
||||
'-lr',
|
||||
|
|
@ -479,7 +470,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
|
|||
)
|
||||
.trim()
|
||||
.split('\n')
|
||||
.filter(filename => filename.endsWith('.fb.js'));
|
||||
.filter(filteringClosure);
|
||||
|
||||
for (const artifactFilename of artifactFilenames) {
|
||||
const originalText = fs.readFileSync(artifactFilename, 'utf8');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user