diff --git a/.circleci/configurations/commands.yml b/.circleci/configurations/commands.yml index 1ffde738995d49..bc190b9a5eeac9 100644 --- a/.circleci/configurations/commands.yml +++ b/.circleci/configurations/commands.yml @@ -31,7 +31,7 @@ commands: - restore_cache: key: *rbenv_cache_key - run: - name: Bundle Install + name: Install the proper Ruby and run Bundle install command: | # Check if rbenv is installed. CircleCI is migrating to rbenv so we may not need to always install it. @@ -62,8 +62,10 @@ commands: # Set ruby dependencies rbenv global << parameters.ruby_version >> if [[ $(echo << parameters.ruby_version >> | awk -F'.' '{print $1}') == "2" ]]; then + rbenv rehash gem install bundler -v 2.4.22 else + rbenv rehash gem install bundler fi bundle check || bundle install --path vendor/bundle --clean diff --git a/.circleci/configurations/executors.yml b/.circleci/configurations/executors.yml index 3884b21abfdfc1..eb1fecfaaefd2f 100644 --- a/.circleci/configurations/executors.yml +++ b/.circleci/configurations/executors.yml @@ -33,6 +33,6 @@ executors: <<: *defaults macos: xcode: *xcode_version - resource_class: macos.x86.medium.gen2 + resource_class: macos.m1.medium.gen1 environment: - RCT_BUILD_HERMES_FROM_SOURCE: true diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml index 7b4559d18fae2c..60e9e827d4318e 100644 --- a/.circleci/configurations/jobs.yml +++ b/.circleci/configurations/jobs.yml @@ -116,7 +116,7 @@ jobs: executor: reactnativeios parameters: ruby_version: - default: "2.7.7" + default: "2.7.8" description: The version of ruby that must be used type: string steps: diff --git a/.circleci/configurations/test_workflows/testAll.yml b/.circleci/configurations/test_workflows/testAll.yml index 145dcbd71ff213..c597ada8ec328a 100644 --- a/.circleci/configurations/test_workflows/testAll.yml +++ b/.circleci/configurations/test_workflows/testAll.yml @@ -56,8 +56,8 @@ - test_ios_template: requires: - build_npm_package - name: "Test Template with Ruby 3.2.0" - ruby_version: "3.2.0" + name: "Test Template with Ruby 3.2.2" + ruby_version: "3.2.2" architecture: "NewArch" flavor: "Debug" - test_ios_template: @@ -149,8 +149,8 @@ - test_ios_rntester: requires: - build_hermes_macos - name: "Test RNTester with Ruby 3.2.0" - ruby_version: "3.2.0" + name: "Test RNTester with Ruby 3.2.2" + ruby_version: "3.2.2" architecture: "NewArch" - test_ios_rntester: requires: diff --git a/.circleci/configurations/test_workflows/testE2E.yml b/.circleci/configurations/test_workflows/testE2E.yml index b161180ee5a5b4..511e6dba41b4e3 100644 --- a/.circleci/configurations/test_workflows/testE2E.yml +++ b/.circleci/configurations/test_workflows/testE2E.yml @@ -5,6 +5,6 @@ - equal: [ false, << pipeline.parameters.run_nightly_workflow >> ] jobs: - test_e2e_ios: - ruby_version: "2.7.7" + ruby_version: "2.7.9" # This is not stable # - test_e2e_android diff --git a/.circleci/configurations/test_workflows/testIOS.yml b/.circleci/configurations/test_workflows/testIOS.yml index 484ef5a8f2ea27..e3e8ab71c5233b 100644 --- a/.circleci/configurations/test_workflows/testIOS.yml +++ b/.circleci/configurations/test_workflows/testIOS.yml @@ -43,12 +43,12 @@ - build_hermes_macos - build_hermesc_windows - test_e2e_ios: - ruby_version: "2.7.7" + ruby_version: "2.7.8" - test_ios_template: requires: - build_npm_package - name: "Test Template with Ruby 3.2.0" - ruby_version: "3.2.0" + name: "Test Template with Ruby 3.2.2" + ruby_version: "3.2.2" architecture: "NewArch" flavor: "Debug" - test_ios_template: @@ -140,8 +140,8 @@ - test_ios_rntester: requires: - build_hermes_macos - name: "Test RNTester with Ruby 3.2.0" - ruby_version: "3.2.0" + name: "Test RNTester with Ruby 3.2.2" + ruby_version: "3.2.2" architecture: "NewArch" - test_ios_rntester: requires: diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml index 6eed67c24e92dc..d13d709f8ad83a 100644 --- a/.circleci/configurations/top_level.yml +++ b/.circleci/configurations/top_level.yml @@ -71,32 +71,32 @@ references: cache_keys: checkout_cache_key: &checkout_cache_key v1-checkout - gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }} + gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }} gradle_cache_key: &gradle_cache_key v3-gradle-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }} yarn_cache_key: &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }} - rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ checksum "/tmp/required_ruby" }} + rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }} hermes_workspace_cache_key: &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }} hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} # Hermes iOS - hermesc_apple_cache_key: &hermesc_apple_cache_key v2-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} - hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v2-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} - hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} - hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} - hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v1-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} - hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v1-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} - hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v1-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} - hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v1-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} + hermesc_apple_cache_key: &hermesc_apple_cache_key v3-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} + hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v3-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} + hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v5-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} + hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v4-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }} + hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v2-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} + hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v2-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} + hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v2-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} + hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v2-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} # Cocoapods - RNTester - pods_cache_key: &pods_cache_key v10-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} - cocoapods_cache_key: &cocoapods_cache_key v9-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }} - rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v7-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }} + pods_cache_key: &pods_cache_key v11-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} + cocoapods_cache_key: &cocoapods_cache_key v10-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }} + rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v8-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }} # Cocoapods - Template - template_cocoapods_cache_key: &template_cocoapods_cache_key v4-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }} - template_podfile_lock_cache_key: &template_podfile_lock_cache_key v4-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }} + template_cocoapods_cache_key: &template_cocoapods_cache_key v5-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }} + template_podfile_lock_cache_key: &template_podfile_lock_cache_key v5-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }} # Windows windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} diff --git a/packages/metro-config/dist/index.d.ts b/packages/metro-config/dist/index.d.ts new file mode 100644 index 00000000000000..6b8415fcee53ce --- /dev/null +++ b/packages/metro-config/dist/index.d.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * + * @format + * @oncall react_native + */ + +import type { ConfigT } from "metro-config"; +export { mergeConfig } from "metro-config"; +/** + * Get the base Metro configuration for a React Native project. + */ +export declare function getDefaultConfig(projectRoot: string): ConfigT; diff --git a/packages/metro-config/dist/index.js b/packages/metro-config/dist/index.js new file mode 100644 index 00000000000000..111ef6c6cf3667 --- /dev/null +++ b/packages/metro-config/dist/index.js @@ -0,0 +1,113 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true, +}); +exports.getDefaultConfig = getDefaultConfig; +Object.defineProperty(exports, "mergeConfig", { + enumerable: true, + get: function () { + return _metroConfig.mergeConfig; + }, +}); +var _metroConfig = require("metro-config"); +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * + * @format + * @oncall react_native + */ + +const INTERNAL_CALLSITES_REGEX = new RegExp( + [ + "/Libraries/BatchedBridge/MessageQueue\\.js$", + "/Libraries/Core/.+\\.js$", + "/Libraries/LogBox/.+\\.js$", + "/Libraries/Network/.+\\.js$", + "/Libraries/Pressability/.+\\.js$", + "/Libraries/Renderer/implementations/.+\\.js$", + "/Libraries/Utilities/.+\\.js$", + "/Libraries/vendor/.+\\.js$", + "/Libraries/WebSocket/.+\\.js$", + "/Libraries/YellowBox/.+\\.js$", + "/metro-runtime/.+\\.js$", + "/node_modules/@babel/runtime/.+\\.js$", + "/node_modules/@react-native/js-polyfills/.+\\.js$", + "/node_modules/event-target-shim/.+\\.js$", + "/node_modules/invariant/.+\\.js$", + "/node_modules/react-devtools-core/.+\\.js$", + "/node_modules/react-native/index.js$", + "/node_modules/react-refresh/.+\\.js$", + "/node_modules/scheduler/.+\\.js$", + "^\\[native code\\]$", + ] + // Make patterns work with both Windows and POSIX paths. + .map((pathPattern) => pathPattern.replaceAll("/", "[/\\\\]")) + .join("|") +); +/** + * Get the base Metro configuration for a React Native project. + */ +function getDefaultConfig(projectRoot) { + const config = { + resolver: { + resolverMainFields: ["react-native", "browser", "main"], + platforms: ["android", "ios"], + unstable_conditionNames: ["require", "import", "react-native"], + }, + serializer: { + // Note: This option is overridden in cli-plugin-metro (getOverrideConfig) + getModulesRunBeforeMainModule: () => [ + require.resolve("react-native/Libraries/Core/InitializeCore"), + ], + getPolyfills: () => require("@react-native/js-polyfills")(), + isThirdPartyModule({ path: modulePath }) { + return ( + INTERNAL_CALLSITES_REGEX.test(modulePath) || + /(?:^|[/\\])node_modules[/\\]/.test(modulePath) + ); + }, + }, + server: { + port: Number(process.env.RCT_METRO_PORT) || 8081, + }, + symbolicator: { + customizeFrame: (frame) => { + const collapse = Boolean( + frame.file != null && INTERNAL_CALLSITES_REGEX.test(frame.file) + ); + return { + collapse, + }; + }, + }, + transformer: { + allowOptionalDependencies: true, + assetRegistryPath: "react-native/Libraries/Image/AssetRegistry", + asyncRequireModulePath: require.resolve( + "metro-runtime/src/modules/asyncRequire" + ), + babelTransformerPath: require.resolve( + "@react-native/metro-babel-transformer" + ), + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: true, + }, + }), + }, + watchFolders: [], + }; + + // Set global hook so that the CLI can detect when this config has been loaded + global.__REACT_NATIVE_METRO_CONFIG_LOADED = true; + return (0, _metroConfig.mergeConfig)( + _metroConfig.getDefaultConfig.getDefaultValues(projectRoot), + config + ); +} diff --git a/packages/metro-config/dist/index.js.flow b/packages/metro-config/dist/index.js.flow new file mode 100644 index 00000000000000..cdc41d2b0bac1b --- /dev/null +++ b/packages/metro-config/dist/index.js.flow @@ -0,0 +1,19 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + * @oncall react_native + */ + +import type { ConfigT } from "metro-config"; + +export { mergeConfig } from "metro-config"; + +/** + * Get the base Metro configuration for a React Native project. + */ +declare export function getDefaultConfig(projectRoot: string): ConfigT;