Skip to content

Commit 97047a8

Browse files
authored
Revert "Build: use content hash for facebook-react-native build" (#27584)
Reverts #27577. We also sync React Native OSS bundles which means this didn't work as hoped unless we abandon the commit hash in OSS which seems useful.
1 parent a998552 commit 97047a8

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

scripts/rollup/build-all-release-channels.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const fse = require('fs-extra');
88
const {spawnSync} = require('child_process');
99
const path = require('path');
1010
const tmp = require('tmp');
11-
const glob = require('glob');
1211

1312
const {
1413
ReactVersion,
@@ -236,28 +235,19 @@ function processExperimental(buildDir, version) {
236235
);
237236
}
238237

239-
const facebookWwwDir = path.join(buildDir, 'facebook-www');
240-
if (fs.existsSync(facebookWwwDir)) {
241-
for (const fileName of fs.readdirSync(facebookWwwDir).sort()) {
242-
const filePath = path.join(facebookWwwDir, fileName);
238+
if (fs.existsSync(buildDir + '/facebook-www')) {
239+
const hash = crypto.createHash('sha1');
240+
for (const fileName of fs.readdirSync(buildDir + '/facebook-www').sort()) {
241+
const filePath = buildDir + '/facebook-www/' + fileName;
243242
const stats = fs.statSync(filePath);
244243
if (!stats.isDirectory()) {
244+
hash.update(fs.readFileSync(filePath));
245245
fs.renameSync(filePath, filePath.replace('.js', '.modern.js'));
246246
}
247247
}
248-
const contentHash = hashJSFilesInDirectory(facebookWwwDir);
249248
updatePlaceholderReactVersionInCompiledArtifacts(
250-
facebookWwwDir,
251-
ReactVersion + '-www-modern-' + contentHash
252-
);
253-
}
254-
255-
const facebookReactNativeDir = path.join(buildDir, 'facebook-react-native');
256-
if (fs.existsSync(facebookReactNativeDir)) {
257-
const contentHash = hashJSFilesInDirectory(facebookReactNativeDir);
258-
updatePlaceholderReactVersionInCompiledArtifacts(
259-
facebookReactNativeDir,
260-
ReactVersion + '-react-native-' + contentHash
249+
buildDir + '/facebook-www',
250+
ReactVersion + '-www-modern-' + hash.digest('hex').slice(0, 8)
261251
);
262252
}
263253

@@ -356,14 +346,6 @@ function updatePackageVersions(
356346
}
357347
}
358348

359-
function hashJSFilesInDirectory(directory) {
360-
const hash = crypto.createHash('sha1');
361-
for (const filePath of glob.sync(directory + '/**/*.js').sort()) {
362-
hash.update(fs.readFileSync(filePath));
363-
}
364-
return hash.digest('hex').slice(0, 8);
365-
}
366-
367349
function updatePlaceholderReactVersionInCompiledArtifacts(
368350
artifactsDirectory,
369351
newVersion

0 commit comments

Comments
 (0)