@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.
Files changed (100) hide show
  1. package/babel-plugin/patch-initialize-core.js +3 -3
  2. package/babel-plugin/patch-require.js +3 -3
  3. package/dist/babel/transformer.js +1 -1
  4. package/dist/commands/bundle-host/index.js +17 -12
  5. package/dist/commands/bundle-host/index.mjs +8 -30
  6. package/dist/commands/bundle-host/options.js +12 -8
  7. package/dist/commands/bundle-host/options.mjs +2 -3
  8. package/dist/commands/bundle-host/types.js +2 -2
  9. package/dist/commands/bundle-host/types.mjs +1 -2
  10. package/dist/commands/bundle-remote/index.js +34 -19
  11. package/dist/commands/bundle-remote/index.mjs +28 -38
  12. package/dist/commands/bundle-remote/options.js +15 -11
  13. package/dist/commands/bundle-remote/options.mjs +4 -5
  14. package/dist/commands/bundle-remote/types.js +2 -2
  15. package/dist/commands/bundle-remote/types.mjs +1 -2
  16. package/dist/commands/index.js +14 -10
  17. package/dist/commands/index.mjs +3 -3
  18. package/dist/commands/types.js +2 -2
  19. package/dist/commands/types.mjs +1 -2
  20. package/dist/commands/utils/create-module-path-remapper.js +15 -11
  21. package/dist/commands/utils/create-module-path-remapper.mjs +1 -2
  22. package/dist/commands/utils/create-resolver.d.ts +1 -1
  23. package/dist/commands/utils/create-resolver.js +15 -11
  24. package/dist/commands/utils/create-resolver.mjs +1 -2
  25. package/dist/commands/utils/get-community-plugin.d.ts +1 -2
  26. package/dist/commands/utils/get-community-plugin.js +15 -12
  27. package/dist/commands/utils/get-community-plugin.mjs +5 -6
  28. package/dist/commands/utils/load-metro-config.js +15 -14
  29. package/dist/commands/utils/load-metro-config.mjs +9 -11
  30. package/dist/commands/utils/path-utils.d.ts +2 -0
  31. package/dist/commands/utils/path-utils.js +51 -0
  32. package/dist/commands/utils/path-utils.mjs +11 -0
  33. package/dist/commands/utils/save-bundle-and-map.d.ts +1 -1
  34. package/dist/commands/utils/save-bundle-and-map.js +14 -11
  35. package/dist/commands/utils/save-bundle-and-map.mjs +3 -27
  36. package/dist/index.js +14 -10
  37. package/dist/index.mjs +3 -5
  38. package/dist/logger.d.ts +2 -0
  39. package/dist/logger.js +43 -0
  40. package/dist/logger.mjs +6 -0
  41. package/dist/modules/asyncRequire.ts +41 -10
  42. package/dist/modules/metroCorePlugin.ts +2 -3
  43. package/dist/plugin/babel-transformer.js +13 -9
  44. package/dist/plugin/babel-transformer.mjs +3 -3
  45. package/dist/plugin/constants.d.ts +1 -0
  46. package/dist/plugin/constants.js +27 -19
  47. package/dist/plugin/constants.mjs +3 -3
  48. package/dist/plugin/generators.js +28 -21
  49. package/dist/plugin/generators.mjs +14 -11
  50. package/dist/plugin/helpers.d.ts +1 -0
  51. package/dist/plugin/helpers.js +28 -20
  52. package/dist/plugin/helpers.mjs +9 -9
  53. package/dist/plugin/index.d.ts +2 -0
  54. package/dist/plugin/index.js +64 -13
  55. package/dist/plugin/index.mjs +54 -7
  56. package/dist/plugin/manifest-middleware.d.ts +12 -0
  57. package/dist/plugin/manifest-middleware.js +217 -0
  58. package/dist/plugin/manifest-middleware.mjs +170 -0
  59. package/dist/plugin/manifest.d.ts +15 -2
  60. package/dist/plugin/manifest.js +126 -26
  61. package/dist/plugin/manifest.mjs +107 -22
  62. package/dist/plugin/normalize-extra-options.js +16 -12
  63. package/dist/plugin/normalize-extra-options.mjs +2 -3
  64. package/dist/plugin/normalize-options.js +70 -20
  65. package/dist/plugin/normalize-options.mjs +60 -14
  66. package/dist/plugin/resolver.d.ts +1 -1
  67. package/dist/plugin/resolver.js +16 -12
  68. package/dist/plugin/resolver.mjs +10 -11
  69. package/dist/plugin/rewrite-request.d.ts +5 -1
  70. package/dist/plugin/rewrite-request.js +23 -10
  71. package/dist/plugin/rewrite-request.mjs +13 -5
  72. package/dist/plugin/serializer.d.ts +2 -1
  73. package/dist/plugin/serializer.js +59 -39
  74. package/dist/plugin/serializer.mjs +48 -55
  75. package/dist/plugin/validate-options.js +116 -12
  76. package/dist/plugin/validate-options.mjs +95 -7
  77. package/dist/types.d.ts +15 -15
  78. package/dist/types.js +2 -2
  79. package/dist/types.mjs +1 -2
  80. package/dist/utils/errors.js +16 -12
  81. package/dist/utils/errors.mjs +1 -2
  82. package/dist/utils/federated-remote-types.d.ts +12 -0
  83. package/dist/utils/federated-remote-types.js +140 -0
  84. package/dist/utils/federated-remote-types.mjs +90 -0
  85. package/dist/utils/index.js +14 -10
  86. package/dist/utils/index.mjs +3 -5
  87. package/dist/utils/metro-compat.d.ts +23 -0
  88. package/dist/utils/metro-compat.js +74 -0
  89. package/dist/utils/metro-compat.mjs +26 -0
  90. package/dist/utils/vm-manager.d.ts +1 -1
  91. package/dist/utils/vm-manager.js +14 -12
  92. package/dist/utils/vm-manager.mjs +3 -6
  93. package/package.json +22 -7
  94. package/dist/babel/transformer.d.ts +0 -2
  95. package/dist/runtime/host-entry.d.ts +0 -1
  96. package/dist/runtime/init-host.d.ts +0 -1
  97. package/dist/runtime/remote-entry.d.ts +0 -1
  98. package/dist/runtime/remote-hmr.d.ts +0 -1
  99. package/dist/runtime/remote-module-registry.d.ts +0 -7
  100. package/dist/runtime/remote-module.d.ts +0 -1
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
10
10
  };
11
11
  })();
12
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
- });
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 ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
30
  value: 'Module'
27
31
  });
28
32
  Object.defineProperty(exports1, '__esModule', {
@@ -37,37 +41,41 @@ __webpack_require__.d(__webpack_exports__, {
37
41
  });
38
42
  const external_node_path_namespaceObject = require("node:path");
39
43
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
40
- const baseJSBundle_namespaceObject = require("metro/src/DeltaBundler/Serializers/baseJSBundle");
41
- var baseJSBundle_default = /*#__PURE__*/ __webpack_require__.n(baseJSBundle_namespaceObject);
42
- const CountingSet_namespaceObject = require("metro/src/lib/CountingSet");
43
- var CountingSet_default = /*#__PURE__*/ __webpack_require__.n(CountingSet_namespaceObject);
44
- const bundleToString_namespaceObject = require("metro/src/lib/bundleToString");
45
- var bundleToString_default = /*#__PURE__*/ __webpack_require__.n(bundleToString_namespaceObject);
46
44
  const errors_js_namespaceObject = require("../utils/errors.js");
47
- function getModuleFederationSerializer(mfConfig, isUsingMFBundleCommand) {
45
+ const external_helpers_js_namespaceObject = require("./helpers.js");
46
+ const external_manifest_js_namespaceObject = require("./manifest.js");
47
+ const metro_compat_js_namespaceObject = require("../utils/metro-compat.js");
48
+ function getModuleFederationSerializer(mfConfig, isUsingMFBundleCommand, manifestPath, manifestOptions) {
49
+ const bundleHashes = new Map();
48
50
  return async (entryPoint, preModules, graph, options)=>{
49
51
  const syncRemoteModules = collectSyncRemoteModules(graph, mfConfig.remotes);
50
52
  const syncSharedModules = collectSyncSharedModules(graph, mfConfig.shared);
53
+ let code;
51
54
  if (true === options.runModule) {
52
55
  const finalPreModules = [
53
56
  getEarlyShared(syncSharedModules),
54
57
  getEarlyRemotes(syncRemoteModules),
55
58
  ...preModules
56
59
  ];
57
- return getBundleCode(entryPoint, finalPreModules, graph, options);
60
+ code = getBundleCode(entryPoint, finalPreModules, graph, options);
61
+ } else if (isProjectSource(entryPoint, options.projectRoot)) {
62
+ const bundlePath = getBundlePath(entryPoint, options.projectRoot, mfConfig.exposes, isUsingMFBundleCommand);
63
+ const finalPreModules = [
64
+ getSyncShared(syncSharedModules, bundlePath, mfConfig.name),
65
+ getSyncRemotes(syncRemoteModules, bundlePath, mfConfig.name)
66
+ ];
67
+ if (false === options.modulesOnly) finalPreModules.push(...preModules);
68
+ const finalOptions = {
69
+ ...options,
70
+ modulesOnly: false
71
+ };
72
+ code = getBundleCode(entryPoint, finalPreModules, graph, finalOptions);
73
+ } else code = getBundleCode(entryPoint, preModules, graph, options);
74
+ if (manifestPath) {
75
+ (0, external_manifest_js_namespaceObject.recordBundleHash)(bundleHashes, code, entryPoint, options.projectRoot, mfConfig);
76
+ (0, external_manifest_js_namespaceObject.updateManifest)(manifestPath, mfConfig, bundleHashes, manifestOptions);
58
77
  }
59
- if (!isProjectSource(entryPoint, options.projectRoot)) return getBundleCode(entryPoint, preModules, graph, options);
60
- const bundlePath = getBundlePath(entryPoint, options.projectRoot, mfConfig.exposes, isUsingMFBundleCommand);
61
- const finalPreModules = [
62
- getSyncShared(syncSharedModules, bundlePath, mfConfig.name),
63
- getSyncRemotes(syncRemoteModules, bundlePath, mfConfig.name)
64
- ];
65
- if (false === options.modulesOnly) finalPreModules.push(...preModules);
66
- const finalOptions = {
67
- ...options,
68
- modulesOnly: false
69
- };
70
- return getBundleCode(entryPoint, finalPreModules, graph, finalOptions);
78
+ return code;
71
79
  };
72
80
  }
73
81
  function collectSyncRemoteModules(graph, _remotes) {
@@ -122,7 +130,7 @@ function generateVirtualModule(name, code) {
122
130
  return {
123
131
  dependencies: new Map(),
124
132
  getSource: ()=>Buffer.from(code),
125
- inverseDependencies: new (CountingSet_default())(),
133
+ inverseDependencies: new metro_compat_js_namespaceObject.CountingSet(),
126
134
  path: name,
127
135
  output: [
128
136
  {
@@ -142,15 +150,15 @@ function isProjectSource(entryPoint, projectRoot) {
142
150
  }
143
151
  function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand) {
144
152
  const relativeEntryPath = external_node_path_default().relative(projectRoot, entryPoint);
145
- if (!isUsingMFBundleCommand) {
146
- const { dir, name } = external_node_path_default().parse(relativeEntryPath);
147
- return external_node_path_default().format({
148
- dir,
149
- name,
150
- ext: ''
151
- });
152
- }
153
- const exposedMatchedKey = Object.keys(exposes).find((exposeKey)=>exposes[exposeKey].match(relativeEntryPath));
153
+ const normalizedRelativeEntryPath = normalizeEntryPath(relativeEntryPath);
154
+ if (!isUsingMFBundleCommand) return removePathExtension(normalizedRelativeEntryPath);
155
+ const exposeEntries = Object.entries(exposes).map(([exposeKey, exposePath])=>({
156
+ exposeKey,
157
+ normalizedExposePath: normalizeEntryPath(exposePath)
158
+ }));
159
+ const exactMatch = exposeEntries.find(({ normalizedExposePath })=>normalizedExposePath === normalizedRelativeEntryPath);
160
+ const extensionlessMatch = exposeEntries.find(({ normalizedExposePath })=>removePathExtension(normalizedExposePath) === removePathExtension(normalizedRelativeEntryPath));
161
+ const exposedMatchedKey = exactMatch?.exposeKey ?? extensionlessMatch?.exposeKey;
154
162
  if (exposedMatchedKey) {
155
163
  let exposedName = exposedMatchedKey;
156
164
  if (exposedName.startsWith('./')) exposedName = exposedName.slice(2);
@@ -158,14 +166,26 @@ function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand)
158
166
  }
159
167
  throw new errors_js_namespaceObject.ConfigError(`Unable to handle entry point: ${relativeEntryPath}. Expected to match an entrypoint with one of the exposed keys, but failed. This is most likely a configuration error. If you believe this is not a configuration issue, please report it as a bug. Debug info: entryPoint="${entryPoint}", projectRoot="${projectRoot}", exposesKeys=[${Object.keys(exposes).join(', ')}]`);
160
168
  }
169
+ function normalizeEntryPath(value) {
170
+ const normalized = (0, external_helpers_js_namespaceObject.toPosixPath)(external_node_path_default().normalize(value));
171
+ return normalized.startsWith('./') ? normalized.slice(2) : normalized;
172
+ }
173
+ function removePathExtension(value) {
174
+ const parsed = external_node_path_default().posix.parse(value);
175
+ return external_node_path_default().posix.format({
176
+ dir: parsed.dir,
177
+ name: parsed.name,
178
+ ext: ''
179
+ });
180
+ }
161
181
  function getBundleCode(entryPoint, preModules, graph, options) {
162
- const { code } = bundleToString_default()(baseJSBundle_default()(entryPoint, preModules, graph, options));
182
+ const { code } = (0, metro_compat_js_namespaceObject.bundleToString)((0, metro_compat_js_namespaceObject.baseJSBundle)(entryPoint, preModules, graph, options));
163
183
  return code;
164
184
  }
165
185
  exports.getModuleFederationSerializer = __webpack_exports__.getModuleFederationSerializer;
166
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
186
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
167
187
  "getModuleFederationSerializer"
168
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
188
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
169
189
  Object.defineProperty(exports, '__esModule', {
170
190
  value: true
171
191
  });
@@ -1,59 +1,40 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  import node_path from "node:path";
4
3
  import { ConfigError } from "../utils/errors.mjs";
5
- import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "node:module";
6
- var __webpack_require__ = {};
7
- (()=>{
8
- __webpack_require__.n = (module)=>{
9
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
10
- __webpack_require__.d(getter, {
11
- a: getter
12
- });
13
- return getter;
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.d = (exports, definition)=>{
18
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
19
- enumerable: true,
20
- get: definition[key]
21
- });
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- const baseJSBundle_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("metro/src/DeltaBundler/Serializers/baseJSBundle");
28
- var baseJSBundle_default = /*#__PURE__*/ __webpack_require__.n(baseJSBundle_namespaceObject);
29
- const CountingSet_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("metro/src/lib/CountingSet");
30
- var CountingSet_default = /*#__PURE__*/ __webpack_require__.n(CountingSet_namespaceObject);
31
- const bundleToString_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("metro/src/lib/bundleToString");
32
- var bundleToString_default = /*#__PURE__*/ __webpack_require__.n(bundleToString_namespaceObject);
33
- function getModuleFederationSerializer(mfConfig, isUsingMFBundleCommand) {
4
+ import { toPosixPath } from "./helpers.mjs";
5
+ import { recordBundleHash, updateManifest } from "./manifest.mjs";
6
+ import { CountingSet, baseJSBundle, bundleToString } from "../utils/metro-compat.mjs";
7
+ function getModuleFederationSerializer(mfConfig, isUsingMFBundleCommand, manifestPath, manifestOptions) {
8
+ const bundleHashes = new Map();
34
9
  return async (entryPoint, preModules, graph, options)=>{
35
10
  const syncRemoteModules = collectSyncRemoteModules(graph, mfConfig.remotes);
36
11
  const syncSharedModules = collectSyncSharedModules(graph, mfConfig.shared);
12
+ let code;
37
13
  if (true === options.runModule) {
38
14
  const finalPreModules = [
39
15
  getEarlyShared(syncSharedModules),
40
16
  getEarlyRemotes(syncRemoteModules),
41
17
  ...preModules
42
18
  ];
43
- return getBundleCode(entryPoint, finalPreModules, graph, options);
19
+ code = getBundleCode(entryPoint, finalPreModules, graph, options);
20
+ } else if (isProjectSource(entryPoint, options.projectRoot)) {
21
+ const bundlePath = getBundlePath(entryPoint, options.projectRoot, mfConfig.exposes, isUsingMFBundleCommand);
22
+ const finalPreModules = [
23
+ getSyncShared(syncSharedModules, bundlePath, mfConfig.name),
24
+ getSyncRemotes(syncRemoteModules, bundlePath, mfConfig.name)
25
+ ];
26
+ if (false === options.modulesOnly) finalPreModules.push(...preModules);
27
+ const finalOptions = {
28
+ ...options,
29
+ modulesOnly: false
30
+ };
31
+ code = getBundleCode(entryPoint, finalPreModules, graph, finalOptions);
32
+ } else code = getBundleCode(entryPoint, preModules, graph, options);
33
+ if (manifestPath) {
34
+ recordBundleHash(bundleHashes, code, entryPoint, options.projectRoot, mfConfig);
35
+ updateManifest(manifestPath, mfConfig, bundleHashes, manifestOptions);
44
36
  }
45
- if (!isProjectSource(entryPoint, options.projectRoot)) return getBundleCode(entryPoint, preModules, graph, options);
46
- const bundlePath = getBundlePath(entryPoint, options.projectRoot, mfConfig.exposes, isUsingMFBundleCommand);
47
- const finalPreModules = [
48
- getSyncShared(syncSharedModules, bundlePath, mfConfig.name),
49
- getSyncRemotes(syncRemoteModules, bundlePath, mfConfig.name)
50
- ];
51
- if (false === options.modulesOnly) finalPreModules.push(...preModules);
52
- const finalOptions = {
53
- ...options,
54
- modulesOnly: false
55
- };
56
- return getBundleCode(entryPoint, finalPreModules, graph, finalOptions);
37
+ return code;
57
38
  };
58
39
  }
59
40
  function collectSyncRemoteModules(graph, _remotes) {
@@ -108,7 +89,7 @@ function generateVirtualModule(name, code) {
108
89
  return {
109
90
  dependencies: new Map(),
110
91
  getSource: ()=>Buffer.from(code),
111
- inverseDependencies: new (CountingSet_default())(),
92
+ inverseDependencies: new CountingSet(),
112
93
  path: name,
113
94
  output: [
114
95
  {
@@ -128,15 +109,15 @@ function isProjectSource(entryPoint, projectRoot) {
128
109
  }
129
110
  function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand) {
130
111
  const relativeEntryPath = node_path.relative(projectRoot, entryPoint);
131
- if (!isUsingMFBundleCommand) {
132
- const { dir, name } = node_path.parse(relativeEntryPath);
133
- return node_path.format({
134
- dir,
135
- name,
136
- ext: ''
137
- });
138
- }
139
- const exposedMatchedKey = Object.keys(exposes).find((exposeKey)=>exposes[exposeKey].match(relativeEntryPath));
112
+ const normalizedRelativeEntryPath = normalizeEntryPath(relativeEntryPath);
113
+ if (!isUsingMFBundleCommand) return removePathExtension(normalizedRelativeEntryPath);
114
+ const exposeEntries = Object.entries(exposes).map(([exposeKey, exposePath])=>({
115
+ exposeKey,
116
+ normalizedExposePath: normalizeEntryPath(exposePath)
117
+ }));
118
+ const exactMatch = exposeEntries.find(({ normalizedExposePath })=>normalizedExposePath === normalizedRelativeEntryPath);
119
+ const extensionlessMatch = exposeEntries.find(({ normalizedExposePath })=>removePathExtension(normalizedExposePath) === removePathExtension(normalizedRelativeEntryPath));
120
+ const exposedMatchedKey = exactMatch?.exposeKey ?? extensionlessMatch?.exposeKey;
140
121
  if (exposedMatchedKey) {
141
122
  let exposedName = exposedMatchedKey;
142
123
  if (exposedName.startsWith('./')) exposedName = exposedName.slice(2);
@@ -144,8 +125,20 @@ function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand)
144
125
  }
145
126
  throw new ConfigError(`Unable to handle entry point: ${relativeEntryPath}. Expected to match an entrypoint with one of the exposed keys, but failed. This is most likely a configuration error. If you believe this is not a configuration issue, please report it as a bug. Debug info: entryPoint="${entryPoint}", projectRoot="${projectRoot}", exposesKeys=[${Object.keys(exposes).join(', ')}]`);
146
127
  }
128
+ function normalizeEntryPath(value) {
129
+ const normalized = toPosixPath(node_path.normalize(value));
130
+ return normalized.startsWith('./') ? normalized.slice(2) : normalized;
131
+ }
132
+ function removePathExtension(value) {
133
+ const parsed = node_path.posix.parse(value);
134
+ return node_path.posix.format({
135
+ dir: parsed.dir,
136
+ name: parsed.name,
137
+ ext: ''
138
+ });
139
+ }
147
140
  function getBundleCode(entryPoint, preModules, graph, options) {
148
- const { code } = bundleToString_default()(baseJSBundle_default()(entryPoint, preModules, graph, options));
141
+ const { code } = bundleToString(baseJSBundle(entryPoint, preModules, graph, options));
149
142
  return code;
150
143
  }
151
144
  export { getModuleFederationSerializer };
@@ -1,11 +1,24 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
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]
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
8
  });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
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");
9
22
  };
10
23
  })();
11
24
  (()=>{
@@ -13,7 +26,7 @@ var __webpack_require__ = {};
13
26
  })();
14
27
  (()=>{
15
28
  __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
30
  value: 'Module'
18
31
  });
19
32
  Object.defineProperty(exports1, '__esModule', {
@@ -26,8 +39,40 @@ __webpack_require__.r(__webpack_exports__);
26
39
  __webpack_require__.d(__webpack_exports__, {
27
40
  validateOptions: ()=>validateOptions
28
41
  });
42
+ const external_node_path_namespaceObject = require("node:path");
43
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
44
+ const external_logger_js_namespaceObject = require("../logger.js");
45
+ var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
29
46
  const index_js_namespaceObject = require("../utils/index.js");
47
+ const unsupportedTopLevelOptions = [
48
+ 'library',
49
+ 'remoteType',
50
+ 'runtime',
51
+ 'shareScope',
52
+ 'getPublicPath',
53
+ 'implementation',
54
+ 'manifest',
55
+ 'dev',
56
+ 'virtualRuntimeEntry',
57
+ 'experiments',
58
+ 'bridge',
59
+ 'async',
60
+ 'treeShakingDir',
61
+ 'injectTreeShakingUsedExports',
62
+ 'treeShakingSharedExcludePlugins',
63
+ 'treeShakingSharedPlugins'
64
+ ];
65
+ const unsupportedSharedFields = [
66
+ 'packageName',
67
+ 'shareKey',
68
+ 'shareScope',
69
+ 'strictVersion',
70
+ 'treeShaking',
71
+ 'shareStrategy'
72
+ ];
73
+ const warningSet = new Set();
30
74
  function validateName(name) {
75
+ if (!name || 'string' != typeof name) throw new index_js_namespaceObject.ConfigError("Option 'name' is required.");
31
76
  const validEcmaIdentifierRegex = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u;
32
77
  if (!validEcmaIdentifierRegex.test(name)) throw new index_js_namespaceObject.ConfigError(`Invalid 'name': ${name}. The 'name' must be a valid JavaScript identifier.`);
33
78
  }
@@ -39,23 +84,82 @@ function validateShared(shared) {
39
84
  if (!shared) throw new index_js_namespaceObject.ConfigError('Shared configuration is required.');
40
85
  if ('object' != typeof shared) throw new index_js_namespaceObject.ConfigError('Shared must be an object.');
41
86
  if (Array.isArray(shared)) throw new index_js_namespaceObject.ConfigError('Array format is not supported for shared.');
42
- if (!('react' in shared)) throw new index_js_namespaceObject.ConfigError("Dependency 'react' must be present in shared.");
43
- if (!('react-native' in shared)) throw new index_js_namespaceObject.ConfigError("Dependency 'react-native' must be present in shared.");
44
- for (const sharedName of Object.keys(shared)){
45
- if (sharedName.startsWith('./') || sharedName.startsWith('../')) throw new index_js_namespaceObject.ConfigError('Relative paths are not supported as shared module names.');
46
- if (sharedName.startsWith('/')) throw new index_js_namespaceObject.ConfigError('Absolute paths are not supported as shared module names.');
87
+ if (!isPlainObject(shared)) throw new index_js_namespaceObject.ConfigError('Shared must be an object.');
88
+ const sharedObject = shared;
89
+ if (!('react' in sharedObject)) throw new index_js_namespaceObject.ConfigError("Dependency 'react' must be present in shared.");
90
+ if (!('react-native' in sharedObject)) throw new index_js_namespaceObject.ConfigError("Dependency 'react-native' must be present in shared.");
91
+ for (const sharedName of Object.keys(sharedObject)){
92
+ const sharedConfig = sharedObject[sharedName];
93
+ if (isRelativePathLike(sharedName)) throw new index_js_namespaceObject.ConfigError('Relative paths are not supported as shared module names.');
94
+ if (isAbsolutePathLike(sharedName)) throw new index_js_namespaceObject.ConfigError('Absolute paths are not supported as shared module names.');
47
95
  if (sharedName.endsWith('/')) throw new index_js_namespaceObject.ConfigError("Deep import wildcards are not supported as shared module names. You need to list all deep imports explicitly.");
96
+ if (!isPlainObject(sharedConfig)) throw new index_js_namespaceObject.ConfigError(`Unsupported shared format for '${sharedName}'. Metro only supports object notation for shared modules.`);
97
+ if ('import' in sharedConfig && false !== sharedConfig.import && 'string' != typeof sharedConfig.import) throw new index_js_namespaceObject.ConfigError(`Unsupported shared.import value for '${sharedName}'. Only string and false are supported in Metro.`);
98
+ for (const unsupportedField of unsupportedSharedFields)if (unsupportedField in sharedConfig) warnUnsupported(`shared.${sharedName}.${unsupportedField}`, `Option 'shared.${sharedName}.${unsupportedField}' is not supported in Metro and will have no effect.`);
48
99
  }
49
100
  }
101
+ function validateRemotes(remotes) {
102
+ if (void 0 === remotes) return;
103
+ if (!isPlainObject(remotes)) throw new index_js_namespaceObject.ConfigError('Unsupported remotes format. Metro only supports remotes as Record<string, string>.');
104
+ for (const remoteConfig of Object.values(remotes))if ('string' != typeof remoteConfig) throw new index_js_namespaceObject.ConfigError('Unsupported remotes format. Metro only supports remotes as Record<string, string>.');
105
+ }
106
+ function validateExposes(exposes) {
107
+ if (void 0 === exposes) return;
108
+ if (!isPlainObject(exposes)) throw new index_js_namespaceObject.ConfigError('Unsupported exposes format. Metro only supports exposes as Record<string, string>.');
109
+ for (const exposeConfig of Object.values(exposes))if ('string' != typeof exposeConfig) throw new index_js_namespaceObject.ConfigError('Unsupported exposes format. Metro only supports exposes as Record<string, string>.');
110
+ }
111
+ function validateRuntimePlugins(runtimePlugins) {
112
+ if (void 0 === runtimePlugins) return;
113
+ if (!Array.isArray(runtimePlugins)) throw new index_js_namespaceObject.ConfigError('runtimePlugins must be an array.');
114
+ runtimePlugins.forEach((runtimePlugin, index)=>{
115
+ if ('string' == typeof runtimePlugin) return;
116
+ if (!Array.isArray(runtimePlugin)) throw new index_js_namespaceObject.ConfigError('runtimePlugins entries must be either a string or a tuple of [path, params].');
117
+ const [pluginPath, pluginParams] = runtimePlugin;
118
+ if ('string' != typeof pluginPath) throw new index_js_namespaceObject.ConfigError(`Invalid runtimePlugins[${index}] path. Expected a string path.`);
119
+ if (void 0 !== pluginParams) warnUnsupported(`runtimePlugins[${index}][1]`, `Option 'runtimePlugins[${index}][1]' is not supported in Metro and will have no effect.`);
120
+ });
121
+ }
122
+ function validateDts(dts) {
123
+ if (void 0 === dts || 'boolean' == typeof dts) return;
124
+ if (!isPlainObject(dts)) throw new index_js_namespaceObject.ConfigError("Option 'dts' must be a boolean or a plain object.");
125
+ }
126
+ function validateUnsupportedTopLevelOptions(options) {
127
+ unsupportedTopLevelOptions.forEach((unsupportedOption)=>{
128
+ if (void 0 !== options[unsupportedOption]) warnUnsupported(String(unsupportedOption), `Option '${String(unsupportedOption)}' is not supported in Metro and will have no effect.`);
129
+ });
130
+ }
131
+ function validateDeprecatedOptions(options) {
132
+ if (options.plugins && options.plugins.length > 0) warnUnsupported('deprecated.plugins', "The 'plugins' option is deprecated. Use 'runtimePlugins' instead. Support for 'plugins' will be removed in the next major version.");
133
+ }
134
+ function warnUnsupported(key, message) {
135
+ if (warningSet.has(key)) return;
136
+ warningSet.add(key);
137
+ external_logger_js_default().warn(message);
138
+ }
139
+ function isPlainObject(value) {
140
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
141
+ }
142
+ function isRelativePathLike(value) {
143
+ return /^\.{1,2}[\\/]/.test(value);
144
+ }
145
+ function isAbsolutePathLike(value) {
146
+ return external_node_path_default().posix.isAbsolute(value) || external_node_path_default().win32.isAbsolute(value);
147
+ }
50
148
  function validateOptions(options) {
149
+ validateUnsupportedTopLevelOptions(options);
150
+ validateDeprecatedOptions(options);
51
151
  validateName(options.name);
52
152
  validateFilename(options.filename);
153
+ validateRemotes(options.remotes);
154
+ validateExposes(options.exposes);
155
+ validateRuntimePlugins(options.runtimePlugins);
156
+ validateDts(options.dts);
53
157
  validateShared(options.shared);
54
158
  }
55
159
  exports.validateOptions = __webpack_exports__.validateOptions;
56
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
160
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
57
161
  "validateOptions"
58
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
162
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
59
163
  Object.defineProperty(exports, '__esModule', {
60
164
  value: true
61
165
  });
@@ -1,7 +1,36 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import logger from "../logger.mjs";
3
4
  import { ConfigError } from "../utils/index.mjs";
5
+ const unsupportedTopLevelOptions = [
6
+ 'library',
7
+ 'remoteType',
8
+ 'runtime',
9
+ 'shareScope',
10
+ 'getPublicPath',
11
+ 'implementation',
12
+ 'manifest',
13
+ 'dev',
14
+ 'virtualRuntimeEntry',
15
+ 'experiments',
16
+ 'bridge',
17
+ 'async',
18
+ 'treeShakingDir',
19
+ 'injectTreeShakingUsedExports',
20
+ 'treeShakingSharedExcludePlugins',
21
+ 'treeShakingSharedPlugins'
22
+ ];
23
+ const unsupportedSharedFields = [
24
+ 'packageName',
25
+ 'shareKey',
26
+ 'shareScope',
27
+ 'strictVersion',
28
+ 'treeShaking',
29
+ 'shareStrategy'
30
+ ];
31
+ const warningSet = new Set();
4
32
  function validateName(name) {
33
+ if (!name || 'string' != typeof name) throw new ConfigError("Option 'name' is required.");
5
34
  const validEcmaIdentifierRegex = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u;
6
35
  if (!validEcmaIdentifierRegex.test(name)) throw new ConfigError(`Invalid 'name': ${name}. The 'name' must be a valid JavaScript identifier.`);
7
36
  }
@@ -13,17 +42,76 @@ function validateShared(shared) {
13
42
  if (!shared) throw new ConfigError('Shared configuration is required.');
14
43
  if ('object' != typeof shared) throw new ConfigError('Shared must be an object.');
15
44
  if (Array.isArray(shared)) throw new ConfigError('Array format is not supported for shared.');
16
- if (!('react' in shared)) throw new ConfigError("Dependency 'react' must be present in shared.");
17
- if (!('react-native' in shared)) throw new ConfigError("Dependency 'react-native' must be present in shared.");
18
- for (const sharedName of Object.keys(shared)){
19
- if (sharedName.startsWith('./') || sharedName.startsWith('../')) throw new ConfigError('Relative paths are not supported as shared module names.');
20
- if (sharedName.startsWith('/')) throw new ConfigError('Absolute paths are not supported as shared module names.');
45
+ if (!isPlainObject(shared)) throw new ConfigError('Shared must be an object.');
46
+ const sharedObject = shared;
47
+ if (!('react' in sharedObject)) throw new ConfigError("Dependency 'react' must be present in shared.");
48
+ if (!('react-native' in sharedObject)) throw new ConfigError("Dependency 'react-native' must be present in shared.");
49
+ for (const sharedName of Object.keys(sharedObject)){
50
+ const sharedConfig = sharedObject[sharedName];
51
+ if (isRelativePathLike(sharedName)) throw new ConfigError('Relative paths are not supported as shared module names.');
52
+ if (isAbsolutePathLike(sharedName)) throw new ConfigError('Absolute paths are not supported as shared module names.');
21
53
  if (sharedName.endsWith('/')) throw new ConfigError("Deep import wildcards are not supported as shared module names. You need to list all deep imports explicitly.");
54
+ if (!isPlainObject(sharedConfig)) throw new ConfigError(`Unsupported shared format for '${sharedName}'. Metro only supports object notation for shared modules.`);
55
+ if ('import' in sharedConfig && false !== sharedConfig.import && 'string' != typeof sharedConfig.import) throw new ConfigError(`Unsupported shared.import value for '${sharedName}'. Only string and false are supported in Metro.`);
56
+ for (const unsupportedField of unsupportedSharedFields)if (unsupportedField in sharedConfig) warnUnsupported(`shared.${sharedName}.${unsupportedField}`, `Option 'shared.${sharedName}.${unsupportedField}' is not supported in Metro and will have no effect.`);
22
57
  }
23
58
  }
59
+ function validateRemotes(remotes) {
60
+ if (void 0 === remotes) return;
61
+ if (!isPlainObject(remotes)) throw new ConfigError('Unsupported remotes format. Metro only supports remotes as Record<string, string>.');
62
+ for (const remoteConfig of Object.values(remotes))if ('string' != typeof remoteConfig) throw new ConfigError('Unsupported remotes format. Metro only supports remotes as Record<string, string>.');
63
+ }
64
+ function validateExposes(exposes) {
65
+ if (void 0 === exposes) return;
66
+ if (!isPlainObject(exposes)) throw new ConfigError('Unsupported exposes format. Metro only supports exposes as Record<string, string>.');
67
+ for (const exposeConfig of Object.values(exposes))if ('string' != typeof exposeConfig) throw new ConfigError('Unsupported exposes format. Metro only supports exposes as Record<string, string>.');
68
+ }
69
+ function validateRuntimePlugins(runtimePlugins) {
70
+ if (void 0 === runtimePlugins) return;
71
+ if (!Array.isArray(runtimePlugins)) throw new ConfigError('runtimePlugins must be an array.');
72
+ runtimePlugins.forEach((runtimePlugin, index)=>{
73
+ if ('string' == typeof runtimePlugin) return;
74
+ if (!Array.isArray(runtimePlugin)) throw new ConfigError('runtimePlugins entries must be either a string or a tuple of [path, params].');
75
+ const [pluginPath, pluginParams] = runtimePlugin;
76
+ if ('string' != typeof pluginPath) throw new ConfigError(`Invalid runtimePlugins[${index}] path. Expected a string path.`);
77
+ if (void 0 !== pluginParams) warnUnsupported(`runtimePlugins[${index}][1]`, `Option 'runtimePlugins[${index}][1]' is not supported in Metro and will have no effect.`);
78
+ });
79
+ }
80
+ function validateDts(dts) {
81
+ if (void 0 === dts || 'boolean' == typeof dts) return;
82
+ if (!isPlainObject(dts)) throw new ConfigError("Option 'dts' must be a boolean or a plain object.");
83
+ }
84
+ function validateUnsupportedTopLevelOptions(options) {
85
+ unsupportedTopLevelOptions.forEach((unsupportedOption)=>{
86
+ if (void 0 !== options[unsupportedOption]) warnUnsupported(String(unsupportedOption), `Option '${String(unsupportedOption)}' is not supported in Metro and will have no effect.`);
87
+ });
88
+ }
89
+ function validateDeprecatedOptions(options) {
90
+ if (options.plugins && options.plugins.length > 0) warnUnsupported('deprecated.plugins', "The 'plugins' option is deprecated. Use 'runtimePlugins' instead. Support for 'plugins' will be removed in the next major version.");
91
+ }
92
+ function warnUnsupported(key, message) {
93
+ if (warningSet.has(key)) return;
94
+ warningSet.add(key);
95
+ logger.warn(message);
96
+ }
97
+ function isPlainObject(value) {
98
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
99
+ }
100
+ function isRelativePathLike(value) {
101
+ return /^\.{1,2}[\\/]/.test(value);
102
+ }
103
+ function isAbsolutePathLike(value) {
104
+ return node_path.posix.isAbsolute(value) || node_path.win32.isAbsolute(value);
105
+ }
24
106
  function validateOptions(options) {
107
+ validateUnsupportedTopLevelOptions(options);
108
+ validateDeprecatedOptions(options);
25
109
  validateName(options.name);
26
110
  validateFilename(options.filename);
111
+ validateRemotes(options.remotes);
112
+ validateExposes(options.exposes);
113
+ validateRuntimePlugins(options.runtimePlugins);
114
+ validateDts(options.dts);
27
115
  validateShared(options.shared);
28
116
  }
29
117
  export { validateOptions };
package/dist/types.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- export interface SharedConfig {
2
- singleton: boolean;
3
- eager: boolean;
4
- version: string;
5
- requiredVersion: string;
6
- import?: false;
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ export interface ModuleFederationConfig extends moduleFederationPlugin.ModuleFederationPluginOptions {
3
+ /**
4
+ * @deprecated Use runtimePlugins instead. Scheduled for removal in the next major version.
5
+ */
6
+ plugins?: string[];
7
7
  }
8
- export type Shared = Record<string, SharedConfig>;
9
- export interface ModuleFederationConfig {
8
+ export type ShareObject = Record<string, moduleFederationPlugin.SharedConfig>;
9
+ export interface ModuleFederationConfigNormalized {
10
10
  name: string;
11
- filename?: string;
12
- remotes?: Record<string, string>;
13
- exposes?: Record<string, string>;
14
- shared?: Shared;
15
- shareStrategy?: 'loaded-first' | 'version-first';
16
- plugins?: string[];
11
+ filename: string;
12
+ remotes: Record<string, string>;
13
+ exposes: Record<string, string>;
14
+ shared: ShareObject;
15
+ shareStrategy: moduleFederationPlugin.SharedStrategy;
16
+ plugins: string[];
17
+ dts: boolean | moduleFederationPlugin.PluginDtsOptions;
17
18
  }
18
- export type ModuleFederationConfigNormalized = Required<ModuleFederationConfig>;
19
19
  export type ModuleFederationExtraOptions = {
20
20
  flags?: MetroMFFlags;
21
21
  };
package/dist/types.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
4
  __webpack_require__.r = (exports1)=>{
5
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
6
  value: 'Module'
7
7
  });
8
8
  Object.defineProperty(exports1, '__esModule', {
@@ -12,7 +12,7 @@ var __webpack_require__ = {};
12
12
  })();
13
13
  var __webpack_exports__ = {};
14
14
  __webpack_require__.r(__webpack_exports__);
15
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
16
  Object.defineProperty(exports, '__esModule', {
17
17
  value: true
18
18
  });
package/dist/types.mjs CHANGED
@@ -1,2 +1 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";