Skip to content

Automate the download of ReactNativeDependencies #51505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-native/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ let reactRuntimeApple = RNTarget(
name: .reactRuntimeApple,
path: "ReactCommon/react/runtime/platform/ios",
searchPaths: ["ReactCommon", RuntimeExecutorPath, CallInvokerPath, ReactFBReactNativeSpecPath, FBLazyVectorPath],
excludedPaths: ["ReactCommon/RCTJscInstance.mm"],
excludedPaths: ["ReactCommon/RCTJscInstance.mm", "ReactCommon/metainternal"],
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .reactCxxReact, .rctDeprecation, .yoga, .reactRuntime, .reactRCTFabric, .reactCoreModules, .reactTurboModuleCore, .hermesPrebuilt, .reactUtils]
)

Expand Down
5 changes: 5 additions & 0 deletions packages/react-native/scripts/ios-prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/

const {prepareHermesArtifactsAsync} = require('./ios-prebuild/hermes');
const {
prepareReactNativeDependenciesArtifactsAsync,
} = require('./ios-prebuild/reactNativeDependencies');
const {
createFolderIfNotExists,
prebuildLog,
Expand Down Expand Up @@ -111,6 +114,8 @@ async function main() {
// HERMES ARTIFACTS
await prepareHermesArtifactsAsync(currentVersion, 'debug');

await prepareReactNativeDependenciesArtifactsAsync(currentVersion, 'debug');

// CODEGEN
const codegenPath = path.join(root, '.build/codegen');
createFolderIfNotExists(codegenPath);
Expand Down
25 changes: 24 additions & 1 deletion packages/react-native/scripts/ios-prebuild/hermes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ async function prepareHermesArtifactsAsync(
// Only check if the artifacts folder exists if we are not using a local tarball
if (!localPath) {
// Resolve the version from the environment variable or use the default version
const resolvedVersion = process.env.HERMES_VERSION ?? version;
let resolvedVersion = process.env.HERMES_VERSION ?? version;

if (resolvedVersion === 'nightly') {
hermesLog('Using latest nightly tarball');
const hermesVersion = await getNightlyVersionFromNPM();
resolvedVersion = hermesVersion;
}

// Check if the Hermes artifacts are already downloaded
if (
Expand Down Expand Up @@ -89,6 +95,23 @@ async function prepareHermesArtifactsAsync(
return artifactsPath;
}

async function getNightlyVersionFromNPM() /*: Promise<string> */ {
const npmResponse /*: Response */ = await fetch(
'https://registry.npmjs.org/react-native/nightly',
);

if (!npmResponse.ok) {
throw new Error(
`Couldn't get an answer from NPM: ${npmResponse.status} ${npmResponse.statusText}`,
);
}

const json = await npmResponse.json();
const latestNightly = json.version;
hermesLog(`Using version ${latestNightly}`);
return latestNightly;
}

/*::
type HermesEngineSourceType =
| 'local_prebuilt_tarball'
Expand Down
Loading
Loading