@module-federation/metro 0.0.0-next-20250827124348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/babel-plugin/index.js +115 -0
  4. package/babel-plugin/patch-initialize-core.js +61 -0
  5. package/babel-plugin/patch-require.js +174 -0
  6. package/bootstrap/index.d.ts +1 -0
  7. package/bootstrap/index.js +1 -0
  8. package/dist/babel/transformer.d.ts +2 -0
  9. package/dist/babel/transformer.js +15 -0
  10. package/dist/commands/bundle-host/index.d.ts +13 -0
  11. package/dist/commands/bundle-host/index.js +95 -0
  12. package/dist/commands/bundle-host/index.mjs +69 -0
  13. package/dist/commands/bundle-host/options.d.ts +5 -0
  14. package/dist/commands/bundle-host/options.js +39 -0
  15. package/dist/commands/bundle-host/options.mjs +7 -0
  16. package/dist/commands/bundle-host/types.d.ts +22 -0
  17. package/dist/commands/bundle-host/types.js +18 -0
  18. package/dist/commands/bundle-host/types.mjs +2 -0
  19. package/dist/commands/bundle-remote/index.d.ts +12 -0
  20. package/dist/commands/bundle-remote/index.js +226 -0
  21. package/dist/commands/bundle-remote/index.mjs +200 -0
  22. package/dist/commands/bundle-remote/options.d.ts +32 -0
  23. package/dist/commands/bundle-remote/options.js +109 -0
  24. package/dist/commands/bundle-remote/options.mjs +67 -0
  25. package/dist/commands/bundle-remote/types.d.ts +16 -0
  26. package/dist/commands/bundle-remote/types.js +18 -0
  27. package/dist/commands/bundle-remote/types.mjs +2 -0
  28. package/dist/commands/index.d.ts +48 -0
  29. package/dist/commands/index.js +72 -0
  30. package/dist/commands/index.mjs +13 -0
  31. package/dist/commands/types.d.ts +14 -0
  32. package/dist/commands/types.js +18 -0
  33. package/dist/commands/types.mjs +2 -0
  34. package/dist/commands/utils/create-module-path-remapper.d.ts +7 -0
  35. package/dist/commands/utils/create-module-path-remapper.js +64 -0
  36. package/dist/commands/utils/create-module-path-remapper.mjs +32 -0
  37. package/dist/commands/utils/create-resolver.d.ts +20 -0
  38. package/dist/commands/utils/create-resolver.js +57 -0
  39. package/dist/commands/utils/create-resolver.mjs +25 -0
  40. package/dist/commands/utils/get-community-plugin.d.ts +29 -0
  41. package/dist/commands/utils/get-community-plugin.js +50 -0
  42. package/dist/commands/utils/get-community-plugin.mjs +18 -0
  43. package/dist/commands/utils/load-metro-config.d.ts +3 -0
  44. package/dist/commands/utils/load-metro-config.js +84 -0
  45. package/dist/commands/utils/load-metro-config.mjs +43 -0
  46. package/dist/commands/utils/save-bundle-and-map.d.ts +5 -0
  47. package/dist/commands/utils/save-bundle-and-map.js +77 -0
  48. package/dist/commands/utils/save-bundle-and-map.mjs +57 -0
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.js +40 -0
  51. package/dist/index.mjs +5 -0
  52. package/dist/modules/HMRClient.ts +31 -0
  53. package/dist/modules/HMRClientShim.ts +1 -0
  54. package/dist/modules/asyncRequire.ts +134 -0
  55. package/dist/modules/asyncStartup.tsx +38 -0
  56. package/dist/modules/getDevServer.ts +15 -0
  57. package/dist/modules/metroCorePlugin.ts +83 -0
  58. package/dist/plugin/babel-transformer.d.ts +11 -0
  59. package/dist/plugin/babel-transformer.js +68 -0
  60. package/dist/plugin/babel-transformer.mjs +25 -0
  61. package/dist/plugin/constants.d.ts +9 -0
  62. package/dist/plugin/constants.js +68 -0
  63. package/dist/plugin/constants.mjs +12 -0
  64. package/dist/plugin/generators.d.ts +13 -0
  65. package/dist/plugin/generators.js +157 -0
  66. package/dist/plugin/generators.mjs +99 -0
  67. package/dist/plugin/helpers.d.ts +7 -0
  68. package/dist/plugin/helpers.js +119 -0
  69. package/dist/plugin/helpers.mjs +58 -0
  70. package/dist/plugin/index.d.ts +9 -0
  71. package/dist/plugin/index.js +167 -0
  72. package/dist/plugin/index.mjs +124 -0
  73. package/dist/plugin/manifest.d.ts +3 -0
  74. package/dist/plugin/manifest.js +146 -0
  75. package/dist/plugin/manifest.mjs +100 -0
  76. package/dist/plugin/normalize-extra-options.d.ts +8 -0
  77. package/dist/plugin/normalize-extra-options.js +46 -0
  78. package/dist/plugin/normalize-extra-options.mjs +14 -0
  79. package/dist/plugin/normalize-options.d.ts +7 -0
  80. package/dist/plugin/normalize-options.js +89 -0
  81. package/dist/plugin/normalize-options.mjs +46 -0
  82. package/dist/plugin/resolver.d.ts +25 -0
  83. package/dist/plugin/resolver.js +199 -0
  84. package/dist/plugin/resolver.mjs +160 -0
  85. package/dist/plugin/rewrite-request.d.ts +10 -0
  86. package/dist/plugin/rewrite-request.js +76 -0
  87. package/dist/plugin/rewrite-request.mjs +34 -0
  88. package/dist/plugin/serializer.d.ts +5 -0
  89. package/dist/plugin/serializer.js +171 -0
  90. package/dist/plugin/serializer.mjs +151 -0
  91. package/dist/plugin/validate-options.d.ts +2 -0
  92. package/dist/plugin/validate-options.js +61 -0
  93. package/dist/plugin/validate-options.mjs +29 -0
  94. package/dist/runtime/host-entry.d.ts +1 -0
  95. package/dist/runtime/host-entry.js +3 -0
  96. package/dist/runtime/init-host.d.ts +1 -0
  97. package/dist/runtime/init-host.js +31 -0
  98. package/dist/runtime/remote-entry.d.ts +1 -0
  99. package/dist/runtime/remote-entry.js +57 -0
  100. package/dist/runtime/remote-hmr.d.ts +1 -0
  101. package/dist/runtime/remote-hmr.js +19 -0
  102. package/dist/runtime/remote-module-registry.d.ts +7 -0
  103. package/dist/runtime/remote-module-registry.js +57 -0
  104. package/dist/runtime/remote-module.d.ts +1 -0
  105. package/dist/runtime/remote-module.js +2 -0
  106. package/dist/types.d.ts +26 -0
  107. package/dist/types.js +18 -0
  108. package/dist/types.mjs +2 -0
  109. package/dist/utils/errors.d.ts +8 -0
  110. package/dist/utils/errors.js +50 -0
  111. package/dist/utils/errors.mjs +15 -0
  112. package/dist/utils/index.d.ts +2 -0
  113. package/dist/utils/index.js +43 -0
  114. package/dist/utils/index.mjs +5 -0
  115. package/dist/utils/vm-manager.d.ts +21 -0
  116. package/dist/utils/vm-manager.js +116 -0
  117. package/dist/utils/vm-manager.mjs +73 -0
  118. package/package.json +91 -0
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ withModuleFederation: ()=>withModuleFederation
37
+ });
38
+ const external_node_path_namespaceObject = require("node:path");
39
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
40
+ const external_node_util_namespaceObject = require("node:util");
41
+ var external_node_util_default = /*#__PURE__*/ __webpack_require__.n(external_node_util_namespaceObject);
42
+ const index_js_namespaceObject = require("../utils/index.js");
43
+ const external_babel_transformer_js_namespaceObject = require("./babel-transformer.js");
44
+ const external_helpers_js_namespaceObject = require("./helpers.js");
45
+ const external_manifest_js_namespaceObject = require("./manifest.js");
46
+ const external_normalize_extra_options_js_namespaceObject = require("./normalize-extra-options.js");
47
+ const external_normalize_options_js_namespaceObject = require("./normalize-options.js");
48
+ const external_resolver_js_namespaceObject = require("./resolver.js");
49
+ const external_rewrite_request_js_namespaceObject = require("./rewrite-request.js");
50
+ const external_serializer_js_namespaceObject = require("./serializer.js");
51
+ const external_validate_options_js_namespaceObject = require("./validate-options.js");
52
+ function withModuleFederation(config, federationOptions, extraOptions) {
53
+ if ((0, external_helpers_js_namespaceObject.isUsingMFCommand)()) return augmentConfig(config, federationOptions, extraOptions);
54
+ console.warn(external_node_util_default().styleText('yellow', 'Warning: Module Federation build is disabled for this command.\n') + external_node_util_default().styleText('yellow', 'To enable Module Federation, please use one of the dedicated bundle commands:\n') + ` ${external_node_util_default().styleText('dim', "\u2022")} bundle-mf-host` + external_node_util_default().styleText('dim', ' - for bundling a host application\n') + ` ${external_node_util_default().styleText('dim', "\u2022")} bundle-mf-remote` + external_node_util_default().styleText('dim', ' - for bundling a remote application\n'));
55
+ return config;
56
+ }
57
+ function augmentConfig(config, federationOptions, extraOptions) {
58
+ const isHost = !federationOptions.exposes;
59
+ const isRemote = !isHost;
60
+ const tmpDirPath = (0, external_helpers_js_namespaceObject.prepareTmpDir)(config.projectRoot);
61
+ (0, external_validate_options_js_namespaceObject.validateOptions)(federationOptions);
62
+ const options = (0, external_normalize_options_js_namespaceObject.normalizeOptions)(federationOptions, {
63
+ projectRoot: config.projectRoot,
64
+ tmpDirPath
65
+ });
66
+ const { flags } = (0, external_normalize_extra_options_js_namespaceObject.normalizeExtraOptions)(extraOptions);
67
+ const vmManager = new index_js_namespaceObject.VirtualModuleManager(config);
68
+ const { originalEntryFilename, originalEntryPath } = getOriginalEntry(config.projectRoot, 'index.js');
69
+ const hostEntryFilename = originalEntryFilename;
70
+ const hostEntryPath = external_node_path_default().resolve(tmpDirPath, hostEntryFilename);
71
+ const remoteEntryFilename = (0, external_helpers_js_namespaceObject.replaceExtension)(options.filename, '.js');
72
+ const remoteEntryPath = external_node_path_default().resolve(tmpDirPath, remoteEntryFilename);
73
+ const initHostPath = external_node_path_default().resolve(tmpDirPath, 'init-host.js');
74
+ const remoteHMRSetupPath = external_node_path_default().resolve(tmpDirPath, 'remote-hmr.js');
75
+ const remoteModuleRegistryPath = external_node_path_default().resolve(tmpDirPath, 'remote-module-registry.js');
76
+ const asyncRequirePath = require.resolve('../modules/asyncRequire.ts');
77
+ const babelTransformerPath = (0, external_babel_transformer_js_namespaceObject.createBabelTransformer)({
78
+ blacklistedPaths: [
79
+ initHostPath,
80
+ remoteEntryPath
81
+ ],
82
+ federationConfig: options,
83
+ originalBabelTransformerPath: config.transformer.babelTransformerPath,
84
+ tmpDirPath: tmpDirPath,
85
+ enableInitializeCorePatching: flags.unstable_patchInitializeCore,
86
+ enableRuntimeRequirePatching: flags.unstable_patchRuntimeRequire
87
+ });
88
+ const manifestPath = (0, external_manifest_js_namespaceObject.createManifest)(options, tmpDirPath);
89
+ (0, external_helpers_js_namespaceObject.stubHostEntry)(hostEntryPath);
90
+ (0, external_helpers_js_namespaceObject.stubRemoteEntry)(remoteEntryPath);
91
+ global.__METRO_FEDERATION_CONFIG = options;
92
+ global.__METRO_FEDERATION_HOST_ENTRY_PATH = hostEntryPath;
93
+ global.__METRO_FEDERATION_REMOTE_ENTRY_PATH = remoteEntryPath;
94
+ global.__METRO_FEDERATION_MANIFEST_PATH = manifestPath;
95
+ return {
96
+ ...config,
97
+ serializer: {
98
+ ...config.serializer,
99
+ customSerializer: (0, external_serializer_js_namespaceObject.getModuleFederationSerializer)(options, (0, external_helpers_js_namespaceObject.isUsingMFBundleCommand)()),
100
+ getModulesRunBeforeMainModule: (entryFilePath)=>{
101
+ if (flags.unstable_patchInitializeCore) return config.serializer.getModulesRunBeforeMainModule(entryFilePath);
102
+ if (isRemote) return [];
103
+ return [
104
+ initHostPath,
105
+ ...config.serializer.getModulesRunBeforeMainModule(entryFilePath)
106
+ ];
107
+ },
108
+ getRunModuleStatement: (moduleId)=>`${options.name}__r(${JSON.stringify(moduleId)});`,
109
+ getPolyfills: (options)=>isHost ? config.serializer.getPolyfills(options) : []
110
+ },
111
+ transformer: {
112
+ ...config.transformer,
113
+ globalPrefix: options.name,
114
+ babelTransformerPath: babelTransformerPath,
115
+ getTransformOptions: vmManager.getTransformOptions()
116
+ },
117
+ resolver: {
118
+ ...config.resolver,
119
+ resolveRequest: (0, external_resolver_js_namespaceObject.createResolveRequest)({
120
+ isRemote,
121
+ vmManager,
122
+ options,
123
+ paths: {
124
+ asyncRequire: asyncRequirePath,
125
+ originalEntry: originalEntryPath,
126
+ hostEntry: hostEntryPath,
127
+ initHost: initHostPath,
128
+ remoteModuleRegistry: remoteModuleRegistryPath,
129
+ remoteHMRSetup: remoteHMRSetupPath,
130
+ remoteEntry: remoteEntryPath,
131
+ projectDir: config.projectRoot,
132
+ tmpDir: tmpDirPath
133
+ },
134
+ hacks: {
135
+ patchHMRClient: flags.unstable_patchHMRClient,
136
+ patchInitializeCore: flags.unstable_patchInitializeCore
137
+ }
138
+ })
139
+ },
140
+ server: {
141
+ ...config.server,
142
+ enhanceMiddleware: vmManager.getMiddleware(),
143
+ rewriteRequestUrl: (0, external_rewrite_request_js_namespaceObject.createRewriteRequest)({
144
+ config,
145
+ originalEntryFilename,
146
+ remoteEntryFilename,
147
+ manifestPath,
148
+ tmpDirPath
149
+ })
150
+ }
151
+ };
152
+ }
153
+ function getOriginalEntry(projectRoot, entryFilename) {
154
+ const originalEntryFilename = external_node_path_default().basename(global.__METRO_FEDERATION_ORIGINAL_ENTRY_PATH ?? entryFilename);
155
+ const originalEntryPath = external_node_path_default().resolve(projectRoot, global.__METRO_FEDERATION_ORIGINAL_ENTRY_PATH ?? entryFilename);
156
+ return {
157
+ originalEntryFilename,
158
+ originalEntryPath
159
+ };
160
+ }
161
+ exports.withModuleFederation = __webpack_exports__.withModuleFederation;
162
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
163
+ "withModuleFederation"
164
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
165
+ Object.defineProperty(exports, '__esModule', {
166
+ value: true
167
+ });
@@ -0,0 +1,124 @@
1
+ import __rslib_shim_module__ from 'module';
2
+ const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
3
+ import node_path from "node:path";
4
+ import node_util from "node:util";
5
+ import { VirtualModuleManager } from "../utils/index.mjs";
6
+ import { createBabelTransformer } from "./babel-transformer.mjs";
7
+ import { isUsingMFBundleCommand, isUsingMFCommand, prepareTmpDir, replaceExtension, stubHostEntry, stubRemoteEntry } from "./helpers.mjs";
8
+ import { createManifest } from "./manifest.mjs";
9
+ import { normalizeExtraOptions } from "./normalize-extra-options.mjs";
10
+ import { normalizeOptions } from "./normalize-options.mjs";
11
+ import { createResolveRequest } from "./resolver.mjs";
12
+ import { createRewriteRequest } from "./rewrite-request.mjs";
13
+ import { getModuleFederationSerializer } from "./serializer.mjs";
14
+ import { validateOptions } from "./validate-options.mjs";
15
+ function withModuleFederation(config, federationOptions, extraOptions) {
16
+ if (isUsingMFCommand()) return augmentConfig(config, federationOptions, extraOptions);
17
+ console.warn(node_util.styleText('yellow', 'Warning: Module Federation build is disabled for this command.\n') + node_util.styleText('yellow', 'To enable Module Federation, please use one of the dedicated bundle commands:\n') + ` ${node_util.styleText('dim', "\u2022")} bundle-mf-host` + node_util.styleText('dim', ' - for bundling a host application\n') + ` ${node_util.styleText('dim', "\u2022")} bundle-mf-remote` + node_util.styleText('dim', ' - for bundling a remote application\n'));
18
+ return config;
19
+ }
20
+ function augmentConfig(config, federationOptions, extraOptions) {
21
+ const isHost = !federationOptions.exposes;
22
+ const isRemote = !isHost;
23
+ const tmpDirPath = prepareTmpDir(config.projectRoot);
24
+ validateOptions(federationOptions);
25
+ const options = normalizeOptions(federationOptions, {
26
+ projectRoot: config.projectRoot,
27
+ tmpDirPath
28
+ });
29
+ const { flags } = normalizeExtraOptions(extraOptions);
30
+ const vmManager = new VirtualModuleManager(config);
31
+ const { originalEntryFilename, originalEntryPath } = getOriginalEntry(config.projectRoot, 'index.js');
32
+ const hostEntryFilename = originalEntryFilename;
33
+ const hostEntryPath = node_path.resolve(tmpDirPath, hostEntryFilename);
34
+ const remoteEntryFilename = replaceExtension(options.filename, '.js');
35
+ const remoteEntryPath = node_path.resolve(tmpDirPath, remoteEntryFilename);
36
+ const initHostPath = node_path.resolve(tmpDirPath, 'init-host.js');
37
+ const remoteHMRSetupPath = node_path.resolve(tmpDirPath, 'remote-hmr.js');
38
+ const remoteModuleRegistryPath = node_path.resolve(tmpDirPath, 'remote-module-registry.js');
39
+ const asyncRequirePath = require.resolve('../modules/asyncRequire.ts');
40
+ const babelTransformerPath = createBabelTransformer({
41
+ blacklistedPaths: [
42
+ initHostPath,
43
+ remoteEntryPath
44
+ ],
45
+ federationConfig: options,
46
+ originalBabelTransformerPath: config.transformer.babelTransformerPath,
47
+ tmpDirPath: tmpDirPath,
48
+ enableInitializeCorePatching: flags.unstable_patchInitializeCore,
49
+ enableRuntimeRequirePatching: flags.unstable_patchRuntimeRequire
50
+ });
51
+ const manifestPath = createManifest(options, tmpDirPath);
52
+ stubHostEntry(hostEntryPath);
53
+ stubRemoteEntry(remoteEntryPath);
54
+ global.__METRO_FEDERATION_CONFIG = options;
55
+ global.__METRO_FEDERATION_HOST_ENTRY_PATH = hostEntryPath;
56
+ global.__METRO_FEDERATION_REMOTE_ENTRY_PATH = remoteEntryPath;
57
+ global.__METRO_FEDERATION_MANIFEST_PATH = manifestPath;
58
+ return {
59
+ ...config,
60
+ serializer: {
61
+ ...config.serializer,
62
+ customSerializer: getModuleFederationSerializer(options, isUsingMFBundleCommand()),
63
+ getModulesRunBeforeMainModule: (entryFilePath)=>{
64
+ if (flags.unstable_patchInitializeCore) return config.serializer.getModulesRunBeforeMainModule(entryFilePath);
65
+ if (isRemote) return [];
66
+ return [
67
+ initHostPath,
68
+ ...config.serializer.getModulesRunBeforeMainModule(entryFilePath)
69
+ ];
70
+ },
71
+ getRunModuleStatement: (moduleId)=>`${options.name}__r(${JSON.stringify(moduleId)});`,
72
+ getPolyfills: (options)=>isHost ? config.serializer.getPolyfills(options) : []
73
+ },
74
+ transformer: {
75
+ ...config.transformer,
76
+ globalPrefix: options.name,
77
+ babelTransformerPath: babelTransformerPath,
78
+ getTransformOptions: vmManager.getTransformOptions()
79
+ },
80
+ resolver: {
81
+ ...config.resolver,
82
+ resolveRequest: createResolveRequest({
83
+ isRemote,
84
+ vmManager,
85
+ options,
86
+ paths: {
87
+ asyncRequire: asyncRequirePath,
88
+ originalEntry: originalEntryPath,
89
+ hostEntry: hostEntryPath,
90
+ initHost: initHostPath,
91
+ remoteModuleRegistry: remoteModuleRegistryPath,
92
+ remoteHMRSetup: remoteHMRSetupPath,
93
+ remoteEntry: remoteEntryPath,
94
+ projectDir: config.projectRoot,
95
+ tmpDir: tmpDirPath
96
+ },
97
+ hacks: {
98
+ patchHMRClient: flags.unstable_patchHMRClient,
99
+ patchInitializeCore: flags.unstable_patchInitializeCore
100
+ }
101
+ })
102
+ },
103
+ server: {
104
+ ...config.server,
105
+ enhanceMiddleware: vmManager.getMiddleware(),
106
+ rewriteRequestUrl: createRewriteRequest({
107
+ config,
108
+ originalEntryFilename,
109
+ remoteEntryFilename,
110
+ manifestPath,
111
+ tmpDirPath
112
+ })
113
+ }
114
+ };
115
+ }
116
+ function getOriginalEntry(projectRoot, entryFilename) {
117
+ const originalEntryFilename = node_path.basename(global.__METRO_FEDERATION_ORIGINAL_ENTRY_PATH ?? entryFilename);
118
+ const originalEntryPath = node_path.resolve(projectRoot, global.__METRO_FEDERATION_ORIGINAL_ENTRY_PATH ?? entryFilename);
119
+ return {
120
+ originalEntryFilename,
121
+ originalEntryPath
122
+ };
123
+ }
124
+ export { withModuleFederation };
@@ -0,0 +1,3 @@
1
+ import type { ModuleFederationConfigNormalized } from '../types';
2
+ export declare function createManifest(options: ModuleFederationConfigNormalized, mfMetroPath: string): string;
3
+ export declare const updateManifest: (manifestPath: string, options: ModuleFederationConfigNormalized) => string;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ createManifest: ()=>createManifest,
37
+ updateManifest: ()=>updateManifest
38
+ });
39
+ const external_node_fs_namespaceObject = require("node:fs");
40
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
41
+ const external_node_path_namespaceObject = require("node:path");
42
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
43
+ const external_constants_js_namespaceObject = require("./constants.js");
44
+ function createManifest(options, mfMetroPath) {
45
+ const manifestPath = external_node_path_default().join(mfMetroPath, external_constants_js_namespaceObject.MANIFEST_FILENAME);
46
+ const manifest = generateManifest(options);
47
+ external_node_fs_default().writeFileSync(manifestPath, JSON.stringify(manifest, void 0, 2));
48
+ return manifestPath;
49
+ }
50
+ const updateManifest = (manifestPath, options)=>{
51
+ const manifest = generateManifest(options);
52
+ external_node_fs_default().writeFileSync(manifestPath, JSON.stringify(manifest, void 0, 2));
53
+ return manifestPath;
54
+ };
55
+ function generateManifest(config) {
56
+ return {
57
+ id: config.name,
58
+ name: config.name,
59
+ metaData: generateMetaData(config),
60
+ exposes: generateExposes(config),
61
+ remotes: generateRemotes(config),
62
+ shared: generateShared(config)
63
+ };
64
+ }
65
+ function generateMetaData(config) {
66
+ return {
67
+ name: config.name,
68
+ type: 'app',
69
+ buildInfo: {
70
+ buildVersion: '1.0.0',
71
+ buildName: config.name
72
+ },
73
+ remoteEntry: {
74
+ name: config.filename,
75
+ path: '',
76
+ type: 'global'
77
+ },
78
+ types: {
79
+ path: '',
80
+ name: '',
81
+ api: '',
82
+ zip: ''
83
+ },
84
+ globalName: config.name,
85
+ pluginVersion: '',
86
+ publicPath: 'auto'
87
+ };
88
+ }
89
+ function generateExposes(config) {
90
+ return Object.keys(config.exposes).map((expose)=>{
91
+ const formatKey = expose.replace('./', '');
92
+ const assets = getEmptyAssets();
93
+ assets.js.sync.push(config.exposes[expose]);
94
+ return {
95
+ id: `${config.name}:${formatKey}`,
96
+ name: formatKey,
97
+ path: expose,
98
+ assets
99
+ };
100
+ });
101
+ }
102
+ function generateRemotes(config) {
103
+ return Object.keys(config.remotes).map((remote)=>({
104
+ federationContainerName: config.remotes[remote],
105
+ moduleName: remote,
106
+ alias: remote,
107
+ entry: '*'
108
+ }));
109
+ }
110
+ function generateShared(config) {
111
+ return Object.keys(config.shared).map((sharedName)=>{
112
+ const assets = getEmptyAssets();
113
+ if (config.shared[sharedName].eager) assets.js.sync.push(config.filename);
114
+ else if (false !== config.shared[sharedName].import) assets.js.sync.push(`shared/${sharedName}.bundle`);
115
+ return {
116
+ id: sharedName,
117
+ name: sharedName,
118
+ version: config.shared[sharedName].version,
119
+ requiredVersion: config.shared[sharedName].requiredVersion,
120
+ singleton: config.shared[sharedName].singleton,
121
+ hash: '',
122
+ assets
123
+ };
124
+ });
125
+ }
126
+ function getEmptyAssets() {
127
+ return {
128
+ js: {
129
+ sync: [],
130
+ async: []
131
+ },
132
+ css: {
133
+ sync: [],
134
+ async: []
135
+ }
136
+ };
137
+ }
138
+ exports.createManifest = __webpack_exports__.createManifest;
139
+ exports.updateManifest = __webpack_exports__.updateManifest;
140
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
141
+ "createManifest",
142
+ "updateManifest"
143
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
144
+ Object.defineProperty(exports, '__esModule', {
145
+ value: true
146
+ });
@@ -0,0 +1,100 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import node_fs from "node:fs";
4
+ import node_path from "node:path";
5
+ import { MANIFEST_FILENAME } from "./constants.mjs";
6
+ function createManifest(options, mfMetroPath) {
7
+ const manifestPath = node_path.join(mfMetroPath, MANIFEST_FILENAME);
8
+ const manifest = generateManifest(options);
9
+ node_fs.writeFileSync(manifestPath, JSON.stringify(manifest, void 0, 2));
10
+ return manifestPath;
11
+ }
12
+ const updateManifest = (manifestPath, options)=>{
13
+ const manifest = generateManifest(options);
14
+ node_fs.writeFileSync(manifestPath, JSON.stringify(manifest, void 0, 2));
15
+ return manifestPath;
16
+ };
17
+ function generateManifest(config) {
18
+ return {
19
+ id: config.name,
20
+ name: config.name,
21
+ metaData: generateMetaData(config),
22
+ exposes: generateExposes(config),
23
+ remotes: generateRemotes(config),
24
+ shared: generateShared(config)
25
+ };
26
+ }
27
+ function generateMetaData(config) {
28
+ return {
29
+ name: config.name,
30
+ type: 'app',
31
+ buildInfo: {
32
+ buildVersion: '1.0.0',
33
+ buildName: config.name
34
+ },
35
+ remoteEntry: {
36
+ name: config.filename,
37
+ path: '',
38
+ type: 'global'
39
+ },
40
+ types: {
41
+ path: '',
42
+ name: '',
43
+ api: '',
44
+ zip: ''
45
+ },
46
+ globalName: config.name,
47
+ pluginVersion: '',
48
+ publicPath: 'auto'
49
+ };
50
+ }
51
+ function generateExposes(config) {
52
+ return Object.keys(config.exposes).map((expose)=>{
53
+ const formatKey = expose.replace('./', '');
54
+ const assets = getEmptyAssets();
55
+ assets.js.sync.push(config.exposes[expose]);
56
+ return {
57
+ id: `${config.name}:${formatKey}`,
58
+ name: formatKey,
59
+ path: expose,
60
+ assets
61
+ };
62
+ });
63
+ }
64
+ function generateRemotes(config) {
65
+ return Object.keys(config.remotes).map((remote)=>({
66
+ federationContainerName: config.remotes[remote],
67
+ moduleName: remote,
68
+ alias: remote,
69
+ entry: '*'
70
+ }));
71
+ }
72
+ function generateShared(config) {
73
+ return Object.keys(config.shared).map((sharedName)=>{
74
+ const assets = getEmptyAssets();
75
+ if (config.shared[sharedName].eager) assets.js.sync.push(config.filename);
76
+ else if (false !== config.shared[sharedName].import) assets.js.sync.push(`shared/${sharedName}.bundle`);
77
+ return {
78
+ id: sharedName,
79
+ name: sharedName,
80
+ version: config.shared[sharedName].version,
81
+ requiredVersion: config.shared[sharedName].requiredVersion,
82
+ singleton: config.shared[sharedName].singleton,
83
+ hash: '',
84
+ assets
85
+ };
86
+ });
87
+ }
88
+ function getEmptyAssets() {
89
+ return {
90
+ js: {
91
+ sync: [],
92
+ async: []
93
+ },
94
+ css: {
95
+ sync: [],
96
+ async: []
97
+ }
98
+ };
99
+ }
100
+ export { createManifest, updateManifest };
@@ -0,0 +1,8 @@
1
+ import type { ModuleFederationExtraOptions } from '../types';
2
+ export declare function normalizeExtraOptions(extraOptions?: ModuleFederationExtraOptions): {
3
+ flags: {
4
+ unstable_patchHMRClient: boolean;
5
+ unstable_patchInitializeCore: boolean;
6
+ unstable_patchRuntimeRequire: boolean;
7
+ };
8
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ normalizeExtraOptions: ()=>normalizeExtraOptions
28
+ });
29
+ function normalizeExtraOptions(extraOptions) {
30
+ return {
31
+ ...extraOptions,
32
+ flags: {
33
+ unstable_patchHMRClient: false,
34
+ unstable_patchInitializeCore: false,
35
+ unstable_patchRuntimeRequire: false,
36
+ ...null == extraOptions ? void 0 : extraOptions.flags
37
+ }
38
+ };
39
+ }
40
+ exports.normalizeExtraOptions = __webpack_exports__.normalizeExtraOptions;
41
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
42
+ "normalizeExtraOptions"
43
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });
@@ -0,0 +1,14 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ function normalizeExtraOptions(extraOptions) {
4
+ return {
5
+ ...extraOptions,
6
+ flags: {
7
+ unstable_patchHMRClient: false,
8
+ unstable_patchInitializeCore: false,
9
+ unstable_patchRuntimeRequire: false,
10
+ ...null == extraOptions ? void 0 : extraOptions.flags
11
+ }
12
+ };
13
+ }
14
+ export { normalizeExtraOptions };
@@ -0,0 +1,7 @@
1
+ import type { ModuleFederationConfig, ModuleFederationConfigNormalized } from '../types';
2
+ interface ProjectConfig {
3
+ projectRoot: string;
4
+ tmpDirPath: string;
5
+ }
6
+ export declare function normalizeOptions(options: ModuleFederationConfig, { projectRoot, tmpDirPath }: ProjectConfig): ModuleFederationConfigNormalized;
7
+ export {};