Skip to content

Commit 9aa073e

Browse files
Thegrep01jbromatheGrep01
authored
feat: expose loadMetroConfig & updateManifest helpers (#90)
Co-authored-by: Jakub Romanczyk <[email protected]> Co-authored-by: theGrep01 <[email protected]>
1 parent 4909c8c commit 9aa073e

File tree

12 files changed

+1563
-921
lines changed

12 files changed

+1563
-921
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ apps/*/.rnef
2828

2929
# TypeScript build cache
3030
*.tsbuildinfo
31+
32+
/apps/.DS_Store

apps/example-host/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,11 +2422,11 @@ SPEC CHECKSUMS:
24222422
React-timing: a275a1c2e6112dba17f8f7dd496d439213bbea0d
24232423
React-utils: 449a6e1fd53886510e284e80bdbb1b1c6db29452
24242424
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
2425-
ReactCodegen: 329074759314ce897f564daaccf8800077479699
2425+
ReactCodegen: a1a6d7288d6a5fc86f109e46149c35d707932702
24262426
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
24272427
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
24282428
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
24292429

2430-
PODFILE CHECKSUM: d7ddd7fd39d49e0dd5d1205cb5dc83483092e5fb
2430+
PODFILE CHECKSUM: a8134080201cda3c42e54a89f48d0930861e3c58
24312431

2432-
COCOAPODS: 1.15.2
2432+
COCOAPODS: 1.15.2

apps/example-host/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const config = {
2121
module.exports = withModuleFederation(
2222
mergeConfig(getDefaultConfig(__dirname), config),
2323
{
24-
name: 'MFExampleHost',
24+
name: 'example-host',
2525
remotes: {
2626
mini: 'mini@http://localhost:8082/mf-manifest.json',
2727
nestedMini: 'nestedMini@http://localhost:8083/mf-manifest.json',

apps/example-mini/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const config = {
2020
module.exports = withModuleFederation(
2121
mergeConfig(getDefaultConfig(__dirname), config),
2222
{
23-
name: 'mini',
23+
name: 'example-mini',
2424
filename: 'mini.bundle',
2525
exposes: {
2626
'./info': './src/info.tsx',

apps/example-mini/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"pods": "(cd ios && bundle install && (bundle exec pod install || bundle exec pod update))",
1313
"build:ios": "rnef bundle-mf-remote --platform ios --dev false",
1414
"build:android": "rnef bundle-mf-remote --platform android --dev false",
15+
"build:rnc:ios": "react-native bundle-mf-remote --platform ios --dev false",
16+
"build:rnc:android": "react-native bundle-mf-remote --platform android --dev false",
1517
"serve:ios": "serve dist/ios -p 8082",
1618
"serve:android": "serve dist/android -p 8082",
1719
"adbreverse": "adb reverse tcp:8082 tcp:8082"
@@ -28,6 +30,7 @@
2830
"@module-federation/metro": "workspace:*",
2931
"@module-federation/metro-plugin-rnef": "workspace:*",
3032
"@module-federation/runtime": "^0.15.0",
33+
"@react-native-community/cli": "^19.1.0",
3134
"@react-native/babel-preset": "0.80.0",
3235
"@react-native/eslint-config": "0.80.0",
3336
"@react-native/metro-config": "0.80.0",

apps/example-nested-mini/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const config = {
2020
module.exports = withModuleFederation(
2121
mergeConfig(getDefaultConfig(__dirname), config),
2222
{
23-
name: 'nestedMini',
23+
name: 'example-nested-mini',
2424
filename: 'nestedMini.bundle',
2525
exposes: {
2626
'./nestedMiniInfo': './src/nested-mini-info.tsx',

apps/example-nested-mini/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"pods": "(cd ios && bundle install && (bundle exec pod install || bundle exec pod update))",
1313
"build:ios": "rnef bundle-mf-remote --platform ios --dev false",
1414
"build:android": "rnef bundle-mf-remote --platform android --dev false",
15+
"build:rnc:ios": "react-native bundle-mf-remote --platform ios --dev false",
16+
"build:rnc:android": "react-native bundle-mf-remote --platform android --dev false",
1517
"serve:ios": "serve dist/ios -p 8083",
1618
"serve:android": "serve dist/android -p 8083",
1719
"adbreverse": "adb reverse tcp:8083 tcp:8083"

packages/core/src/commands/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ import bundleFederatedHost, { bundleFederatedHostOptions } from './bundle-host';
22
import bundleFederatedRemote, {
33
bundleFederatedRemoteOptions,
44
} from './bundle-remote';
5+
import loadMetroConfig from './utils/load-metro-config';
56

67
export {
78
bundleFederatedHost,
89
bundleFederatedHostOptions,
910
bundleFederatedRemote,
1011
bundleFederatedRemoteOptions,
12+
loadMetroConfig,
1113
};
1214

1315
export default {
1416
bundleFederatedHost,
1517
bundleFederatedHostOptions,
1618
bundleFederatedRemote,
1719
bundleFederatedRemoteOptions,
20+
loadMetroConfig,
1821
};
1922

2023
export type { BundleFederatedHostArgs } from './bundle-host/types';

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { withModuleFederation } from './plugin';
2+
export { updateManifest } from './plugin/manifest';

packages/core/src/plugin/manifest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ export function createManifest(
1414
return manifestPath;
1515
}
1616

17+
export const updateManifest = (
18+
manifestPath: string,
19+
options: ModuleFederationConfigNormalized
20+
): string => {
21+
const manifest = generateManifest(options);
22+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, undefined, 2));
23+
return manifestPath;
24+
};
25+
1726
function generateManifest(config: ModuleFederationConfigNormalized): Manifest {
1827
return {
1928
id: config.name,

0 commit comments

Comments
 (0)