Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
5 changes: 5 additions & 0 deletions .changeset/add-metro-plugin-rock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/metro-plugin-rock': minor
---

feat(metro): add metro-plugin-rock for Rock integration
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@module-federation/treeshake-frontend",
"@module-federation/metro",
"@module-federation/metro-plugin-rnef",
"@module-federation/metro-plugin-rock",
"@module-federation/metro-plugin-rnc-cli"
]
],
Expand Down
5 changes: 5 additions & 0 deletions .changeset/deprecate-metro-plugin-rnef.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/metro-plugin-rnef': patch
---

chore(metro): deprecate metro-plugin-rnef in favor of metro-plugin-rock
38 changes: 22 additions & 16 deletions .github/workflows/e2e-metro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
NO_COLOR: 1
ANDROID_EMULATOR_API_LEVEL: 28
ANDROID_EMULATOR_TARGET: default
ANDROID_EMULATOR_ARCH: x86_64
Expand Down Expand Up @@ -121,15 +122,17 @@ jobs:
echo "${HOME}/.maestro/bin" >> "$GITHUB_PATH"
shell: bash

- name: Configure RNEF cache auth
- name: Configure Rock cache auth
shell: bash
run: |
RNEF_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rnef/cache"
mkdir -p "$RNEF_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$RNEF_PATH/project.json"

- name: Build Metro Android app (RNEF action)
uses: callstackincubator/android@v1
ROCK_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rock/cache"
mkdir -p "$ROCK_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$ROCK_PATH/project.json"

# TODO: working-directory not propagated to all steps in upstream action
# https://github.com/callstackincubator/android/pull/25
- name: Build Metro Android app (Rock action)
uses: callstackincubator/android@v3
Comment thread
jbroma marked this conversation as resolved.
Outdated
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-bot: false
Expand All @@ -152,7 +155,7 @@ jobs:
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
node tools/scripts/run-metro-e2e.mjs --platform=android --appName=${{ env.METRO_APP_NAME }} --skip-rnef-cache-auth
node tools/scripts/run-metro-e2e.mjs --platform=android --appName=${{ env.METRO_APP_NAME }} --skip-rock-cache-auth

- name: Upload Android Maestro logs on failure
if: failure()
Expand All @@ -167,6 +170,7 @@ jobs:
runs-on: macos-latest
timeout-minutes: 60
env:
NO_COLOR: 1
RUBY_VERSION: 2.7.6
MAESTRO_VERSION: 1.39.13
MAESTRO_DRIVER_STARTUP_TIMEOUT: 600000
Expand Down Expand Up @@ -221,15 +225,17 @@ jobs:
echo "${HOME}/.maestro/bin" >> "$GITHUB_PATH"
shell: bash

- name: Configure RNEF cache auth
- name: Configure Rock cache auth
shell: bash
run: |
RNEF_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rnef/cache"
mkdir -p "$RNEF_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$RNEF_PATH/project.json"

- name: Build Metro iOS app (RNEF action)
uses: callstackincubator/ios@v1
ROCK_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rock/cache"
mkdir -p "$ROCK_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$ROCK_PATH/project.json"

# TODO: working-directory not propagated to all steps in upstream action
# https://github.com/callstackincubator/ios/pull/27
- name: Build Metro iOS app (Rock action)
uses: callstackincubator/ios@v3
Comment thread
jbroma marked this conversation as resolved.
Outdated
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-bot: false
Expand All @@ -241,7 +247,7 @@ jobs:
- name: Run Metro iOS E2E tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node tools/scripts/run-metro-e2e.mjs --platform=ios --appName=${{ env.METRO_APP_NAME }} --skip-rnef-cache-auth
run: node tools/scripts/run-metro-e2e.mjs --platform=ios --appName=${{ env.METRO_APP_NAME }} --skip-rock-cache-auth
shell: bash

- name: Upload iOS Maestro logs on failure
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ pnpm run build:packages
- Metro tests:

```bash
pnpm exec turbo run test --filter=@module-federation/metro --filter=@module-federation/metro-plugin-rnef --filter=@module-federation/metro-plugin-rnc-cli
pnpm exec turbo run test --filter=@module-federation/metro --filter=@module-federation/metro-plugin-rnef --filter=@module-federation/metro-plugin-rock --filter=@module-federation/metro-plugin-rnc-cli
```

- Metro lint:

```bash
pnpm exec turbo run lint --filter=@module-federation/metro --filter=@module-federation/metro-plugin-rnef --filter=@module-federation/metro-plugin-rnc-cli
pnpm exec turbo run lint --filter=@module-federation/metro --filter=@module-federation/metro-plugin-rnef --filter=@module-federation/metro-plugin-rock --filter=@module-federation/metro-plugin-rnc-cli
```

### E2E Parity via Local CI Runner
Expand Down
3 changes: 2 additions & 1 deletion apps/metro-example-host/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ yarn-error.log
# build artifacts
dist/

# RNEF
# Rock
.rock
.rnef
30 changes: 16 additions & 14 deletions apps/metro-example-host/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.9)
activesupport (7.2.3.1)
activesupport (7.1.6)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1, < 6)
minitest (>= 5.1)
mutex_m
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.8)
tzinfo (~> 2.0)
addressable (2.9.0)
public_suffix (>= 2.0.2, < 8.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.0.1)
bigdecimal (4.1.1)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -63,22 +64,23 @@ GEM
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.3)
connection_pool (3.0.2)
connection_pool (2.5.5)
drb (2.2.3)
escape (0.0.4)
ethon (0.15.0)
ethon (0.18.0)
ffi (>= 1.15.0)
ffi (1.17.3)
logger
ffi (1.17.4)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.9.0)
mutex_m
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.18.1)
json (2.19.3)
logger (1.7.0)
minitest (5.27.0)
minitest (5.26.1)
molinillo (0.8.0)
mutex_m (0.3.0)
nanaimo (0.3.0)
Expand All @@ -87,9 +89,9 @@ GEM
public_suffix (4.0.7)
rexml (3.4.4)
ruby-macho (2.5.1)
securerandom (0.4.1)
typhoeus (1.5.0)
ethon (>= 0.9.0, < 0.16.0)
securerandom (0.3.2)
typhoeus (1.6.0)
ethon (>= 0.18.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.25.1)
Expand Down
2 changes: 1 addition & 1 deletion apps/metro-example-host/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ react {
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
codegenDir = file("../../../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
cliFile = file("../../node_modules/@rnef/cli/dist/src/bin.js")
cliFile = file("../../node_modules/rock/dist/src/bin.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down
2 changes: 1 addition & 1 deletion apps/metro-example-host/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand(['npx', 'rnef', 'config', '-p', 'android']) }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand(['npx', 'rock', 'config', '-p', 'android']) }
rootProject.name = "MFExampleHost"
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nif [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env.local\"\nfi\nexport BUNDLE_COMMAND=\"bundle-mf-host\"\nexport CONFIG_CMD=\"dummy-workaround-value\"\nexport CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@rnef/cli/package.json')) + '/dist/src/bin.js'\")\"\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
shellScript = "set -e\nif [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env.local\"\nfi\nexport BUNDLE_COMMAND=\"bundle-mf-host\"\nexport CONFIG_CMD=\"dummy-workaround-value\"\nexport CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('rock/package.json')) + '/dist/src/bin.js'\")\"\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
};
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion apps/metro-example-host/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if linkage != nil
end

target 'MFExampleHost' do
config = use_native_modules!(['npx', 'rnef', 'config', '-p', 'ios'])
config = use_native_modules!(['npx', 'rock', 'config', '-p', 'ios'])

use_react_native!(
:path => config[:reactNativePath],
Expand Down
4 changes: 2 additions & 2 deletions apps/metro-example-host/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2422,11 +2422,11 @@ SPEC CHECKSUMS:
React-timing: a275a1c2e6112dba17f8f7dd496d439213bbea0d
React-utils: 449a6e1fd53886510e284e80bdbb1b1c6db29452
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
ReactCodegen: 2539080349c02b1edbf525d0a392df99f984f34b
ReactCodegen: 7b0bacf7557bfaf82e2ea8a24903b7e0e15d4840
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e

PODFILE CHECKSUM: d7ddd7fd39d49e0dd5d1205cb5dc83483092e5fb
PODFILE CHECKSUM: f7c15fdb9b5b2df0ae134c62754cc4c92ec20ff0

COCOAPODS: 1.15.2
21 changes: 11 additions & 10 deletions apps/metro-example-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "0.0.1",
"private": true,
"scripts": {
"android": "rnef run:android",
"ios": "rnef run:ios",
"android:release": "rnef run:android --variant 'Release'",
"ios:release": "rnef run:ios --configuration 'Release' --destination=\"simulator\"",
"android": "rock run:android",
"ios": "rock run:ios",
"android:release": "rock run:android --variant 'Release'",
"ios:release": "rock run:ios --configuration 'Release' --destination=\"simulator\"",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint .",
"dev": "nodemon --config ../../nodemon.json --exec NODE_OPTIONS='--conditions=dev' pnpm start",
"start": "rnef start --reset-cache --client-logs",
"start": "rock start --reset-cache --client-logs",
"pods": "(cd ios && bundle install && (bundle exec pod install || bundle exec pod update))",
"test": "jest",
"adbreverse": "pnpm --filter example-mini --filter example-nested-mini run adbreverse",
Expand All @@ -30,17 +30,18 @@
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@module-federation/metro": "workspace:*",
"@module-federation/metro-plugin-rnef": "workspace:*",
"@module-federation/metro-plugin-rock": "workspace:*",
"@module-federation/runtime": "workspace:*",
"@react-native/babel-preset": "0.80.0",
"@react-native/eslint-config": "0.80.0",
"@react-native/gradle-plugin": "0.80.0",
"@react-native/metro-config": "0.80.0",
"@react-native/typescript-config": "0.80.0",
"@rnef/cli": "^0.7.25",
"@rnef/platform-android": "^0.7.25",
"@rnef/platform-ios": "^0.7.25",
"@rnef/plugin-metro": "^0.7.25",
"rock": "^0.13.0",
"@rock-js/platform-android": "^0.13.0",
"@rock-js/platform-ios": "^0.13.0",
"@rock-js/plugin-metro": "^0.13.0",
"@rock-js/provider-github": "^0.13.0",
"@types/jest": "^29.5.13",
"@types/lodash": "^4",
"@types/react": "^19.1.0",
Expand Down
16 changes: 0 additions & 16 deletions apps/metro-example-host/rnef.config.mjs

This file was deleted.

17 changes: 17 additions & 0 deletions apps/metro-example-host/rock.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check
import {pluginMetroModuleFederation} from '@module-federation/metro-plugin-rock';
import {platformAndroid} from '@rock-js/platform-android';
import {platformIOS} from '@rock-js/platform-ios';
import {pluginMetro} from '@rock-js/plugin-metro';
import {providerGitHub} from '@rock-js/provider-github';

/** @type {import('rock').Config} */
export default {
bundler: pluginMetro(),
platforms: {
ios: platformIOS(),
android: platformAndroid(),
},
remoteCacheProvider: providerGitHub(),
plugins: [pluginMetroModuleFederation()],
};
3 changes: 2 additions & 1 deletion apps/metro-example-mini/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ yarn-error.log
# build artifacts
dist/

# RNEF
# Rock
.rock
.rnef
Loading
Loading