@module-federation/esbuild 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 (62) hide show
  1. package/dist/adapters/lib/collect-exports.js +153 -0
  2. package/dist/adapters/lib/collect-exports.mjs +80 -0
  3. package/dist/adapters/lib/commonjs.js +258 -0
  4. package/dist/adapters/lib/commonjs.mjs +182 -0
  5. package/dist/adapters/lib/containerPlugin.js +233 -0
  6. package/dist/adapters/lib/containerPlugin.mjs +179 -0
  7. package/dist/adapters/lib/containerReference.js +257 -0
  8. package/dist/adapters/lib/containerReference.mjs +188 -0
  9. package/dist/adapters/lib/lexer.js +187 -0
  10. package/dist/adapters/lib/lexer.mjs +136 -0
  11. package/dist/adapters/lib/linkRemotesPlugin.js +117 -0
  12. package/dist/adapters/lib/linkRemotesPlugin.mjs +48 -0
  13. package/dist/adapters/lib/manifest.js +227 -0
  14. package/dist/adapters/lib/manifest.mjs +159 -0
  15. package/dist/adapters/lib/plugin.js +340 -0
  16. package/dist/adapters/lib/plugin.mjs +247 -0
  17. package/dist/adapters/lib/react-replacements.js +86 -0
  18. package/dist/adapters/lib/react-replacements.mjs +34 -0
  19. package/dist/adapters/lib/transform.js +171 -0
  20. package/dist/adapters/lib/transform.mjs +116 -0
  21. package/dist/adapters/lib/utils.js +87 -0
  22. package/dist/adapters/lib/utils.mjs +31 -0
  23. package/dist/build.js +132 -473
  24. package/dist/build.mjs +12 -380
  25. package/dist/index.js +45 -26
  26. package/dist/index.mjs +3 -2
  27. package/dist/lib/config/configuration-context.js +73 -0
  28. package/dist/lib/config/configuration-context.mjs +18 -0
  29. package/dist/lib/config/federation-config.js +29 -0
  30. package/dist/lib/config/federation-config.mjs +3 -0
  31. package/dist/lib/config/share-utils.js +340 -0
  32. package/dist/lib/config/share-utils.mjs +245 -0
  33. package/dist/lib/config/with-native-federation.js +120 -0
  34. package/dist/lib/config/with-native-federation.mjs +66 -0
  35. package/dist/lib/core/build-adapter.js +72 -0
  36. package/dist/lib/core/build-adapter.mjs +16 -0
  37. package/dist/lib/core/createContainerTemplate.js +235 -0
  38. package/dist/lib/core/createContainerTemplate.mjs +183 -0
  39. package/dist/lib/core/default-skip-list.js +103 -0
  40. package/dist/lib/core/default-skip-list.mjs +45 -0
  41. package/dist/lib/core/federation-options.js +29 -0
  42. package/dist/lib/core/federation-options.mjs +3 -0
  43. package/dist/lib/core/get-externals.js +68 -0
  44. package/dist/lib/core/get-externals.mjs +17 -0
  45. package/dist/lib/core/load-federation-config.js +71 -0
  46. package/dist/lib/core/load-federation-config.mjs +16 -0
  47. package/dist/lib/core/write-federation-info.js +67 -0
  48. package/dist/lib/core/write-federation-info.mjs +12 -0
  49. package/dist/lib/utils/logger.js +113 -0
  50. package/dist/lib/utils/logger.mjs +44 -0
  51. package/dist/lib/utils/mapped-paths.js +95 -0
  52. package/dist/lib/utils/mapped-paths.mjs +40 -0
  53. package/dist/lib/utils/normalize.js +66 -0
  54. package/dist/lib/utils/normalize.mjs +15 -0
  55. package/dist/lib/utils/package-info.js +325 -0
  56. package/dist/lib/utils/package-info.mjs +259 -0
  57. package/dist/plugin.d.ts +1 -0
  58. package/dist/plugin.js +82 -1233
  59. package/dist/plugin.mjs +2 -1188
  60. package/dist/resolve/esm-resolver.mjs +15 -22
  61. package/dist/rslib-runtime.mjs +31 -0
  62. package/package.json +20 -11
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ var __webpack_modules__ = ({
10
+ "esbuild"(module) {
11
+ module.exports = require("esbuild");
12
+
13
+ },
14
+
15
+ });
16
+ // The module cache
17
+ var __webpack_module_cache__ = {};
18
+
19
+ // The require function
20
+ function __webpack_require__(moduleId) {
21
+
22
+ // Check if module is in cache
23
+ var cachedModule = __webpack_module_cache__[moduleId];
24
+ if (cachedModule !== undefined) {
25
+ return cachedModule.exports;
26
+ }
27
+ // Create a new module (and put it into the cache)
28
+ var module = (__webpack_module_cache__[moduleId] = {
29
+ exports: {}
30
+ });
31
+ // Execute the module function
32
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33
+
34
+ // Return the exports of the module
35
+ return module.exports;
36
+
37
+ }
38
+
39
+ // webpack/runtime/compat_get_default_export
40
+ (() => {
41
+ // getDefaultExport function for compatibility with non-ESM modules
42
+ __webpack_require__.n = (module) => {
43
+ var getter = module && module.__esModule ?
44
+ () => (module['default']) :
45
+ () => (module);
46
+ __webpack_require__.d(getter, { a: getter });
47
+ return getter;
48
+ };
49
+
50
+ })();
51
+ // webpack/runtime/define_property_getters
52
+ (() => {
53
+ __webpack_require__.d = (exports, getters, values) => {
54
+ var define = (defs, kind) => {
55
+ for(var key in defs) {
56
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
57
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
58
+ }
59
+ }
60
+ };
61
+ define(getters, "get");
62
+ define(values, "value");
63
+ };
64
+ })();
65
+ // webpack/runtime/has_own_property
66
+ (() => {
67
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
68
+ })();
69
+ // webpack/runtime/make_namespace_object
70
+ (() => {
71
+ // define __esModule on exports
72
+ __webpack_require__.r = (exports) => {
73
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
74
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
75
+ }
76
+ Object.defineProperty(exports, '__esModule', { value: true });
77
+ };
78
+ })();
79
+ var __webpack_exports__ = {};
80
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
81
+ (() => {
82
+ // ESM COMPAT FLAG
83
+ __webpack_require__.r(__webpack_exports__);
84
+
85
+ // EXPORTS
86
+ __webpack_require__.d(__webpack_exports__, {
87
+ createVirtualRemoteModule: () => (/* binding */ createVirtualRemoteModule),
88
+ createVirtualShareModule: () => (/* binding */ createVirtualShareModule),
89
+ moduleFederationPlugin: () => (/* binding */ moduleFederationPlugin)
90
+ });
91
+
92
+ ;// CONCATENATED MODULE: external "fs"
93
+ const external_fs_namespaceObject = require("fs");
94
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
95
+ ;// CONCATENATED MODULE: external "./collect-exports.js"
96
+ const external_collect_exports_js_namespaceObject = require("./collect-exports.js");
97
+ ;// CONCATENATED MODULE: external "path"
98
+ const external_path_namespaceObject = require("path");
99
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
100
+ ;// CONCATENATED MODULE: external "./manifest.js"
101
+ const external_manifest_js_namespaceObject = require("./manifest.js");
102
+ ;// CONCATENATED MODULE: external "./containerPlugin.js"
103
+ const external_containerPlugin_js_namespaceObject = require("./containerPlugin.js");
104
+ ;// CONCATENATED MODULE: external "./containerReference.js"
105
+ const external_containerReference_js_namespaceObject = require("./containerReference.js");
106
+ ;// CONCATENATED MODULE: external "./linkRemotesPlugin.js"
107
+ const external_linkRemotesPlugin_js_namespaceObject = require("./linkRemotesPlugin.js");
108
+ ;// CONCATENATED MODULE: external "./commonjs.js"
109
+ const external_commonjs_js_namespaceObject = require("./commonjs.js");
110
+ ;// CONCATENATED MODULE: external "../../lib/core/get-externals.js"
111
+ const get_externals_js_namespaceObject = require("../../lib/core/get-externals.js");
112
+ ;// CONCATENATED MODULE: ./src/adapters/lib/plugin.ts
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ // Creates a virtual module for sharing dependencies
123
+ const createVirtualShareModule = (name, ref, exports)=>`
124
+ const container = __FEDERATION__.__INSTANCES__.find(container => container.name === ${JSON.stringify(name)}) || __FEDERATION__.__INSTANCES__[0]
125
+
126
+ const mfLsZJ92 = await container.loadShare(${JSON.stringify(ref)})
127
+
128
+ ${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
129
+ `;
130
+ const createVirtualRemoteModule = (name, ref)=>`
131
+ export * from ${JSON.stringify('federationRemote/' + ref)}
132
+ `;
133
+ // Plugin to transform CommonJS modules to ESM
134
+ const cjsToEsmPlugin = {
135
+ name: 'cjs-to-esm',
136
+ setup (build) {
137
+ build.onLoad({
138
+ filter: /.*/,
139
+ namespace: 'esm-shares'
140
+ }, async (args)=>{
141
+ let esbuild_shim;
142
+ const require_esbuild = ()=>// eslint-disable-next-line @typescript-eslint/no-require-imports
143
+ build.esbuild || (esbuild_shim ||= __webpack_require__("esbuild"));
144
+ const packageBuilder = await require_esbuild().build({
145
+ ...build.initialOptions,
146
+ external: build.initialOptions.external?.filter((e)=>{
147
+ if (e.includes('*')) {
148
+ const prefix = e.split('*')[0];
149
+ return !args.path.startsWith(prefix);
150
+ }
151
+ return e !== args.path;
152
+ }),
153
+ entryPoints: [
154
+ args.path
155
+ ],
156
+ plugins: [
157
+ (0,external_commonjs_js_namespaceObject.commonjs)({
158
+ filter: /.*/
159
+ })
160
+ ],
161
+ write: false
162
+ });
163
+ return {
164
+ contents: packageBuilder.outputFiles[0].text,
165
+ loader: 'js',
166
+ resolveDir: args.pluginData.resolveDir
167
+ };
168
+ });
169
+ }
170
+ };
171
+ // Plugin to link shared dependencies
172
+ const linkSharedPlugin = (config)=>({
173
+ name: 'linkShared',
174
+ setup (build) {
175
+ const filter = new RegExp(Object.keys(config.shared || {}).map((name)=>`${name}$`).join('|'));
176
+ build.onResolve({
177
+ filter
178
+ }, (args)=>{
179
+ if (args.namespace === 'esm-shares') return null;
180
+ return {
181
+ path: args.path,
182
+ namespace: 'virtual-share-module',
183
+ pluginData: {
184
+ kind: args.kind,
185
+ resolveDir: args.resolveDir
186
+ }
187
+ };
188
+ });
189
+ build.onResolve({
190
+ filter: /.*/,
191
+ namespace: 'esm-shares'
192
+ }, (args)=>{
193
+ if (filter.test(args.path)) {
194
+ return {
195
+ path: args.path,
196
+ namespace: 'virtual-share-module',
197
+ pluginData: {
198
+ kind: args.kind,
199
+ resolveDir: args.resolveDir
200
+ }
201
+ };
202
+ }
203
+ if (filter.test(args.importer)) {
204
+ return {
205
+ path: args.path,
206
+ namespace: 'esm-shares',
207
+ pluginData: {
208
+ kind: args.kind,
209
+ resolveDir: args.resolveDir
210
+ }
211
+ };
212
+ }
213
+ return undefined;
214
+ });
215
+ build.onResolve({
216
+ filter: /^federationShare/
217
+ }, async (args)=>({
218
+ path: args.path.replace('federationShare/', ''),
219
+ namespace: 'esm-shares',
220
+ pluginData: {
221
+ kind: args.kind,
222
+ resolveDir: args.resolveDir
223
+ }
224
+ }));
225
+ build.onLoad({
226
+ filter,
227
+ namespace: 'virtual-share-module'
228
+ }, async (args)=>{
229
+ const exp = await (0,external_collect_exports_js_namespaceObject.getExports)(args.path);
230
+ return {
231
+ contents: createVirtualShareModule(config.name, args.path, exp),
232
+ loader: 'js',
233
+ resolveDir: external_path_default().dirname(args.path)
234
+ };
235
+ });
236
+ }
237
+ });
238
+ // Main module federation plugin
239
+ const moduleFederationPlugin = (config)=>({
240
+ name: 'module-federation',
241
+ setup (build) {
242
+ build.initialOptions.metafile = true;
243
+ const externals = (0,get_externals_js_namespaceObject.getExternals)(config);
244
+ if (build.initialOptions.external) {
245
+ build.initialOptions.external = [
246
+ ...new Set([
247
+ ...build.initialOptions.external,
248
+ ...externals
249
+ ])
250
+ ];
251
+ } else {
252
+ build.initialOptions.external = externals;
253
+ }
254
+ const pluginStack = [];
255
+ const remotes = Object.keys(config.remotes || {}).length;
256
+ const shared = Object.keys(config.shared || {}).length;
257
+ const exposes = Object.keys(config.exposes || {}).length;
258
+ const entryPoints = build.initialOptions.entryPoints;
259
+ const filename = config.filename || 'remoteEntry.js';
260
+ if (remotes) {
261
+ pluginStack.push((0,external_linkRemotesPlugin_js_namespaceObject.linkRemotesPlugin)(config));
262
+ }
263
+ if (shared) {
264
+ pluginStack.push(linkSharedPlugin(config));
265
+ }
266
+ if (!entryPoints) {
267
+ build.initialOptions.entryPoints = [];
268
+ }
269
+ if (exposes) {
270
+ if (Array.isArray(entryPoints)) {
271
+ entryPoints.push(filename);
272
+ } else if (entryPoints && typeof entryPoints === 'object') {
273
+ entryPoints[filename] = filename;
274
+ } else {
275
+ build.initialOptions.entryPoints = [
276
+ filename
277
+ ];
278
+ }
279
+ }
280
+ [
281
+ (0,external_containerReference_js_namespaceObject.initializeHostPlugin)(config),
282
+ (0,external_containerPlugin_js_namespaceObject.createContainerPlugin)(config),
283
+ cjsToEsmPlugin,
284
+ ...pluginStack
285
+ ].forEach((plugin)=>plugin.setup(build));
286
+ build.onEnd(async (result)=>{
287
+ if (!result.metafile) return;
288
+ if (exposes) {
289
+ const exposedConfig = config.exposes || {};
290
+ const remoteFile = config.filename;
291
+ const exposedEntries = {};
292
+ const outputMapWithoutExt = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
293
+ //@ts-ignore
294
+ const { entryPoint } = chunkValue;
295
+ const key = entryPoint || chunkKey;
296
+ const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
297
+ //@ts-ignore
298
+ acc[trimKey] = {
299
+ ...chunkValue,
300
+ chunk: chunkKey
301
+ };
302
+ return acc;
303
+ }, {});
304
+ for (const [expose, value] of Object.entries(exposedConfig)){
305
+ const exposedFound = //@ts-ignore
306
+ outputMapWithoutExt[value.replace('./', '')] || //@ts-ignore
307
+ outputMapWithoutExt[expose.replace('./', '')];
308
+ if (exposedFound) {
309
+ exposedEntries[expose] = {
310
+ entryPoint: exposedFound.entryPoint,
311
+ exports: exposedFound.exports
312
+ };
313
+ }
314
+ }
315
+ for (const [outputPath, value] of Object.entries(result.metafile.outputs)){
316
+ if (!value.entryPoint) continue;
317
+ if (!value.entryPoint.startsWith('container:')) continue;
318
+ if (!value.entryPoint.endsWith(remoteFile)) continue;
319
+ const container = external_fs_default().readFileSync(outputPath, 'utf-8');
320
+ const withExports = container.replace('"__MODULE_MAP__"', `${JSON.stringify(exposedEntries)}`).replace("'__MODULE_MAP__'", `${JSON.stringify(exposedEntries)}`);
321
+ external_fs_default().writeFileSync(outputPath, withExports, 'utf-8');
322
+ }
323
+ }
324
+ await (0,external_manifest_js_namespaceObject.writeRemoteManifest)(config, result);
325
+ console.log(`build ended with ${result.errors.length} errors`);
326
+ });
327
+ }
328
+ });
329
+
330
+ })();
331
+
332
+ exports.createVirtualRemoteModule = __webpack_exports__.createVirtualRemoteModule;
333
+ exports.createVirtualShareModule = __webpack_exports__.createVirtualShareModule;
334
+ exports.moduleFederationPlugin = __webpack_exports__.moduleFederationPlugin;
335
+ for(var __rspack_i in __webpack_exports__) {
336
+ if(["createVirtualRemoteModule","createVirtualShareModule","moduleFederationPlugin"].indexOf(__rspack_i) === -1) {
337
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
338
+ }
339
+ }
340
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,247 @@
1
+ import fs from "fs";
2
+ import { getExports } from "./collect-exports.mjs";
3
+ import path from "path";
4
+ import { writeRemoteManifest } from "./manifest.mjs";
5
+ import { createContainerPlugin } from "./containerPlugin.mjs";
6
+ import { initializeHostPlugin } from "./containerReference.mjs";
7
+ import { linkRemotesPlugin } from "./linkRemotesPlugin.mjs";
8
+ import { commonjs } from "./commonjs.mjs";
9
+ import { getExternals } from "../../lib/core/get-externals.mjs";
10
+ import { __webpack_require__ } from "../../rslib-runtime.mjs";
11
+
12
+ import * as __rspack_external_esbuild from "esbuild";
13
+ __webpack_require__.add({
14
+ "esbuild?ee69"(module) {
15
+
16
+ module.exports = __rspack_external_esbuild;
17
+
18
+
19
+ },
20
+ });
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ // Creates a virtual module for sharing dependencies
40
+ const createVirtualShareModule = (name, ref, exports)=>`
41
+ const container = __FEDERATION__.__INSTANCES__.find(container => container.name === ${JSON.stringify(name)}) || __FEDERATION__.__INSTANCES__[0]
42
+
43
+ const mfLsZJ92 = await container.loadShare(${JSON.stringify(ref)})
44
+
45
+ ${exports.map((e)=>e === 'default' ? `export default mfLsZJ92.default` : `export const ${e} = mfLsZJ92[${JSON.stringify(e)}];`).join('\n')}
46
+ `;
47
+ const createVirtualRemoteModule = (name, ref)=>`
48
+ export * from ${JSON.stringify('federationRemote/' + ref)}
49
+ `;
50
+ // Plugin to transform CommonJS modules to ESM
51
+ const cjsToEsmPlugin = {
52
+ name: 'cjs-to-esm',
53
+ setup (build) {
54
+ build.onLoad({
55
+ filter: /.*/,
56
+ namespace: 'esm-shares'
57
+ }, async (args)=>{
58
+ let esbuild_shim;
59
+ const require_esbuild = ()=>// eslint-disable-next-line @typescript-eslint/no-require-imports
60
+ build.esbuild || (esbuild_shim ||= __webpack_require__("esbuild?ee69"));
61
+ const packageBuilder = await require_esbuild().build({
62
+ ...build.initialOptions,
63
+ external: build.initialOptions.external?.filter((e)=>{
64
+ if (e.includes('*')) {
65
+ const prefix = e.split('*')[0];
66
+ return !args.path.startsWith(prefix);
67
+ }
68
+ return e !== args.path;
69
+ }),
70
+ entryPoints: [
71
+ args.path
72
+ ],
73
+ plugins: [
74
+ commonjs({
75
+ filter: /.*/
76
+ })
77
+ ],
78
+ write: false
79
+ });
80
+ return {
81
+ contents: packageBuilder.outputFiles[0].text,
82
+ loader: 'js',
83
+ resolveDir: args.pluginData.resolveDir
84
+ };
85
+ });
86
+ }
87
+ };
88
+ // Plugin to link shared dependencies
89
+ const linkSharedPlugin = (config)=>({
90
+ name: 'linkShared',
91
+ setup (build) {
92
+ const filter = new RegExp(Object.keys(config.shared || {}).map((name)=>`${name}$`).join('|'));
93
+ build.onResolve({
94
+ filter
95
+ }, (args)=>{
96
+ if (args.namespace === 'esm-shares') return null;
97
+ return {
98
+ path: args.path,
99
+ namespace: 'virtual-share-module',
100
+ pluginData: {
101
+ kind: args.kind,
102
+ resolveDir: args.resolveDir
103
+ }
104
+ };
105
+ });
106
+ build.onResolve({
107
+ filter: /.*/,
108
+ namespace: 'esm-shares'
109
+ }, (args)=>{
110
+ if (filter.test(args.path)) {
111
+ return {
112
+ path: args.path,
113
+ namespace: 'virtual-share-module',
114
+ pluginData: {
115
+ kind: args.kind,
116
+ resolveDir: args.resolveDir
117
+ }
118
+ };
119
+ }
120
+ if (filter.test(args.importer)) {
121
+ return {
122
+ path: args.path,
123
+ namespace: 'esm-shares',
124
+ pluginData: {
125
+ kind: args.kind,
126
+ resolveDir: args.resolveDir
127
+ }
128
+ };
129
+ }
130
+ return undefined;
131
+ });
132
+ build.onResolve({
133
+ filter: /^federationShare/
134
+ }, async (args)=>({
135
+ path: args.path.replace('federationShare/', ''),
136
+ namespace: 'esm-shares',
137
+ pluginData: {
138
+ kind: args.kind,
139
+ resolveDir: args.resolveDir
140
+ }
141
+ }));
142
+ build.onLoad({
143
+ filter,
144
+ namespace: 'virtual-share-module'
145
+ }, async (args)=>{
146
+ const exp = await getExports(args.path);
147
+ return {
148
+ contents: createVirtualShareModule(config.name, args.path, exp),
149
+ loader: 'js',
150
+ resolveDir: path.dirname(args.path)
151
+ };
152
+ });
153
+ }
154
+ });
155
+ // Main module federation plugin
156
+ const moduleFederationPlugin = (config)=>({
157
+ name: 'module-federation',
158
+ setup (build) {
159
+ build.initialOptions.metafile = true;
160
+ const externals = getExternals(config);
161
+ if (build.initialOptions.external) {
162
+ build.initialOptions.external = [
163
+ ...new Set([
164
+ ...build.initialOptions.external,
165
+ ...externals
166
+ ])
167
+ ];
168
+ } else {
169
+ build.initialOptions.external = externals;
170
+ }
171
+ const pluginStack = [];
172
+ const remotes = Object.keys(config.remotes || {}).length;
173
+ const shared = Object.keys(config.shared || {}).length;
174
+ const exposes = Object.keys(config.exposes || {}).length;
175
+ const entryPoints = build.initialOptions.entryPoints;
176
+ const filename = config.filename || 'remoteEntry.js';
177
+ if (remotes) {
178
+ pluginStack.push(linkRemotesPlugin(config));
179
+ }
180
+ if (shared) {
181
+ pluginStack.push(linkSharedPlugin(config));
182
+ }
183
+ if (!entryPoints) {
184
+ build.initialOptions.entryPoints = [];
185
+ }
186
+ if (exposes) {
187
+ if (Array.isArray(entryPoints)) {
188
+ entryPoints.push(filename);
189
+ } else if (entryPoints && typeof entryPoints === 'object') {
190
+ entryPoints[filename] = filename;
191
+ } else {
192
+ build.initialOptions.entryPoints = [
193
+ filename
194
+ ];
195
+ }
196
+ }
197
+ [
198
+ initializeHostPlugin(config),
199
+ createContainerPlugin(config),
200
+ cjsToEsmPlugin,
201
+ ...pluginStack
202
+ ].forEach((plugin)=>plugin.setup(build));
203
+ build.onEnd(async (result)=>{
204
+ if (!result.metafile) return;
205
+ if (exposes) {
206
+ const exposedConfig = config.exposes || {};
207
+ const remoteFile = config.filename;
208
+ const exposedEntries = {};
209
+ const outputMapWithoutExt = Object.entries(result.metafile.outputs).reduce((acc, [chunkKey, chunkValue])=>{
210
+ //@ts-ignore
211
+ const { entryPoint } = chunkValue;
212
+ const key = entryPoint || chunkKey;
213
+ const trimKey = key.substring(0, key.lastIndexOf('.')) || key;
214
+ //@ts-ignore
215
+ acc[trimKey] = {
216
+ ...chunkValue,
217
+ chunk: chunkKey
218
+ };
219
+ return acc;
220
+ }, {});
221
+ for (const [expose, value] of Object.entries(exposedConfig)){
222
+ const exposedFound = //@ts-ignore
223
+ outputMapWithoutExt[value.replace('./', '')] || //@ts-ignore
224
+ outputMapWithoutExt[expose.replace('./', '')];
225
+ if (exposedFound) {
226
+ exposedEntries[expose] = {
227
+ entryPoint: exposedFound.entryPoint,
228
+ exports: exposedFound.exports
229
+ };
230
+ }
231
+ }
232
+ for (const [outputPath, value] of Object.entries(result.metafile.outputs)){
233
+ if (!value.entryPoint) continue;
234
+ if (!value.entryPoint.startsWith('container:')) continue;
235
+ if (!value.entryPoint.endsWith(remoteFile)) continue;
236
+ const container = fs.readFileSync(outputPath, 'utf-8');
237
+ const withExports = container.replace('"__MODULE_MAP__"', `${JSON.stringify(exposedEntries)}`).replace("'__MODULE_MAP__'", `${JSON.stringify(exposedEntries)}`);
238
+ fs.writeFileSync(outputPath, withExports, 'utf-8');
239
+ }
240
+ }
241
+ await writeRemoteManifest(config, result);
242
+ console.log(`build ended with ${result.errors.length} errors`);
243
+ });
244
+ }
245
+ });
246
+
247
+ export { createVirtualRemoteModule, createVirtualShareModule, moduleFederationPlugin };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ "use strict"
10
+ // The require scope
11
+ var __webpack_require__ = {};
12
+
13
+ // webpack/runtime/define_property_getters
14
+ (() => {
15
+ __webpack_require__.d = (exports, getters, values) => {
16
+ var define = (defs, kind) => {
17
+ for(var key in defs) {
18
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
19
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
20
+ }
21
+ }
22
+ };
23
+ define(getters, "get");
24
+ define(values, "value");
25
+ };
26
+ })();
27
+ // webpack/runtime/has_own_property
28
+ (() => {
29
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
30
+ })();
31
+ // webpack/runtime/make_namespace_object
32
+ (() => {
33
+ // define __esModule on exports
34
+ __webpack_require__.r = (exports) => {
35
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
36
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
37
+ }
38
+ Object.defineProperty(exports, '__esModule', { value: true });
39
+ };
40
+ })();
41
+ var __webpack_exports__ = {};
42
+ __webpack_require__.r(__webpack_exports__);
43
+
44
+ const reactReplacements = {
45
+ dev: {
46
+ 'node_modules/react/index.js': {
47
+ file: 'node_modules/react/cjs/react.development.js'
48
+ },
49
+ 'node_modules/react/jsx-dev-runtime.js': {
50
+ file: 'node_modules/react/cjs/react-jsx-dev-runtime.development.js'
51
+ },
52
+ 'node_modules/react/jsx-runtime.js': {
53
+ file: 'node_modules/react/cjs/react-jsx-runtime.development.js'
54
+ },
55
+ 'node_modules/react-dom/index.js': {
56
+ file: 'node_modules/react-dom/cjs/react-dom.development.js'
57
+ }
58
+ },
59
+ prod: {
60
+ 'node_modules/react/index.js': {
61
+ file: 'node_modules/react/cjs/react.production.min.js'
62
+ },
63
+ 'node_modules/react/jsx-dev-runtime.js': {
64
+ file: 'node_modules/react/cjs/react-jsx-dev-runtime.production.min.js'
65
+ },
66
+ 'node_modules/react/jsx-runtime.js': {
67
+ file: 'node_modules/react/cjs/react-jsx-runtime.production.min.js'
68
+ },
69
+ 'node_modules/react-dom/index.js': {
70
+ file: 'node_modules/react-dom/cjs/react-dom.production.min.js'
71
+ }
72
+ }
73
+ };
74
+
75
+ __webpack_require__.d(__webpack_exports__, {
76
+ }, {
77
+ reactReplacements: reactReplacements
78
+ });
79
+
80
+ exports.reactReplacements = __webpack_exports__.reactReplacements;
81
+ for(var __rspack_i in __webpack_exports__) {
82
+ if(["reactReplacements"].indexOf(__rspack_i) === -1) {
83
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
84
+ }
85
+ }
86
+ Object.defineProperty(exports, '__esModule', { value: true });