@module-federation/metro-plugin-rock 0.0.0-alpha.0

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jakub Romanczyk 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,96 @@
1
+ # @module-federation/metro-plugin-rock
2
+
3
+ Module Federation for [Rock](https://rockjs.dev) (formerly RNEF) using Metro bundler. This plugin integrates the `@module-federation/metro` package with Rock, providing commands to bundle Module Federation host and remotes.
4
+
5
+ ## Installation
6
+
7
+ 1. First, ensure you have [Rock](https://rockjs.dev) set up in your project.
8
+
9
+ 2. Install the plugin:
10
+
11
+ ```bash
12
+ npm install --save-dev @module-federation/metro-plugin-rock
13
+ ```
14
+
15
+ 3. Add the plugin to your Rock configuration (typically in `rock.config.mjs`):
16
+
17
+ ```typescript
18
+ import { pluginMetro } from '@rock-js/plugin-metro';
19
+ import moduleFederation from '@module-federation/metro-plugin-rock';
20
+
21
+ /** @type {import('@rock-js/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
+ rock bundle-mf-host --entry-file index.js --platform ios
35
+
36
+ # Bundle for Android
37
+ rock 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
+ rock bundle-mf-remote --platform ios
45
+
46
+ # Bundle for Android
47
+ rock 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
86
+
87
+ ## Migrating from RNEF
88
+
89
+ If you're migrating from `@module-federation/metro-plugin-rnef`, update your imports:
90
+
91
+ ```diff
92
+ -import moduleFederation from '@module-federation/metro-plugin-rnef';
93
+ +import moduleFederation from '@module-federation/metro-plugin-rock';
94
+ ```
95
+
96
+ And update your config file from `rnef.config.mjs` to `rock.config.mjs` as per the [Rock migration guide](https://rockjs.dev).
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@module-federation/metro-plugin-rock",
3
+ "version": "0.0.0-alpha.0",
4
+ "description": "Metro Module Federation plugin for Rock",
5
+ "keywords": [
6
+ "rock",
7
+ "rockjs",
8
+ "module-federation",
9
+ "metro",
10
+ "react-native"
11
+ ],
12
+ "type": "module",
13
+ "license": "MIT",
14
+ "author": "Jakub Romańczyk <j.romanczyk@gmail.com> (https://github.com/jbroma)",
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/module-federation/core.git",
22
+ "directory": "packages/metro-plugin-rock"
23
+ },
24
+ "files": [
25
+ "dist/"
26
+ ],
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ "types": "./dist/index.d.ts",
31
+ "require": "./dist/index.cjs",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "scripts": {
35
+ "build": "rslib build",
36
+ "typecheck": "tsc --noEmit",
37
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.{js,ts}\""
38
+ },
39
+ "peerDependencies": {
40
+ "@module-federation/metro": "workspace:*",
41
+ "@rock-js/tools": "^0.13.0"
42
+ },
43
+ "devDependencies": {
44
+ "@module-federation/metro": "workspace:*",
45
+ "@rock-js/config": "^0.13.0",
46
+ "@rock-js/tools": "^0.13.0",
47
+ "@rslib/core": "^0.10.0",
48
+ "@typescript-eslint/eslint-plugin": "8.54.0",
49
+ "@typescript-eslint/parser": "8.54.0",
50
+ "@types/node": "^20.0.0",
51
+ "typescript": "^5.8.3"
52
+ }
53
+ }