Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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 @@ -33,6 +33,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
37 changes: 23 additions & 14 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,19 +122,26 @@ jobs:
echo "${HOME}/.maestro/bin" >> "$GITHUB_PATH"
shell: bash

- name: Configure RNEF cache auth
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt

- 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"
ROCK_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rock/cache"
mkdir -p "$ROCK_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$ROCK_PATH/project.json"

- name: Build Metro Android app (RNEF action)
uses: callstackincubator/android@v1
- name: Build Metro Android app (Rock action)
uses: callstackincubator/android@599c4a7f0f78cbb1b3fdcd3aea220ee9fbb7e973 # v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-bot: false
variant: 'Release'
setup-java: false
working-directory: './apps/metro-${{ env.METRO_APP_NAME }}'

- name: Run Metro Android E2E tests
Expand All @@ -152,7 +160,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 +175,7 @@ jobs:
runs-on: macos-latest
timeout-minutes: 60
env:
NO_COLOR: 1
RUBY_VERSION: 3.4.9
MAESTRO_VERSION: 1.39.13
MAESTRO_DRIVER_STARTUP_TIMEOUT: 600000
Expand Down Expand Up @@ -221,15 +230,15 @@ 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"
ROCK_PATH="apps/metro-${{ env.METRO_APP_NAME }}/.rock/cache"
mkdir -p "$ROCK_PATH"
echo "{\"githubToken\": \"${{ secrets.GITHUB_TOKEN }}\"}" > "$ROCK_PATH/project.json"

- name: Build Metro iOS app (RNEF action)
uses: callstackincubator/ios@v1
- name: Build Metro iOS app (Rock action)
uses: callstackincubator/ios@a5f0126bfe03817e2951b29111d75fbd352de0a7 # v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-bot: false
Expand All @@ -241,7 +250,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
4 changes: 2 additions & 2 deletions apps/metro-example-host/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GEM
atomos (0.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.1.1)
bigdecimal (4.1.2)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -77,7 +77,7 @@ GEM
mutex_m
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.19.3)
json (2.19.4)
logger (1.7.0)
minitest (5.27.0)
molinillo (0.8.0)
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
2 changes: 1 addition & 1 deletion apps/metro-example-host/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,6 @@ SPEC CHECKSUMS:
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb

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
4 changes: 2 additions & 2 deletions apps/metro-example-mini/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ GEM
atomos (0.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.1.1)
bigdecimal (4.1.2)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -77,7 +77,7 @@ GEM
mutex_m
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.19.3)
json (2.19.4)
logger (1.7.0)
minitest (5.27.0)
molinillo (0.8.0)
Expand Down
2 changes: 1 addition & 1 deletion apps/metro-example-mini/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-mini/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 = 'mini'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
2 changes: 1 addition & 1 deletion apps/metro-example-mini/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if linkage != nil
end

target 'mini' 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
2 changes: 1 addition & 1 deletion apps/metro-example-mini/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,6 @@ SPEC CHECKSUMS:
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb

PODFILE CHECKSUM: a8134080201cda3c42e54a89f48d0930861e3c58
PODFILE CHECKSUM: 0bef6bcbae4cfd995527daffb014d1e226ab15f8

COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion apps/metro-example-mini/ios/mini.xcodeproj/project.pbxproj
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
21 changes: 11 additions & 10 deletions apps/metro-example-mini/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"version": "0.0.1",
"private": true,
"scripts": {
"android": "rnef run:android",
"ios": "rnef run:ios",
"android": "rock run:android",
"ios": "rock run:ios",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint .",
"dev": "nodemon --config ../../nodemon.json --exec NODE_OPTIONS='--conditions=dev' pnpm start",
"start": "rnef start --port 8082",
"start": "rock start --port 8082",
"test": "jest",
"pods": "(cd ios && bundle install && (bundle exec pod install || bundle exec pod update))",
"build:ios": "rnef bundle-mf-remote --platform ios --dev false",
"build:android": "rnef bundle-mf-remote --platform android --dev false",
"build:ios": "rock bundle-mf-remote --platform ios --dev false",
"build:android": "rock bundle-mf-remote --platform android --dev false",
"build:rnc:ios": "react-native bundle-mf-remote --platform ios --dev false",
"build:rnc:android": "react-native bundle-mf-remote --platform android --dev false",
"serve:ios": "serve dist/ios -p 8082",
Expand All @@ -28,17 +28,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-community/cli": "^19.1.0",
"@react-native/babel-preset": "0.80.0",
"@react-native/eslint-config": "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
Loading
Loading