@module-federation/metro-plugin-rnef 0.0.0-next-20250827124348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Callstack and Zephyr Cloud
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @module-federation/metro-plugin-rnef
2
+
3
+ Module Federation for React Native Enterprise Framework (RNEF) using Metro bundler. This plugin integrates the `@module-federation/metro` package with RNEF, providing commands to bundle Module Federation host and remotes.
4
+
5
+ ## Installation
6
+
7
+ 1. First, ensure you have [RNEF](https://github.com/callstack/rnef) set up in your project.
8
+
9
+ 2. Install the plugin:
10
+
11
+ ```bash
12
+ npm install --save-dev @module-federation/metro-plugin-rnef
13
+ ```
14
+
15
+ 3. Add the plugin to your RNEF configuration (typically in `rnef.config.mjs`):
16
+
17
+ ```typescript
18
+ import { pluginMetro } from "@rnef/plugin-metro";
19
+ import moduleFederation from "@module-federation/metro-plugin-rnef";
20
+
21
+ /** @type {import('@rnef/config').Config} */
22
+ export default {
23
+ bundler: pluginMetro(),
24
+ plugins: [moduleFederation()],
25
+ };
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Bundle a Module Federation Host
31
+
32
+ ```bash
33
+ # Bundle for iOS
34
+ rnef bundle-mf-host --entry-file index.js --platform ios
35
+
36
+ # Bundle for Android
37
+ rnef bundle-mf-host --entry-file index.js --platform android
38
+ ```
39
+
40
+ ### Bundle a Module Federation Remote
41
+
42
+ ```bash
43
+ # Bundle for iOS
44
+ rnef bundle-mf-remote --platform ios
45
+
46
+ # Bundle for Android
47
+ rnef bundle-mf-remote --platform android
48
+ ```
49
+
50
+ ### Available Options
51
+
52
+ #### `bundle-mf-host`
53
+
54
+ - `--entry-file <path>`: Path to the root JavaScript entry file
55
+ - `--platform <string>`: Target platform (default: "ios") - Either "ios" or "android"
56
+ - `--transformer <string>`: Specify a custom transformer
57
+ - `--dev [boolean]`: If false, warnings are disabled and the bundle is minified (default: true)
58
+ - `--minify [boolean]`: Allows overriding whether bundle is minified. This defaults to false if dev is true, and true if dev is false. Disabling minification can be useful for speeding up production builds for testing purposes.
59
+ - `--bundle-output <string>`: File path where to store the resulting bundle
60
+ - `--bundle-encoding <string>`: Encoding the bundle should be written in (default: "utf8")
61
+ - `--resolver-option <string...>`: Custom resolver options (key=value format, URL-encoded, can be specified multiple times)
62
+ - `--sourcemap-output <string>`: File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map
63
+ - `--sourcemap-sources-root <string>`: Path to make sourcemap's sources entries relative to, ex. /root/dir
64
+ - `--sourcemap-use-absolute-path`: Report SourceMapURL using its full path (default: false)
65
+ - `--max-workers <number>`: Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine.
66
+ - `--assets-dest <string>`: Directory name where to store assets referenced in the bundle
67
+ - `--reset-cache`: Removes cached files (default: false)
68
+ - `--read-global-cache`: Try to fetch transformed JS code from the global cache, if configured (default: false)
69
+ - `--config <string>`: Path to the CLI configuration file
70
+
71
+ #### `bundle-mf-remote`
72
+
73
+ - `--platform <string>`: Target platform (default: "ios") - Either "ios" or "android"
74
+ - `--dev [boolean]`: If false, warnings are disabled and the bundle is minified (default: true)
75
+ - `--minify [boolean]`: Allows overriding whether bundle is minified. This defaults to false if dev is true, and true if dev is false. Disabling minification can be useful for speeding up production builds for testing purposes.
76
+ - `--bundle-encoding <string>`: Encoding the bundle should be written in (default: "utf8")
77
+ - `--max-workers <number>`: Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine.
78
+ - `--bundle-output <string>`: File path where to store the resulting bundle
79
+ - `--sourcemap-output <string>`: File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map
80
+ - `--sourcemap-sources-root <string>`: Path to make sourcemap's sources entries relative to, ex. /root/dir
81
+ - `--sourcemap-use-absolute-path`: Report SourceMapURL using its full path (default: false)
82
+ - `--assets-dest <string>`: Directory name where to store assets referenced in the bundle
83
+ - `--asset-catalog-dest [string]`: Path where to create an iOS Asset Catalog for images
84
+ - `--reset-cache`: Removes cached files (default: false)
85
+ - `--config <string>`: Path to the CLI configuration file
package/dist/index.cjs ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ pluginMetroModuleFederation: ()=>external_plugin_cjs_namespaceObject.pluginMetroModuleFederation,
28
+ default: ()=>src
29
+ });
30
+ const external_plugin_cjs_namespaceObject = require("./plugin.cjs");
31
+ const src = external_plugin_cjs_namespaceObject.pluginMetroModuleFederation;
32
+ exports["default"] = __webpack_exports__["default"];
33
+ exports.pluginMetroModuleFederation = __webpack_exports__.pluginMetroModuleFederation;
34
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
35
+ "default",
36
+ "pluginMetroModuleFederation"
37
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
38
+ Object.defineProperty(exports, '__esModule', {
39
+ value: true
40
+ });
@@ -0,0 +1,3 @@
1
+ import { pluginMetroModuleFederation } from './plugin.js';
2
+ export { pluginMetroModuleFederation };
3
+ export default pluginMetroModuleFederation;
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { pluginMetroModuleFederation } from "./plugin.js";
2
+ const src = pluginMetroModuleFederation;
3
+ export { src as default, pluginMetroModuleFederation };
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ pluginMetroModuleFederation: ()=>pluginMetroModuleFederation
37
+ });
38
+ const commands_namespaceObject = require("@module-federation/metro/commands");
39
+ var commands_default = /*#__PURE__*/ __webpack_require__.n(commands_namespaceObject);
40
+ const tools_namespaceObject = require("@rnef/tools");
41
+ const pluginMetroModuleFederation = (pluginConfig = {})=>(api)=>{
42
+ api.registerCommand({
43
+ name: 'bundle-mf-host',
44
+ description: 'Bundles a Module Federation host',
45
+ action: async (args)=>{
46
+ const commandConfig = {
47
+ root: api.getProjectRoot(),
48
+ platforms: api.getPlatforms(),
49
+ reactNativePath: api.getReactNativePath(),
50
+ ...pluginConfig
51
+ };
52
+ tools_namespaceObject.logger.info(`Bundling Module Federation host for platform ${tools_namespaceObject.color.cyan(args.platform)}`);
53
+ await commands_default().bundleFederatedHost([], commandConfig, args);
54
+ tools_namespaceObject.logger.info('Bundle artifacts available at ...');
55
+ (0, tools_namespaceObject.outro)("Success \uD83C\uDF89.");
56
+ },
57
+ options: [
58
+ ...commands_default().bundleFederatedHostOptions,
59
+ {
60
+ name: '--config-cmd [string]',
61
+ description: "[Internal] A hack for Xcode build script pointing to wrong bundle command that recognizes this flag. Do not use."
62
+ }
63
+ ]
64
+ });
65
+ api.registerCommand({
66
+ name: 'bundle-mf-remote',
67
+ description: 'Bundles a Module Federation remote, including its container entry and all exposed modules for consumption by host applications',
68
+ action: async (args)=>{
69
+ const commandConfig = {
70
+ root: api.getProjectRoot(),
71
+ platforms: api.getPlatforms(),
72
+ reactNativePath: api.getReactNativePath(),
73
+ ...pluginConfig
74
+ };
75
+ tools_namespaceObject.logger.info(`Bundling Module Federation remote for platform ${tools_namespaceObject.color.cyan(args.platform)}`);
76
+ await commands_default().bundleFederatedRemote([], commandConfig, args);
77
+ tools_namespaceObject.logger.info('Bundle artifacts available at ...');
78
+ (0, tools_namespaceObject.outro)("Success \uD83C\uDF89.");
79
+ },
80
+ options: commands_default().bundleFederatedRemoteOptions
81
+ });
82
+ return {
83
+ name: '@module-federation/metro-plugin-rnef',
84
+ description: 'RNEF plugin for Module Federation with Metro'
85
+ };
86
+ };
87
+ exports.pluginMetroModuleFederation = __webpack_exports__.pluginMetroModuleFederation;
88
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
89
+ "pluginMetroModuleFederation"
90
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
91
+ Object.defineProperty(exports, '__esModule', {
92
+ value: true
93
+ });
@@ -0,0 +1,6 @@
1
+ import type { PluginApi, PluginOutput } from '@rnef/config';
2
+ interface PluginConfig {
3
+ platforms?: Record<string, object>;
4
+ }
5
+ export declare const pluginMetroModuleFederation: (pluginConfig?: PluginConfig) => (api: PluginApi) => PluginOutput;
6
+ export {};
package/dist/plugin.js ADDED
@@ -0,0 +1,49 @@
1
+ import commands from "@module-federation/metro/commands";
2
+ import { color, logger, outro } from "@rnef/tools";
3
+ const pluginMetroModuleFederation = (pluginConfig = {})=>(api)=>{
4
+ api.registerCommand({
5
+ name: 'bundle-mf-host',
6
+ description: 'Bundles a Module Federation host',
7
+ action: async (args)=>{
8
+ const commandConfig = {
9
+ root: api.getProjectRoot(),
10
+ platforms: api.getPlatforms(),
11
+ reactNativePath: api.getReactNativePath(),
12
+ ...pluginConfig
13
+ };
14
+ logger.info(`Bundling Module Federation host for platform ${color.cyan(args.platform)}`);
15
+ await commands.bundleFederatedHost([], commandConfig, args);
16
+ logger.info('Bundle artifacts available at ...');
17
+ outro("Success \uD83C\uDF89.");
18
+ },
19
+ options: [
20
+ ...commands.bundleFederatedHostOptions,
21
+ {
22
+ name: '--config-cmd [string]',
23
+ description: "[Internal] A hack for Xcode build script pointing to wrong bundle command that recognizes this flag. Do not use."
24
+ }
25
+ ]
26
+ });
27
+ api.registerCommand({
28
+ name: 'bundle-mf-remote',
29
+ description: 'Bundles a Module Federation remote, including its container entry and all exposed modules for consumption by host applications',
30
+ action: async (args)=>{
31
+ const commandConfig = {
32
+ root: api.getProjectRoot(),
33
+ platforms: api.getPlatforms(),
34
+ reactNativePath: api.getReactNativePath(),
35
+ ...pluginConfig
36
+ };
37
+ logger.info(`Bundling Module Federation remote for platform ${color.cyan(args.platform)}`);
38
+ await commands.bundleFederatedRemote([], commandConfig, args);
39
+ logger.info('Bundle artifacts available at ...');
40
+ outro("Success \uD83C\uDF89.");
41
+ },
42
+ options: commands.bundleFederatedRemoteOptions
43
+ });
44
+ return {
45
+ name: '@module-federation/metro-plugin-rnef',
46
+ description: 'RNEF plugin for Module Federation with Metro'
47
+ };
48
+ };
49
+ export { pluginMetroModuleFederation };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@module-federation/metro-plugin-rnef",
3
+ "version": "0.0.0-next-20250827124348",
4
+ "description": "Metro Module Federation plugin for React Native Enterprise Framework (RNEF)",
5
+ "keywords": [
6
+ "rnef",
7
+ "module-federation",
8
+ "metro",
9
+ "react-native"
10
+ ],
11
+ "type": "module",
12
+ "license": "MIT",
13
+ "contributors": [
14
+ "Jakub Romańczyk <j.romanczyk@gmail.com> (https://github.com/jbroma)",
15
+ "Kacper Wiszczuk <kacperwiszczuk@gmail.com> (https://github.com/esemesek)"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "registry": "https://registry.npmjs.org/"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/module-federation/core",
24
+ "directory": "packages/metro-plugin-rnef"
25
+ },
26
+ "files": [
27
+ "dist/"
28
+ ],
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ "types": "./dist/index.d.ts",
33
+ "require": "./dist/index.cjs",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "peerDependencies": {
37
+ "@rnef/tools": "^0.7.18",
38
+ "@module-federation/metro": "0.0.0-next-20250827124348"
39
+ },
40
+ "devDependencies": {
41
+ "@rnef/config": "^0.7.18",
42
+ "@rnef/tools": "^0.7.18",
43
+ "@rslib/core": "^0.10.0",
44
+ "@types/node": "^20.0.0",
45
+ "typescript": "^5.8.3",
46
+ "@module-federation/metro": "0.0.0-next-20250827124348"
47
+ },
48
+ "scripts": {
49
+ "build": "rslib build",
50
+ "typecheck": "tsc --noEmit"
51
+ }
52
+ }