@module-federation/metro 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703
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/babel-plugin/patch-initialize-core.js +3 -3
- package/babel-plugin/patch-require.js +3 -3
- package/dist/babel/transformer.js +1 -1
- package/dist/commands/bundle-host/index.js +17 -12
- package/dist/commands/bundle-host/index.mjs +8 -30
- package/dist/commands/bundle-host/options.js +12 -8
- package/dist/commands/bundle-host/options.mjs +2 -3
- package/dist/commands/bundle-host/types.js +2 -2
- package/dist/commands/bundle-host/types.mjs +1 -2
- package/dist/commands/bundle-remote/index.js +34 -19
- package/dist/commands/bundle-remote/index.mjs +28 -38
- package/dist/commands/bundle-remote/options.js +15 -11
- package/dist/commands/bundle-remote/options.mjs +4 -5
- package/dist/commands/bundle-remote/types.js +2 -2
- package/dist/commands/bundle-remote/types.mjs +1 -2
- package/dist/commands/index.js +14 -10
- package/dist/commands/index.mjs +3 -3
- package/dist/commands/types.js +2 -2
- package/dist/commands/types.mjs +1 -2
- package/dist/commands/utils/create-module-path-remapper.js +15 -11
- package/dist/commands/utils/create-module-path-remapper.mjs +1 -2
- package/dist/commands/utils/create-resolver.d.ts +1 -1
- package/dist/commands/utils/create-resolver.js +15 -11
- package/dist/commands/utils/create-resolver.mjs +1 -2
- package/dist/commands/utils/get-community-plugin.d.ts +1 -2
- package/dist/commands/utils/get-community-plugin.js +15 -12
- package/dist/commands/utils/get-community-plugin.mjs +5 -6
- package/dist/commands/utils/load-metro-config.js +15 -14
- package/dist/commands/utils/load-metro-config.mjs +9 -11
- package/dist/commands/utils/path-utils.d.ts +2 -0
- package/dist/commands/utils/path-utils.js +51 -0
- package/dist/commands/utils/path-utils.mjs +11 -0
- package/dist/commands/utils/save-bundle-and-map.d.ts +1 -1
- package/dist/commands/utils/save-bundle-and-map.js +14 -11
- package/dist/commands/utils/save-bundle-and-map.mjs +3 -27
- package/dist/index.js +14 -10
- package/dist/index.mjs +3 -5
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +43 -0
- package/dist/logger.mjs +6 -0
- package/dist/modules/asyncRequire.ts +41 -10
- package/dist/modules/metroCorePlugin.ts +2 -3
- package/dist/plugin/babel-transformer.js +13 -9
- package/dist/plugin/babel-transformer.mjs +3 -3
- package/dist/plugin/constants.d.ts +1 -0
- package/dist/plugin/constants.js +27 -19
- package/dist/plugin/constants.mjs +3 -3
- package/dist/plugin/generators.js +28 -21
- package/dist/plugin/generators.mjs +14 -11
- package/dist/plugin/helpers.d.ts +1 -0
- package/dist/plugin/helpers.js +28 -20
- package/dist/plugin/helpers.mjs +9 -9
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.js +64 -13
- package/dist/plugin/index.mjs +54 -7
- package/dist/plugin/manifest-middleware.d.ts +12 -0
- package/dist/plugin/manifest-middleware.js +217 -0
- package/dist/plugin/manifest-middleware.mjs +170 -0
- package/dist/plugin/manifest.d.ts +15 -2
- package/dist/plugin/manifest.js +126 -26
- package/dist/plugin/manifest.mjs +107 -22
- package/dist/plugin/normalize-extra-options.js +16 -12
- package/dist/plugin/normalize-extra-options.mjs +2 -3
- package/dist/plugin/normalize-options.js +70 -20
- package/dist/plugin/normalize-options.mjs +60 -14
- package/dist/plugin/resolver.d.ts +1 -1
- package/dist/plugin/resolver.js +16 -12
- package/dist/plugin/resolver.mjs +10 -11
- package/dist/plugin/rewrite-request.d.ts +5 -1
- package/dist/plugin/rewrite-request.js +23 -10
- package/dist/plugin/rewrite-request.mjs +13 -5
- package/dist/plugin/serializer.d.ts +2 -1
- package/dist/plugin/serializer.js +59 -39
- package/dist/plugin/serializer.mjs +48 -55
- package/dist/plugin/validate-options.js +116 -12
- package/dist/plugin/validate-options.mjs +95 -7
- package/dist/types.d.ts +15 -15
- package/dist/types.js +2 -2
- package/dist/types.mjs +1 -2
- package/dist/utils/errors.js +16 -12
- package/dist/utils/errors.mjs +1 -2
- package/dist/utils/federated-remote-types.d.ts +12 -0
- package/dist/utils/federated-remote-types.js +140 -0
- package/dist/utils/federated-remote-types.mjs +90 -0
- package/dist/utils/index.js +14 -10
- package/dist/utils/index.mjs +3 -5
- package/dist/utils/metro-compat.d.ts +23 -0
- package/dist/utils/metro-compat.js +74 -0
- package/dist/utils/metro-compat.mjs +26 -0
- package/dist/utils/vm-manager.d.ts +1 -1
- package/dist/utils/vm-manager.js +14 -12
- package/dist/utils/vm-manager.mjs +3 -6
- package/package.json +22 -7
- package/dist/babel/transformer.d.ts +0 -2
- package/dist/runtime/host-entry.d.ts +0 -1
- package/dist/runtime/init-host.d.ts +0 -1
- package/dist/runtime/remote-entry.d.ts +0 -1
- package/dist/runtime/remote-hmr.d.ts +0 -1
- package/dist/runtime/remote-module-registry.d.ts +0 -7
- package/dist/runtime/remote-module.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -13,7 +17,7 @@ var __webpack_require__ = {};
|
|
|
13
17
|
})();
|
|
14
18
|
(()=>{
|
|
15
19
|
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if (
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
21
|
value: 'Module'
|
|
18
22
|
});
|
|
19
23
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -24,17 +28,17 @@ var __webpack_require__ = {};
|
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
updateManifest: ()=>manifest_js_namespaceObject.updateManifest,
|
|
32
|
+
withModuleFederation: ()=>index_js_namespaceObject.withModuleFederation
|
|
29
33
|
});
|
|
30
34
|
const index_js_namespaceObject = require("./plugin/index.js");
|
|
31
35
|
const manifest_js_namespaceObject = require("./plugin/manifest.js");
|
|
32
36
|
exports.updateManifest = __webpack_exports__.updateManifest;
|
|
33
37
|
exports.withModuleFederation = __webpack_exports__.withModuleFederation;
|
|
34
|
-
for(var
|
|
38
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
39
|
"updateManifest",
|
|
36
40
|
"withModuleFederation"
|
|
37
|
-
].indexOf(
|
|
41
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
38
42
|
Object.defineProperty(exports, '__esModule', {
|
|
39
43
|
value: true
|
|
40
44
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { updateManifest } from "./plugin/manifest.mjs";
|
|
5
|
-
export { updateManifest, withModuleFederation };
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { withModuleFederation } from "./plugin/index.mjs";
|
|
3
|
+
export { updateManifest } from "./plugin/manifest.mjs";
|
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
default: ()=>src_logger
|
|
32
|
+
});
|
|
33
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
34
|
+
const constants_js_namespaceObject = require("./plugin/constants.js");
|
|
35
|
+
const logger = (0, sdk_namespaceObject.createLogger)(constants_js_namespaceObject.PLUGIN_IDENTIFIER);
|
|
36
|
+
const src_logger = logger;
|
|
37
|
+
exports["default"] = __webpack_exports__["default"];
|
|
38
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
39
|
+
"default"
|
|
40
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
41
|
+
Object.defineProperty(exports, '__esModule', {
|
|
42
|
+
value: true
|
|
43
|
+
});
|
package/dist/logger.mjs
ADDED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// This file is injected as a self-contained Metro runtime module. Keep all
|
|
2
|
+
// runtime logic in this file and do not add imports.
|
|
3
|
+
|
|
1
4
|
// join two paths
|
|
2
5
|
// e.g. /a/b/ + /c/d -> /a/b/c/d
|
|
3
6
|
function joinComponents(prefix: string, suffix: string) {
|
|
@@ -14,6 +17,13 @@ function isUrl(url: string) {
|
|
|
14
17
|
return url.match(/^https?:\/\//);
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
// normalize Windows separators and encode parent segments to prevent URL sanitization
|
|
21
|
+
// macOS: /../../node_modules -> /..%2F..%2Fnode_modules
|
|
22
|
+
// Windows: /..\..\node_modules -> /..%2F..%2Fnode_modules
|
|
23
|
+
function encodeBundlePath(bundlePath: string) {
|
|
24
|
+
return bundlePath.replaceAll('\\', '/').replaceAll('../', '..%2F');
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
// get bundle id from the bundle path
|
|
18
28
|
// e.g. /a/b.bundle?platform=ios -> a/b
|
|
19
29
|
// e.g. http://host:8081/a/b.bundle -> a/b
|
|
@@ -27,8 +37,8 @@ function getBundleId(bundlePath: string, publicPath: string) {
|
|
|
27
37
|
if (path.startsWith('/')) {
|
|
28
38
|
path = path.slice(1);
|
|
29
39
|
}
|
|
30
|
-
// remove the query params
|
|
31
|
-
path = path.split('?')[0];
|
|
40
|
+
// remove the query params and normalize Windows separators
|
|
41
|
+
path = path.split('?')[0].replaceAll('\\', '/');
|
|
32
42
|
// remove the bundle extension
|
|
33
43
|
return path.replace('.bundle', '');
|
|
34
44
|
}
|
|
@@ -65,25 +75,48 @@ function buildLoadBundleAsyncWrapper() {
|
|
|
65
75
|
const registry = require('mf:remote-module-registry');
|
|
66
76
|
|
|
67
77
|
const __loadBundleAsync =
|
|
68
|
-
// @ts-expect-error dynamic key access on global object
|
|
69
78
|
globalThis[`${__METRO_GLOBAL_PREFIX__ ?? ''}__loadBundleAsync`];
|
|
70
79
|
|
|
71
80
|
const loadBundleAsync =
|
|
72
81
|
__loadBundleAsync as typeof globalThis.__loadBundleAsync;
|
|
73
82
|
|
|
74
|
-
return async (originalBundlePath: string) => {
|
|
83
|
+
return async (originalBundlePath: string): Promise<void> => {
|
|
75
84
|
const scope = globalThis.__FEDERATION__.__NATIVE__[__METRO_GLOBAL_PREFIX__];
|
|
76
85
|
|
|
77
86
|
// entry is always in the root directory of assets associated with remote
|
|
78
87
|
// based on that, we extract the public path from the origin URL
|
|
79
88
|
// e.g. http://example.com/a/b/c/mf-manfiest.json -> http://example.com/a/b/c
|
|
80
89
|
const publicPath = getPublicPath(scope.origin);
|
|
81
|
-
|
|
90
|
+
let bundlePath = getBundlePath(originalBundlePath, publicPath);
|
|
91
|
+
|
|
92
|
+
const isSplitBundle = !isUrl(originalBundlePath);
|
|
93
|
+
|
|
94
|
+
// Cache handler registered externally (e.g. by zephyr-native-cache register()).
|
|
95
|
+
// Stored under __FEDERATION__.__NATIVE__.__CACHE__ as a singleton (no prefix scope).
|
|
96
|
+
const cacheHandler = (globalThis as any).__FEDERATION__?.__NATIVE__
|
|
97
|
+
?.__CACHE__ as
|
|
98
|
+
| ((
|
|
99
|
+
fallback: (path: string) => Promise<void>,
|
|
100
|
+
bundlePath: string,
|
|
101
|
+
) => Promise<void>)
|
|
102
|
+
| undefined;
|
|
103
|
+
|
|
104
|
+
// For remote split bundles with cache enabled, convert relative paths to
|
|
105
|
+
// full URLs so they enter the same cache path as container bundles.
|
|
106
|
+
// In dev mode, getBundlePath returns relative paths unchanged, but we need
|
|
107
|
+
// full URLs for the cache layer (download + eval).
|
|
108
|
+
if (isSplitBundle && cacheHandler && publicPath && !isUrl(bundlePath)) {
|
|
109
|
+
bundlePath = joinComponents(publicPath, bundlePath);
|
|
110
|
+
}
|
|
82
111
|
|
|
83
|
-
|
|
84
|
-
const encodedBundlePath = bundlePath.replaceAll('../', '..%2F');
|
|
112
|
+
const encodedBundlePath = encodeBundlePath(bundlePath);
|
|
85
113
|
|
|
86
|
-
|
|
114
|
+
let result;
|
|
115
|
+
if (cacheHandler) {
|
|
116
|
+
await cacheHandler(loadBundleAsync, encodedBundlePath);
|
|
117
|
+
} else {
|
|
118
|
+
result = await loadBundleAsync(encodedBundlePath);
|
|
119
|
+
}
|
|
87
120
|
|
|
88
121
|
// when the origin is not the same, it means we are loading a remote container
|
|
89
122
|
// we can return early since dependencies are processed differently for entry bundles
|
|
@@ -125,10 +158,8 @@ if (!process.env.EXPO_OS) {
|
|
|
125
158
|
buildAsyncRequire,
|
|
126
159
|
} = require('@expo/metro-runtime/src/async-require/buildAsyncRequire');
|
|
127
160
|
|
|
128
|
-
// @ts-expect-error dynamic key access on global object
|
|
129
161
|
global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`] = buildAsyncRequire();
|
|
130
162
|
}
|
|
131
163
|
|
|
132
|
-
// @ts-expect-error dynamic key access on global object
|
|
133
164
|
global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`] =
|
|
134
165
|
buildLoadBundleAsyncWrapper();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Federation,
|
|
3
|
-
|
|
3
|
+
ModuleFederationRuntimePlugin,
|
|
4
4
|
} from '@module-federation/runtime';
|
|
5
5
|
|
|
6
6
|
declare global {
|
|
@@ -42,13 +42,12 @@ const buildUrlForEntryBundle = (entry: string) => {
|
|
|
42
42
|
return entry;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const MetroCorePlugin: () =>
|
|
45
|
+
const MetroCorePlugin: () => ModuleFederationRuntimePlugin = () => ({
|
|
46
46
|
name: 'metro-core-plugin',
|
|
47
47
|
loadEntry: async ({ remoteInfo }) => {
|
|
48
48
|
const { entry, entryGlobalName } = remoteInfo;
|
|
49
49
|
|
|
50
50
|
const __loadBundleAsync =
|
|
51
|
-
// @ts-expect-error dynamic key access on global object
|
|
52
51
|
globalThis[`${__METRO_GLOBAL_PREFIX__ ?? ''}__loadBundleAsync`];
|
|
53
52
|
|
|
54
53
|
const loadBundleAsync =
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -22,7 +26,7 @@ var __webpack_require__ = {};
|
|
|
22
26
|
})();
|
|
23
27
|
(()=>{
|
|
24
28
|
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if (
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
30
|
value: 'Module'
|
|
27
31
|
});
|
|
28
32
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -55,14 +59,14 @@ function createBabelTransformer({ blacklistedPaths, federationConfig, originalBa
|
|
|
55
59
|
enableInitializeCorePatching ? '@module-federation/metro/babel-plugin/patch-initialize-core' : void 0,
|
|
56
60
|
enableRuntimeRequirePatching ? '@module-federation/metro/babel-plugin/patch-require' : void 0
|
|
57
61
|
].filter(Boolean);
|
|
58
|
-
const babelTransformer = transformerTemplate.replaceAll('__BABEL_TRANSFORMER_PATH__', originalBabelTransformerPath).replaceAll('__BABEL_PLUGINS__', JSON.stringify(plugins));
|
|
62
|
+
const babelTransformer = transformerTemplate.replaceAll('__BABEL_TRANSFORMER_PATH__', JSON.stringify(originalBabelTransformerPath)).replaceAll('__BABEL_PLUGINS__', JSON.stringify(plugins));
|
|
59
63
|
external_node_fs_default().writeFileSync(outputPath, babelTransformer, 'utf-8');
|
|
60
64
|
return outputPath;
|
|
61
65
|
}
|
|
62
66
|
exports.createBabelTransformer = __webpack_exports__.createBabelTransformer;
|
|
63
|
-
for(var
|
|
67
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
68
|
"createBabelTransformer"
|
|
65
|
-
].indexOf(
|
|
69
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
70
|
Object.defineProperty(exports, '__esModule', {
|
|
67
71
|
value: true
|
|
68
72
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import __rslib_shim_module__ from
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
function createBabelTransformer({ blacklistedPaths, federationConfig, originalBabelTransformerPath, tmpDirPath, enableInitializeCorePatching, enableRuntimeRequirePatching }) {
|
|
@@ -18,7 +18,7 @@ function createBabelTransformer({ blacklistedPaths, federationConfig, originalBa
|
|
|
18
18
|
enableInitializeCorePatching ? '@module-federation/metro/babel-plugin/patch-initialize-core' : void 0,
|
|
19
19
|
enableRuntimeRequirePatching ? '@module-federation/metro/babel-plugin/patch-require' : void 0
|
|
20
20
|
].filter(Boolean);
|
|
21
|
-
const babelTransformer = transformerTemplate.replaceAll('__BABEL_TRANSFORMER_PATH__', originalBabelTransformerPath).replaceAll('__BABEL_PLUGINS__', JSON.stringify(plugins));
|
|
21
|
+
const babelTransformer = transformerTemplate.replaceAll('__BABEL_TRANSFORMER_PATH__', JSON.stringify(originalBabelTransformerPath)).replaceAll('__BABEL_PLUGINS__', JSON.stringify(plugins));
|
|
22
22
|
node_fs.writeFileSync(outputPath, babelTransformer, 'utf-8');
|
|
23
23
|
return outputPath;
|
|
24
24
|
}
|
|
@@ -2,6 +2,7 @@ export declare const INIT_HOST = "mf:init-host";
|
|
|
2
2
|
export declare const ASYNC_REQUIRE = "mf:async-require";
|
|
3
3
|
export declare const REMOTE_MODULE_REGISTRY = "mf:remote-module-registry";
|
|
4
4
|
export declare const REMOTE_HMR_SETUP = "mf:remote-hmr";
|
|
5
|
+
export declare const PLUGIN_IDENTIFIER = "[ Module Federation Metro ]";
|
|
5
6
|
export declare const DEFAULT_ENTRY_FILENAME = "remoteEntry.bundle";
|
|
6
7
|
export declare const GET_DEV_SERVER_REGEX: RegExp;
|
|
7
8
|
export declare const HMR_CLIENT_REGEX: RegExp;
|
package/dist/plugin/constants.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -13,7 +17,7 @@ var __webpack_require__ = {};
|
|
|
13
17
|
})();
|
|
14
18
|
(()=>{
|
|
15
19
|
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if (
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
21
|
value: 'Module'
|
|
18
22
|
});
|
|
19
23
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -23,46 +27,50 @@ var __webpack_require__ = {};
|
|
|
23
27
|
})();
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
ASYNC_REQUIRE: ()=>ASYNC_REQUIRE,
|
|
28
|
-
DEFAULT_ENTRY_FILENAME: ()=>DEFAULT_ENTRY_FILENAME,
|
|
29
|
-
GET_DEV_SERVER_REGEX: ()=>GET_DEV_SERVER_REGEX,
|
|
30
|
-
HMR_CLIENT_REGEX: ()=>HMR_CLIENT_REGEX,
|
|
31
|
-
INIT_HOST: ()=>INIT_HOST,
|
|
32
|
-
MANIFEST_FILENAME: ()=>MANIFEST_FILENAME,
|
|
33
|
-
REMOTE_HMR_SETUP: ()=>REMOTE_HMR_SETUP,
|
|
34
|
-
REMOTE_MODULE_REGISTRY: ()=>REMOTE_MODULE_REGISTRY,
|
|
35
|
-
TMP_DIR_NAME: ()=>TMP_DIR_NAME
|
|
36
|
-
});
|
|
37
30
|
const INIT_HOST = 'mf:init-host';
|
|
38
31
|
const ASYNC_REQUIRE = 'mf:async-require';
|
|
39
32
|
const REMOTE_MODULE_REGISTRY = 'mf:remote-module-registry';
|
|
40
33
|
const REMOTE_HMR_SETUP = 'mf:remote-hmr';
|
|
34
|
+
const PLUGIN_IDENTIFIER = '[ Module Federation Metro ]';
|
|
41
35
|
const DEFAULT_ENTRY_FILENAME = 'remoteEntry.bundle';
|
|
42
36
|
const GET_DEV_SERVER_REGEX = /react-native\/Libraries\/Core\/Devtools\/getDevServer\.js$/;
|
|
43
37
|
const HMR_CLIENT_REGEX = /react-native\/Libraries\/Utilities\/HMRClient\.js$/;
|
|
44
38
|
const TMP_DIR_NAME = '.mf-metro';
|
|
45
39
|
const MANIFEST_FILENAME = 'mf-manifest.json';
|
|
40
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
41
|
+
ASYNC_REQUIRE: ASYNC_REQUIRE,
|
|
42
|
+
DEFAULT_ENTRY_FILENAME: DEFAULT_ENTRY_FILENAME,
|
|
43
|
+
GET_DEV_SERVER_REGEX: GET_DEV_SERVER_REGEX,
|
|
44
|
+
HMR_CLIENT_REGEX: HMR_CLIENT_REGEX,
|
|
45
|
+
INIT_HOST: INIT_HOST,
|
|
46
|
+
MANIFEST_FILENAME: MANIFEST_FILENAME,
|
|
47
|
+
PLUGIN_IDENTIFIER: PLUGIN_IDENTIFIER,
|
|
48
|
+
REMOTE_HMR_SETUP: REMOTE_HMR_SETUP,
|
|
49
|
+
REMOTE_MODULE_REGISTRY: REMOTE_MODULE_REGISTRY,
|
|
50
|
+
TMP_DIR_NAME: TMP_DIR_NAME
|
|
51
|
+
});
|
|
46
52
|
exports.ASYNC_REQUIRE = __webpack_exports__.ASYNC_REQUIRE;
|
|
47
53
|
exports.DEFAULT_ENTRY_FILENAME = __webpack_exports__.DEFAULT_ENTRY_FILENAME;
|
|
48
54
|
exports.GET_DEV_SERVER_REGEX = __webpack_exports__.GET_DEV_SERVER_REGEX;
|
|
49
55
|
exports.HMR_CLIENT_REGEX = __webpack_exports__.HMR_CLIENT_REGEX;
|
|
50
56
|
exports.INIT_HOST = __webpack_exports__.INIT_HOST;
|
|
51
57
|
exports.MANIFEST_FILENAME = __webpack_exports__.MANIFEST_FILENAME;
|
|
58
|
+
exports.PLUGIN_IDENTIFIER = __webpack_exports__.PLUGIN_IDENTIFIER;
|
|
52
59
|
exports.REMOTE_HMR_SETUP = __webpack_exports__.REMOTE_HMR_SETUP;
|
|
53
60
|
exports.REMOTE_MODULE_REGISTRY = __webpack_exports__.REMOTE_MODULE_REGISTRY;
|
|
54
61
|
exports.TMP_DIR_NAME = __webpack_exports__.TMP_DIR_NAME;
|
|
55
|
-
for(var
|
|
62
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
56
63
|
"ASYNC_REQUIRE",
|
|
57
64
|
"DEFAULT_ENTRY_FILENAME",
|
|
58
65
|
"GET_DEV_SERVER_REGEX",
|
|
59
66
|
"HMR_CLIENT_REGEX",
|
|
60
67
|
"INIT_HOST",
|
|
61
68
|
"MANIFEST_FILENAME",
|
|
69
|
+
"PLUGIN_IDENTIFIER",
|
|
62
70
|
"REMOTE_HMR_SETUP",
|
|
63
71
|
"REMOTE_MODULE_REGISTRY",
|
|
64
72
|
"TMP_DIR_NAME"
|
|
65
|
-
].indexOf(
|
|
73
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
74
|
Object.defineProperty(exports, '__esModule', {
|
|
67
75
|
value: true
|
|
68
76
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
const INIT_HOST = 'mf:init-host';
|
|
4
3
|
const ASYNC_REQUIRE = 'mf:async-require';
|
|
5
4
|
const REMOTE_MODULE_REGISTRY = 'mf:remote-module-registry';
|
|
6
5
|
const REMOTE_HMR_SETUP = 'mf:remote-hmr';
|
|
6
|
+
const PLUGIN_IDENTIFIER = '[ Module Federation Metro ]';
|
|
7
7
|
const DEFAULT_ENTRY_FILENAME = 'remoteEntry.bundle';
|
|
8
8
|
const GET_DEV_SERVER_REGEX = /react-native\/Libraries\/Core\/Devtools\/getDevServer\.js$/;
|
|
9
9
|
const HMR_CLIENT_REGEX = /react-native\/Libraries\/Utilities\/HMRClient\.js$/;
|
|
10
10
|
const TMP_DIR_NAME = '.mf-metro';
|
|
11
11
|
const MANIFEST_FILENAME = 'mf-manifest.json';
|
|
12
|
-
export { ASYNC_REQUIRE, DEFAULT_ENTRY_FILENAME, GET_DEV_SERVER_REGEX, HMR_CLIENT_REGEX, INIT_HOST, MANIFEST_FILENAME, REMOTE_HMR_SETUP, REMOTE_MODULE_REGISTRY, TMP_DIR_NAME };
|
|
12
|
+
export { ASYNC_REQUIRE, DEFAULT_ENTRY_FILENAME, GET_DEV_SERVER_REGEX, HMR_CLIENT_REGEX, INIT_HOST, MANIFEST_FILENAME, PLUGIN_IDENTIFIER, REMOTE_HMR_SETUP, REMOTE_MODULE_REGISTRY, TMP_DIR_NAME };
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -22,7 +26,7 @@ var __webpack_require__ = {};
|
|
|
22
26
|
})();
|
|
23
27
|
(()=>{
|
|
24
28
|
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if (
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
30
|
value: 'Module'
|
|
27
31
|
});
|
|
28
32
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -33,24 +37,26 @@ var __webpack_require__ = {};
|
|
|
33
37
|
var __webpack_exports__ = {};
|
|
34
38
|
__webpack_require__.r(__webpack_exports__);
|
|
35
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
getRemoteModuleRegistryModule: ()=>getRemoteModuleRegistryModule,
|
|
37
|
-
getRemoteEntryModule: ()=>getRemoteEntryModule,
|
|
38
|
-
getInitHostModule: ()=>getInitHostModule,
|
|
39
40
|
getHostEntryModule: ()=>getHostEntryModule,
|
|
41
|
+
getInitHostModule: ()=>getInitHostModule,
|
|
42
|
+
getRemoteEntryModule: ()=>getRemoteEntryModule,
|
|
40
43
|
getRemoteHMRSetupModule: ()=>getRemoteHMRSetupModule,
|
|
41
|
-
getRemoteModule: ()=>getRemoteModule
|
|
44
|
+
getRemoteModule: ()=>getRemoteModule,
|
|
45
|
+
getRemoteModuleRegistryModule: ()=>getRemoteModuleRegistryModule
|
|
42
46
|
});
|
|
43
47
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
44
48
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
45
49
|
const external_node_path_namespaceObject = require("node:path");
|
|
46
50
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
51
|
+
const external_helpers_js_namespaceObject = require("./helpers.js");
|
|
47
52
|
function getRemoteModule(name) {
|
|
48
53
|
const template = getModuleTemplate('remote-module.js');
|
|
49
54
|
return template.replaceAll('__MODULE_ID__', `"${name}"`);
|
|
50
55
|
}
|
|
51
56
|
function getHostEntryModule(_, paths) {
|
|
52
57
|
const template = getModuleTemplate('host-entry.js');
|
|
53
|
-
|
|
58
|
+
const relativeEntryPath = (0, external_helpers_js_namespaceObject.toPosixPath)(external_node_path_default().relative(paths.tmpDir, paths.originalEntry));
|
|
59
|
+
return template.replaceAll('__ENTRYPOINT_IMPORT__', `import './${relativeEntryPath}'`);
|
|
54
60
|
}
|
|
55
61
|
function getInitHostModule(options) {
|
|
56
62
|
const template = getModuleTemplate('init-host.js');
|
|
@@ -71,7 +77,7 @@ function getRemoteHMRSetupModule() {
|
|
|
71
77
|
function generateExposes(exposes, paths) {
|
|
72
78
|
const exposesString = Object.keys(exposes).map((key)=>{
|
|
73
79
|
const importPath = external_node_path_default().join(paths.projectDir, exposes[key]);
|
|
74
|
-
const relativeImportPath = external_node_path_default().relative(paths.tmpDir, importPath);
|
|
80
|
+
const relativeImportPath = (0, external_helpers_js_namespaceObject.toPosixPath)(external_node_path_default().relative(paths.tmpDir, importPath));
|
|
75
81
|
return `"${key}": async () => import("${relativeImportPath}")`;
|
|
76
82
|
});
|
|
77
83
|
return `{${exposesString.join(',')}}`;
|
|
@@ -82,7 +88,8 @@ function generateRuntimePlugins(runtimePlugins) {
|
|
|
82
88
|
runtimePlugins.forEach((plugin, index)=>{
|
|
83
89
|
const pluginName = `plugin${index}`;
|
|
84
90
|
pluginNames.push(`${pluginName}()`);
|
|
85
|
-
|
|
91
|
+
const pluginPath = (0, external_helpers_js_namespaceObject.toPosixPath)(plugin);
|
|
92
|
+
pluginImports.push(`import ${pluginName} from "${pluginPath}";`);
|
|
86
93
|
});
|
|
87
94
|
const imports = pluginImports.join('\n');
|
|
88
95
|
const plugins = `const plugins = [${pluginNames.join(', ')}];`;
|
|
@@ -94,12 +101,12 @@ function generateRemotes(remotes = {}) {
|
|
|
94
101
|
const remoteEntryParts = remoteEntry.split('@');
|
|
95
102
|
const remoteName = remoteEntryParts[0];
|
|
96
103
|
const remoteEntryUrl = remoteEntryParts.slice(1).join('@');
|
|
97
|
-
remotesEntries.push(`{
|
|
98
|
-
alias:
|
|
99
|
-
name:
|
|
100
|
-
entry:
|
|
101
|
-
entryGlobalName:
|
|
102
|
-
type: "var"
|
|
104
|
+
remotesEntries.push(`{
|
|
105
|
+
alias: ${JSON.stringify(remoteAlias)},
|
|
106
|
+
name: ${JSON.stringify(remoteName)},
|
|
107
|
+
entry: ${JSON.stringify(remoteEntryUrl)},
|
|
108
|
+
entryGlobalName: ${JSON.stringify(remoteName)},
|
|
109
|
+
type: "var"
|
|
103
110
|
}`);
|
|
104
111
|
}
|
|
105
112
|
return `[${remotesEntries.join(',\n')}]`;
|
|
@@ -144,14 +151,14 @@ exports.getRemoteEntryModule = __webpack_exports__.getRemoteEntryModule;
|
|
|
144
151
|
exports.getRemoteHMRSetupModule = __webpack_exports__.getRemoteHMRSetupModule;
|
|
145
152
|
exports.getRemoteModule = __webpack_exports__.getRemoteModule;
|
|
146
153
|
exports.getRemoteModuleRegistryModule = __webpack_exports__.getRemoteModuleRegistryModule;
|
|
147
|
-
for(var
|
|
154
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
148
155
|
"getHostEntryModule",
|
|
149
156
|
"getInitHostModule",
|
|
150
157
|
"getRemoteEntryModule",
|
|
151
158
|
"getRemoteHMRSetupModule",
|
|
152
159
|
"getRemoteModule",
|
|
153
160
|
"getRemoteModuleRegistryModule"
|
|
154
|
-
].indexOf(
|
|
161
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
155
162
|
Object.defineProperty(exports, '__esModule', {
|
|
156
163
|
value: true
|
|
157
164
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import __rslib_shim_module__ from
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
4
|
import node_path from "node:path";
|
|
5
|
+
import { toPosixPath } from "./helpers.mjs";
|
|
5
6
|
function getRemoteModule(name) {
|
|
6
7
|
const template = getModuleTemplate('remote-module.js');
|
|
7
8
|
return template.replaceAll('__MODULE_ID__', `"${name}"`);
|
|
8
9
|
}
|
|
9
10
|
function getHostEntryModule(_, paths) {
|
|
10
11
|
const template = getModuleTemplate('host-entry.js');
|
|
11
|
-
|
|
12
|
+
const relativeEntryPath = toPosixPath(node_path.relative(paths.tmpDir, paths.originalEntry));
|
|
13
|
+
return template.replaceAll('__ENTRYPOINT_IMPORT__', `import './${relativeEntryPath}'`);
|
|
12
14
|
}
|
|
13
15
|
function getInitHostModule(options) {
|
|
14
16
|
const template = getModuleTemplate('init-host.js');
|
|
@@ -29,7 +31,7 @@ function getRemoteHMRSetupModule() {
|
|
|
29
31
|
function generateExposes(exposes, paths) {
|
|
30
32
|
const exposesString = Object.keys(exposes).map((key)=>{
|
|
31
33
|
const importPath = node_path.join(paths.projectDir, exposes[key]);
|
|
32
|
-
const relativeImportPath = node_path.relative(paths.tmpDir, importPath);
|
|
34
|
+
const relativeImportPath = toPosixPath(node_path.relative(paths.tmpDir, importPath));
|
|
33
35
|
return `"${key}": async () => import("${relativeImportPath}")`;
|
|
34
36
|
});
|
|
35
37
|
return `{${exposesString.join(',')}}`;
|
|
@@ -40,7 +42,8 @@ function generateRuntimePlugins(runtimePlugins) {
|
|
|
40
42
|
runtimePlugins.forEach((plugin, index)=>{
|
|
41
43
|
const pluginName = `plugin${index}`;
|
|
42
44
|
pluginNames.push(`${pluginName}()`);
|
|
43
|
-
|
|
45
|
+
const pluginPath = toPosixPath(plugin);
|
|
46
|
+
pluginImports.push(`import ${pluginName} from "${pluginPath}";`);
|
|
44
47
|
});
|
|
45
48
|
const imports = pluginImports.join('\n');
|
|
46
49
|
const plugins = `const plugins = [${pluginNames.join(', ')}];`;
|
|
@@ -52,12 +55,12 @@ function generateRemotes(remotes = {}) {
|
|
|
52
55
|
const remoteEntryParts = remoteEntry.split('@');
|
|
53
56
|
const remoteName = remoteEntryParts[0];
|
|
54
57
|
const remoteEntryUrl = remoteEntryParts.slice(1).join('@');
|
|
55
|
-
remotesEntries.push(`{
|
|
56
|
-
alias:
|
|
57
|
-
name:
|
|
58
|
-
entry:
|
|
59
|
-
entryGlobalName:
|
|
60
|
-
type: "var"
|
|
58
|
+
remotesEntries.push(`{
|
|
59
|
+
alias: ${JSON.stringify(remoteAlias)},
|
|
60
|
+
name: ${JSON.stringify(remoteName)},
|
|
61
|
+
entry: ${JSON.stringify(remoteEntryUrl)},
|
|
62
|
+
entryGlobalName: ${JSON.stringify(remoteName)},
|
|
63
|
+
type: "var"
|
|
61
64
|
}`);
|
|
62
65
|
}
|
|
63
66
|
return `[${remotesEntries.join(',\n')}]`;
|
package/dist/plugin/helpers.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function removeExtension(filepath: string): string;
|
|
|
5
5
|
export declare function stubHostEntry(hostEntryPath: string): void;
|
|
6
6
|
export declare function stubRemoteEntry(remoteEntryPath: string): void;
|
|
7
7
|
export declare function prepareTmpDir(projectRootPath: string): string;
|
|
8
|
+
export declare function toPosixPath(value: string): string;
|