@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
|
@@ -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,9 +27,6 @@ var __webpack_require__ = {};
|
|
|
23
27
|
})();
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
normalizeExtraOptions: ()=>normalizeExtraOptions
|
|
28
|
-
});
|
|
29
30
|
function normalizeExtraOptions(extraOptions) {
|
|
30
31
|
return {
|
|
31
32
|
...extraOptions,
|
|
@@ -33,14 +34,17 @@ function normalizeExtraOptions(extraOptions) {
|
|
|
33
34
|
unstable_patchHMRClient: false,
|
|
34
35
|
unstable_patchInitializeCore: false,
|
|
35
36
|
unstable_patchRuntimeRequire: false,
|
|
36
|
-
...
|
|
37
|
+
...extraOptions?.flags
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
}
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
normalizeExtraOptions: ()=>normalizeExtraOptions
|
|
43
|
+
});
|
|
40
44
|
exports.normalizeExtraOptions = __webpack_exports__.normalizeExtraOptions;
|
|
41
|
-
for(var
|
|
45
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
42
46
|
"normalizeExtraOptions"
|
|
43
|
-
].indexOf(
|
|
47
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
48
|
Object.defineProperty(exports, '__esModule', {
|
|
45
49
|
value: true
|
|
46
50
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
function normalizeExtraOptions(extraOptions) {
|
|
4
3
|
return {
|
|
5
4
|
...extraOptions,
|
|
@@ -7,7 +6,7 @@ function normalizeExtraOptions(extraOptions) {
|
|
|
7
6
|
unstable_patchHMRClient: false,
|
|
8
7
|
unstable_patchInitializeCore: false,
|
|
9
8
|
unstable_patchRuntimeRequire: false,
|
|
10
|
-
...
|
|
9
|
+
...extraOptions?.flags
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
12
|
}
|
|
@@ -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', {
|
|
@@ -40,28 +44,47 @@ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node
|
|
|
40
44
|
const external_node_path_namespaceObject = require("node:path");
|
|
41
45
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
42
46
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
47
|
+
const external_helpers_js_namespaceObject = require("./helpers.js");
|
|
43
48
|
function normalizeOptions(options, { projectRoot, tmpDirPath }) {
|
|
44
49
|
const shared = getNormalizedShared(options, projectRoot);
|
|
50
|
+
const remotes = getNormalizedRemotes(options);
|
|
51
|
+
const exposes = getNormalizedExposes(options);
|
|
45
52
|
const shareStrategy = getNormalizedShareStrategy(options);
|
|
46
|
-
const plugins = getNormalizedPlugins(options, tmpDirPath);
|
|
53
|
+
const plugins = getNormalizedPlugins(options, tmpDirPath, projectRoot);
|
|
47
54
|
return {
|
|
48
55
|
name: options.name,
|
|
49
56
|
filename: options.filename ?? external_constants_js_namespaceObject.DEFAULT_ENTRY_FILENAME,
|
|
50
|
-
remotes
|
|
51
|
-
exposes
|
|
57
|
+
remotes,
|
|
58
|
+
exposes,
|
|
52
59
|
shared,
|
|
53
60
|
shareStrategy,
|
|
54
|
-
plugins
|
|
61
|
+
plugins,
|
|
62
|
+
dts: options.dts ?? false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function getNormalizedRemotes(options) {
|
|
66
|
+
return {
|
|
67
|
+
...options.remotes ?? {}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getNormalizedExposes(options) {
|
|
71
|
+
return {
|
|
72
|
+
...options.exposes ?? {}
|
|
55
73
|
};
|
|
56
74
|
}
|
|
57
75
|
function getNormalizedShared(options, projectRoot) {
|
|
58
76
|
const pkg = getProjectPackageJson(projectRoot);
|
|
59
|
-
const
|
|
77
|
+
const sharedInput = options.shared ?? {};
|
|
78
|
+
const shared = Object.entries(sharedInput).reduce((acc, [sharedName, config])=>{
|
|
79
|
+
if ('string' == typeof config) return acc;
|
|
80
|
+
const metroSharedConfig = {
|
|
81
|
+
...config
|
|
82
|
+
};
|
|
83
|
+
acc[sharedName] = metroSharedConfig;
|
|
84
|
+
return acc;
|
|
85
|
+
}, {});
|
|
60
86
|
if (!options.exposes) for (const sharedName of Object.keys(shared))shared[sharedName].eager = true;
|
|
61
|
-
for (const sharedName of Object.keys(shared))if (!shared[sharedName].requiredVersion)
|
|
62
|
-
var _pkg_dependencies, _pkg_devDependencies;
|
|
63
|
-
shared[sharedName].requiredVersion = (null == (_pkg_dependencies = pkg.dependencies) ? void 0 : _pkg_dependencies[sharedName]) || (null == (_pkg_devDependencies = pkg.devDependencies) ? void 0 : _pkg_devDependencies[sharedName]);
|
|
64
|
-
}
|
|
87
|
+
for (const sharedName of Object.keys(shared))if (!shared[sharedName].requiredVersion) shared[sharedName].requiredVersion = pkg.dependencies?.[sharedName] || pkg.devDependencies?.[sharedName];
|
|
65
88
|
if (!shared['react-native/Libraries/Network/RCTNetworking']) {
|
|
66
89
|
const reactNativeSharedConfig = shared['react-native'];
|
|
67
90
|
shared['react-native/Libraries/Network/RCTNetworking'] = reactNativeSharedConfig;
|
|
@@ -71,19 +94,46 @@ function getNormalizedShared(options, projectRoot) {
|
|
|
71
94
|
function getNormalizedShareStrategy(options) {
|
|
72
95
|
return options.shareStrategy ?? 'loaded-first';
|
|
73
96
|
}
|
|
74
|
-
function getNormalizedPlugins(options, tmpDirPath) {
|
|
97
|
+
function getNormalizedPlugins(options, tmpDirPath, projectRoot) {
|
|
98
|
+
const runtimePlugins = getNormalizedRuntimePlugins(options);
|
|
75
99
|
const plugins = options.plugins ?? [];
|
|
76
|
-
|
|
77
|
-
|
|
100
|
+
const allPlugins = [
|
|
101
|
+
require.resolve('../modules/metroCorePlugin.ts'),
|
|
102
|
+
...runtimePlugins,
|
|
103
|
+
...plugins
|
|
104
|
+
];
|
|
105
|
+
const deduplicatedPlugins = Array.from(new Set(allPlugins));
|
|
106
|
+
return deduplicatedPlugins.map((pluginPath)=>{
|
|
107
|
+
if (!isLocalPluginPath(pluginPath, projectRoot)) return pluginPath;
|
|
108
|
+
const resolvedPluginPath = external_node_path_default().isAbsolute(pluginPath) ? pluginPath : external_node_path_default().resolve(projectRoot, pluginPath);
|
|
109
|
+
return (0, external_helpers_js_namespaceObject.toPosixPath)(external_node_path_default().relative(tmpDirPath, resolvedPluginPath));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function isLocalPluginPath(pluginPath, projectRoot) {
|
|
113
|
+
if (external_node_path_default().isAbsolute(pluginPath)) return true;
|
|
114
|
+
if (pluginPath.startsWith('./') || pluginPath.startsWith('../')) return true;
|
|
115
|
+
return external_node_fs_default().existsSync(external_node_path_default().resolve(projectRoot, pluginPath));
|
|
116
|
+
}
|
|
117
|
+
function getNormalizedRuntimePlugins(options) {
|
|
118
|
+
const runtimePlugins = options.runtimePlugins ?? [];
|
|
119
|
+
const normalizedRuntimePlugins = [];
|
|
120
|
+
runtimePlugins.forEach((runtimePlugin)=>{
|
|
121
|
+
if ('string' == typeof runtimePlugin) return void normalizedRuntimePlugins.push(runtimePlugin);
|
|
122
|
+
if (Array.isArray(runtimePlugin)) {
|
|
123
|
+
const [pluginPath] = runtimePlugin;
|
|
124
|
+
if ('string' == typeof pluginPath) normalizedRuntimePlugins.push(pluginPath);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return normalizedRuntimePlugins;
|
|
78
128
|
}
|
|
79
129
|
function getProjectPackageJson(projectRoot) {
|
|
80
130
|
const packageJsonPath = external_node_path_default().join(projectRoot, 'package.json');
|
|
81
131
|
return JSON.parse(external_node_fs_default().readFileSync(packageJsonPath, 'utf-8'));
|
|
82
132
|
}
|
|
83
133
|
exports.normalizeOptions = __webpack_exports__.normalizeOptions;
|
|
84
|
-
for(var
|
|
134
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
135
|
"normalizeOptions"
|
|
86
|
-
].indexOf(
|
|
136
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
87
137
|
Object.defineProperty(exports, '__esModule', {
|
|
88
138
|
value: true
|
|
89
139
|
});
|
|
@@ -1,30 +1,49 @@
|
|
|
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
|
import { DEFAULT_ENTRY_FILENAME } from "./constants.mjs";
|
|
6
|
+
import { toPosixPath } from "./helpers.mjs";
|
|
6
7
|
function normalizeOptions(options, { projectRoot, tmpDirPath }) {
|
|
7
8
|
const shared = getNormalizedShared(options, projectRoot);
|
|
9
|
+
const remotes = getNormalizedRemotes(options);
|
|
10
|
+
const exposes = getNormalizedExposes(options);
|
|
8
11
|
const shareStrategy = getNormalizedShareStrategy(options);
|
|
9
|
-
const plugins = getNormalizedPlugins(options, tmpDirPath);
|
|
12
|
+
const plugins = getNormalizedPlugins(options, tmpDirPath, projectRoot);
|
|
10
13
|
return {
|
|
11
14
|
name: options.name,
|
|
12
15
|
filename: options.filename ?? DEFAULT_ENTRY_FILENAME,
|
|
13
|
-
remotes
|
|
14
|
-
exposes
|
|
16
|
+
remotes,
|
|
17
|
+
exposes,
|
|
15
18
|
shared,
|
|
16
19
|
shareStrategy,
|
|
17
|
-
plugins
|
|
20
|
+
plugins,
|
|
21
|
+
dts: options.dts ?? false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getNormalizedRemotes(options) {
|
|
25
|
+
return {
|
|
26
|
+
...options.remotes ?? {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getNormalizedExposes(options) {
|
|
30
|
+
return {
|
|
31
|
+
...options.exposes ?? {}
|
|
18
32
|
};
|
|
19
33
|
}
|
|
20
34
|
function getNormalizedShared(options, projectRoot) {
|
|
21
35
|
const pkg = getProjectPackageJson(projectRoot);
|
|
22
|
-
const
|
|
36
|
+
const sharedInput = options.shared ?? {};
|
|
37
|
+
const shared = Object.entries(sharedInput).reduce((acc, [sharedName, config])=>{
|
|
38
|
+
if ('string' == typeof config) return acc;
|
|
39
|
+
const metroSharedConfig = {
|
|
40
|
+
...config
|
|
41
|
+
};
|
|
42
|
+
acc[sharedName] = metroSharedConfig;
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
23
45
|
if (!options.exposes) for (const sharedName of Object.keys(shared))shared[sharedName].eager = true;
|
|
24
|
-
for (const sharedName of Object.keys(shared))if (!shared[sharedName].requiredVersion)
|
|
25
|
-
var _pkg_dependencies, _pkg_devDependencies;
|
|
26
|
-
shared[sharedName].requiredVersion = (null == (_pkg_dependencies = pkg.dependencies) ? void 0 : _pkg_dependencies[sharedName]) || (null == (_pkg_devDependencies = pkg.devDependencies) ? void 0 : _pkg_devDependencies[sharedName]);
|
|
27
|
-
}
|
|
46
|
+
for (const sharedName of Object.keys(shared))if (!shared[sharedName].requiredVersion) shared[sharedName].requiredVersion = pkg.dependencies?.[sharedName] || pkg.devDependencies?.[sharedName];
|
|
28
47
|
if (!shared['react-native/Libraries/Network/RCTNetworking']) {
|
|
29
48
|
const reactNativeSharedConfig = shared['react-native'];
|
|
30
49
|
shared['react-native/Libraries/Network/RCTNetworking'] = reactNativeSharedConfig;
|
|
@@ -34,10 +53,37 @@ function getNormalizedShared(options, projectRoot) {
|
|
|
34
53
|
function getNormalizedShareStrategy(options) {
|
|
35
54
|
return options.shareStrategy ?? 'loaded-first';
|
|
36
55
|
}
|
|
37
|
-
function getNormalizedPlugins(options, tmpDirPath) {
|
|
56
|
+
function getNormalizedPlugins(options, tmpDirPath, projectRoot) {
|
|
57
|
+
const runtimePlugins = getNormalizedRuntimePlugins(options);
|
|
38
58
|
const plugins = options.plugins ?? [];
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
const allPlugins = [
|
|
60
|
+
require.resolve('../modules/metroCorePlugin.ts'),
|
|
61
|
+
...runtimePlugins,
|
|
62
|
+
...plugins
|
|
63
|
+
];
|
|
64
|
+
const deduplicatedPlugins = Array.from(new Set(allPlugins));
|
|
65
|
+
return deduplicatedPlugins.map((pluginPath)=>{
|
|
66
|
+
if (!isLocalPluginPath(pluginPath, projectRoot)) return pluginPath;
|
|
67
|
+
const resolvedPluginPath = node_path.isAbsolute(pluginPath) ? pluginPath : node_path.resolve(projectRoot, pluginPath);
|
|
68
|
+
return toPosixPath(node_path.relative(tmpDirPath, resolvedPluginPath));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function isLocalPluginPath(pluginPath, projectRoot) {
|
|
72
|
+
if (node_path.isAbsolute(pluginPath)) return true;
|
|
73
|
+
if (pluginPath.startsWith('./') || pluginPath.startsWith('../')) return true;
|
|
74
|
+
return node_fs.existsSync(node_path.resolve(projectRoot, pluginPath));
|
|
75
|
+
}
|
|
76
|
+
function getNormalizedRuntimePlugins(options) {
|
|
77
|
+
const runtimePlugins = options.runtimePlugins ?? [];
|
|
78
|
+
const normalizedRuntimePlugins = [];
|
|
79
|
+
runtimePlugins.forEach((runtimePlugin)=>{
|
|
80
|
+
if ('string' == typeof runtimePlugin) return void normalizedRuntimePlugins.push(runtimePlugin);
|
|
81
|
+
if (Array.isArray(runtimePlugin)) {
|
|
82
|
+
const [pluginPath] = runtimePlugin;
|
|
83
|
+
if ('string' == typeof pluginPath) normalizedRuntimePlugins.push(pluginPath);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return normalizedRuntimePlugins;
|
|
41
87
|
}
|
|
42
88
|
function getProjectPackageJson(projectRoot) {
|
|
43
89
|
const packageJsonPath = node_path.join(projectRoot, 'package.json');
|
|
@@ -19,7 +19,7 @@ interface CreateResolveRequestOptions {
|
|
|
19
19
|
tmpDir: string;
|
|
20
20
|
};
|
|
21
21
|
options: ModuleFederationConfigNormalized;
|
|
22
|
-
vmManager: VirtualModuleManager
|
|
22
|
+
vmManager: Pick<VirtualModuleManager, 'registerVirtualModule'>;
|
|
23
23
|
customResolver?: CustomResolver;
|
|
24
24
|
}
|
|
25
25
|
export declare function createResolveRequest({ vmManager, options, hacks, paths, isRemote, customResolver, }: CreateResolveRequestOptions): CustomResolver;
|
package/dist/plugin/resolver.js
CHANGED
|
@@ -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', {
|
|
@@ -128,8 +132,8 @@ function createResolveRequest({ vmManager, options, hacks, paths, isRemote, cust
|
|
|
128
132
|
for (const sharedName of Object.keys(options.shared)){
|
|
129
133
|
const importName = options.shared[sharedName].import || sharedName;
|
|
130
134
|
if (moduleName === importName) {
|
|
131
|
-
const sharedPath = getSharedPath(
|
|
132
|
-
const sharedGenerator = ()=>(0, external_generators_js_namespaceObject.getRemoteModule)(
|
|
135
|
+
const sharedPath = getSharedPath(sharedName, paths.tmpDir);
|
|
136
|
+
const sharedGenerator = ()=>(0, external_generators_js_namespaceObject.getRemoteModule)(importName);
|
|
133
137
|
vmManager.registerVirtualModule(sharedPath, sharedGenerator);
|
|
134
138
|
return {
|
|
135
139
|
type: 'sourceFile',
|
|
@@ -173,7 +177,7 @@ function resolveModule(moduleName) {
|
|
|
173
177
|
}
|
|
174
178
|
function replaceModule(from, to) {
|
|
175
179
|
return (resolved)=>{
|
|
176
|
-
if ('sourceFile' === resolved.type && from.test(resolved.filePath)) {
|
|
180
|
+
if ('sourceFile' === resolved.type && from.test((0, external_helpers_js_namespaceObject.toPosixPath)(resolved.filePath))) {
|
|
177
181
|
if (null === to) return {
|
|
178
182
|
type: 'empty'
|
|
179
183
|
};
|
|
@@ -187,13 +191,13 @@ function replaceModule(from, to) {
|
|
|
187
191
|
}
|
|
188
192
|
function getEntryPathRegex(paths) {
|
|
189
193
|
const relativeEntryPath = external_node_path_default().relative(paths.projectDir, paths.entry);
|
|
190
|
-
const entryName = (0, external_helpers_js_namespaceObject.removeExtension)(relativeEntryPath);
|
|
194
|
+
const entryName = (0, external_helpers_js_namespaceObject.toPosixPath)((0, external_helpers_js_namespaceObject.removeExtension)(relativeEntryPath));
|
|
191
195
|
return new RegExp(`^\\./${entryName}(\\.js)?$`);
|
|
192
196
|
}
|
|
193
197
|
exports.createResolveRequest = __webpack_exports__.createResolveRequest;
|
|
194
|
-
for(var
|
|
198
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
195
199
|
"createResolveRequest"
|
|
196
|
-
].indexOf(
|
|
200
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
197
201
|
Object.defineProperty(exports, '__esModule', {
|
|
198
202
|
value: true
|
|
199
203
|
});
|
package/dist/plugin/resolver.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
4
|
-
import { dirname as __webpack_dirname__ } from "node:path";
|
|
1
|
+
import "node:module";
|
|
5
2
|
import node_path from "node:path";
|
|
6
3
|
import { ASYNC_REQUIRE, GET_DEV_SERVER_REGEX, HMR_CLIENT_REGEX, INIT_HOST, REMOTE_HMR_SETUP, REMOTE_MODULE_REGISTRY } from "./constants.mjs";
|
|
7
4
|
import { getHostEntryModule, getInitHostModule, getRemoteEntryModule, getRemoteHMRSetupModule, getRemoteModule, getRemoteModuleRegistryModule } from "./generators.mjs";
|
|
8
|
-
import { isUsingMFBundleCommand, removeExtension } from "./helpers.mjs";
|
|
9
|
-
|
|
5
|
+
import { isUsingMFBundleCommand, removeExtension, toPosixPath } from "./helpers.mjs";
|
|
6
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
7
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
8
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
10
9
|
function createResolveRequest({ vmManager, options, hacks, paths, isRemote, customResolver }) {
|
|
11
10
|
const hostEntryPathRegex = getEntryPathRegex({
|
|
12
11
|
entry: paths.hostEntry,
|
|
@@ -95,8 +94,8 @@ function createResolveRequest({ vmManager, options, hacks, paths, isRemote, cust
|
|
|
95
94
|
for (const sharedName of Object.keys(options.shared)){
|
|
96
95
|
const importName = options.shared[sharedName].import || sharedName;
|
|
97
96
|
if (moduleName === importName) {
|
|
98
|
-
const sharedPath = getSharedPath(
|
|
99
|
-
const sharedGenerator = ()=>getRemoteModule(
|
|
97
|
+
const sharedPath = getSharedPath(sharedName, paths.tmpDir);
|
|
98
|
+
const sharedGenerator = ()=>getRemoteModule(importName);
|
|
100
99
|
vmManager.registerVirtualModule(sharedPath, sharedGenerator);
|
|
101
100
|
return {
|
|
102
101
|
type: 'sourceFile',
|
|
@@ -136,11 +135,11 @@ function getRemoteModulePath(name, dir) {
|
|
|
136
135
|
return node_path.join(remoteModuleDir, `${remoteModuleName}.js`);
|
|
137
136
|
}
|
|
138
137
|
function resolveModule(moduleName) {
|
|
139
|
-
return node_path.resolve(
|
|
138
|
+
return node_path.resolve(__rspack_import_meta_dirname__, `../modules/${moduleName}`);
|
|
140
139
|
}
|
|
141
140
|
function replaceModule(from, to) {
|
|
142
141
|
return (resolved)=>{
|
|
143
|
-
if ('sourceFile' === resolved.type && from.test(resolved.filePath)) {
|
|
142
|
+
if ('sourceFile' === resolved.type && from.test(toPosixPath(resolved.filePath))) {
|
|
144
143
|
if (null === to) return {
|
|
145
144
|
type: 'empty'
|
|
146
145
|
};
|
|
@@ -154,7 +153,7 @@ function replaceModule(from, to) {
|
|
|
154
153
|
}
|
|
155
154
|
function getEntryPathRegex(paths) {
|
|
156
155
|
const relativeEntryPath = node_path.relative(paths.projectDir, paths.entry);
|
|
157
|
-
const entryName = removeExtension(relativeEntryPath);
|
|
156
|
+
const entryName = toPosixPath(removeExtension(relativeEntryPath));
|
|
158
157
|
return new RegExp(`^\\./${entryName}(\\.js)?$`);
|
|
159
158
|
}
|
|
160
159
|
export { createResolveRequest };
|
|
@@ -5,6 +5,10 @@ type CreateRewriteRequestOptions = {
|
|
|
5
5
|
remoteEntryFilename: string;
|
|
6
6
|
manifestPath: string;
|
|
7
7
|
tmpDirPath: string;
|
|
8
|
+
getDtsAssetNames?: () => {
|
|
9
|
+
zipName?: string;
|
|
10
|
+
apiFileName?: string;
|
|
11
|
+
};
|
|
8
12
|
};
|
|
9
|
-
export declare function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath, }: CreateRewriteRequestOptions): (url: string) => string;
|
|
13
|
+
export declare function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath, getDtsAssetNames, }: CreateRewriteRequestOptions): (url: string) => string;
|
|
10
14
|
export {};
|
|
@@ -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', {
|
|
@@ -39,7 +43,7 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
39
43
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
44
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
41
45
|
const external_helpers_js_namespaceObject = require("./helpers.js");
|
|
42
|
-
function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath }) {
|
|
46
|
+
function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath, getDtsAssetNames }) {
|
|
43
47
|
const hostEntryName = (0, external_helpers_js_namespaceObject.removeExtension)(originalEntryFilename);
|
|
44
48
|
const remoteEntryName = (0, external_helpers_js_namespaceObject.removeExtension)(remoteEntryFilename);
|
|
45
49
|
const relativeTmpDirPath = external_node_path_default().relative(config.projectRoot, tmpDirPath).split(external_node_path_default().sep).join(external_node_path_default().posix.sep);
|
|
@@ -57,9 +61,18 @@ function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilena
|
|
|
57
61
|
return url.replace(remoteEntryName, target);
|
|
58
62
|
}
|
|
59
63
|
if (pathname.startsWith(`/${external_constants_js_namespaceObject.MANIFEST_FILENAME}`)) {
|
|
60
|
-
const target = manifestPath.replace(root, '[metro-project]');
|
|
64
|
+
const target = (0, external_helpers_js_namespaceObject.toPosixPath)(manifestPath.replace(root, '[metro-project]'));
|
|
61
65
|
return url.replace(external_constants_js_namespaceObject.MANIFEST_FILENAME, target);
|
|
62
66
|
}
|
|
67
|
+
const dtsAssets = getDtsAssetNames?.();
|
|
68
|
+
const dtsAssetName = [
|
|
69
|
+
dtsAssets?.zipName,
|
|
70
|
+
dtsAssets?.apiFileName
|
|
71
|
+
].filter((value)=>Boolean(value)).find((value)=>pathname === `/${value}`);
|
|
72
|
+
if (dtsAssetName) {
|
|
73
|
+
const target = `${relativeTmpDirPath}/${dtsAssetName}`;
|
|
74
|
+
return url.replace(dtsAssetName, target);
|
|
75
|
+
}
|
|
63
76
|
if (config.server.rewriteRequestUrl) return config.server.rewriteRequestUrl(url);
|
|
64
77
|
return url;
|
|
65
78
|
};
|
|
@@ -68,9 +81,9 @@ function getEntryPathRegex(entryFilename) {
|
|
|
68
81
|
return new RegExp(`^\\/${entryFilename}(\\.js)?(\\.bundle)$`);
|
|
69
82
|
}
|
|
70
83
|
exports.createRewriteRequest = __webpack_exports__.createRewriteRequest;
|
|
71
|
-
for(var
|
|
84
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
72
85
|
"createRewriteRequest"
|
|
73
|
-
].indexOf(
|
|
86
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
74
87
|
Object.defineProperty(exports, '__esModule', {
|
|
75
88
|
value: true
|
|
76
89
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import node_path from "node:path";
|
|
4
3
|
import { MANIFEST_FILENAME } from "./constants.mjs";
|
|
5
|
-
import { removeExtension } from "./helpers.mjs";
|
|
6
|
-
function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath }) {
|
|
4
|
+
import { removeExtension, toPosixPath } from "./helpers.mjs";
|
|
5
|
+
function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilename, manifestPath, tmpDirPath, getDtsAssetNames }) {
|
|
7
6
|
const hostEntryName = removeExtension(originalEntryFilename);
|
|
8
7
|
const remoteEntryName = removeExtension(remoteEntryFilename);
|
|
9
8
|
const relativeTmpDirPath = node_path.relative(config.projectRoot, tmpDirPath).split(node_path.sep).join(node_path.posix.sep);
|
|
@@ -21,9 +20,18 @@ function createRewriteRequest({ config, originalEntryFilename, remoteEntryFilena
|
|
|
21
20
|
return url.replace(remoteEntryName, target);
|
|
22
21
|
}
|
|
23
22
|
if (pathname.startsWith(`/${MANIFEST_FILENAME}`)) {
|
|
24
|
-
const target = manifestPath.replace(root, '[metro-project]');
|
|
23
|
+
const target = toPosixPath(manifestPath.replace(root, '[metro-project]'));
|
|
25
24
|
return url.replace(MANIFEST_FILENAME, target);
|
|
26
25
|
}
|
|
26
|
+
const dtsAssets = getDtsAssetNames?.();
|
|
27
|
+
const dtsAssetName = [
|
|
28
|
+
dtsAssets?.zipName,
|
|
29
|
+
dtsAssets?.apiFileName
|
|
30
|
+
].filter((value)=>Boolean(value)).find((value)=>pathname === `/${value}`);
|
|
31
|
+
if (dtsAssetName) {
|
|
32
|
+
const target = `${relativeTmpDirPath}/${dtsAssetName}`;
|
|
33
|
+
return url.replace(dtsAssetName, target);
|
|
34
|
+
}
|
|
27
35
|
if (config.server.rewriteRequestUrl) return config.server.rewriteRequestUrl(url);
|
|
28
36
|
return url;
|
|
29
37
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SerializerConfigT } from 'metro-config';
|
|
2
2
|
import type { ModuleFederationConfigNormalized } from '../types';
|
|
3
|
+
import { type ManifestGenerationOptions } from './manifest';
|
|
3
4
|
type CustomSerializer = SerializerConfigT['customSerializer'];
|
|
4
|
-
export declare function getModuleFederationSerializer(mfConfig: ModuleFederationConfigNormalized, isUsingMFBundleCommand: boolean): CustomSerializer;
|
|
5
|
+
export declare function getModuleFederationSerializer(mfConfig: ModuleFederationConfigNormalized, isUsingMFBundleCommand: boolean, manifestPath?: string, manifestOptions?: ManifestGenerationOptions): CustomSerializer;
|
|
5
6
|
export {};
|