@rollipop/plugin-module-federation 1.0.0-alpha.29 → 1.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -220,11 +220,13 @@ function validateConfig(config) {
220
220
  //#region src/virtual/remote-entry.ts
221
221
  function generateRemoteEntryCode(options) {
222
222
  const exposeEntries = Object.entries(options.exposes);
223
+ const importLines = exposeEntries.map(([, filePath], index) => `import * as __expose_${index} from ${JSON.stringify(filePath)};`).join("\n");
224
+ const moduleMapLines = exposeEntries.map(([key], index) => ` ${JSON.stringify(key)}: () => __expose_${index},`).join("\n");
223
225
  return dedent`
224
- ${exposeEntries.map(([, filePath], index) => `import * as __expose_${index} from ${JSON.stringify(filePath)};`).join("\n")}
226
+ ${importLines}
225
227
 
226
228
  const moduleMap = {
227
- ${exposeEntries.map(([key], index) => ` ${JSON.stringify(key)}: () => __expose_${index},`).join("\n")}
229
+ ${moduleMapLines}
228
230
  };
229
231
 
230
232
  const container = {
@@ -244,59 +246,11 @@ function generateRemoteEntryCode(options) {
244
246
  }
245
247
  //#endregion
246
248
  //#region src/virtual/remote-proxy.ts
247
- function generateRemoteProxyCode({ remoteId, reactAware }) {
249
+ function generateRemoteProxyCode({ remoteId }) {
248
250
  const idLiteral = JSON.stringify(remoteId);
249
- if (reactAware) return dedent`
250
- import * as __mfReact from 'react';
251
-
252
- const __cache = globalThis.${REMOTE_CACHE_GLOBAL};
253
- const __id = ${idLiteral};
254
-
255
- function __ensureLoaded() {
256
- if (__cache.modules[__id] !== undefined) {
257
- return null;
258
- }
259
- return __cache.load(__id);
260
- }
261
-
262
- function __getMod() {
263
- return __cache.modules[__id];
264
- }
265
-
266
- function __FederatedProxy(props) {
267
- const mod = __getMod();
268
- if (mod === undefined) {
269
- throw __ensureLoaded();
270
- }
271
- const fn = mod.default ?? mod;
272
- return __mfReact.createElement(fn, props);
273
- }
274
-
275
- const __proxy = new Proxy(__FederatedProxy, {
276
- get(target, prop) {
277
- if (prop === '__esModule') {
278
- return true;
279
- }
280
- if (prop === 'then') {
281
- return undefined;
282
- }
283
- const mod = __getMod();
284
- if (mod === undefined) {
285
- throw __ensureLoaded();
286
- }
287
- if (prop in mod) {
288
- return mod[prop];
289
- }
290
- if (mod.default != null && prop in mod.default) {
291
- return mod.default[prop];
292
- }
293
- return target[prop];
294
- },
295
- });
296
-
297
- export default __proxy;
298
- `;
299
251
  return dedent`
252
+ import * as __mfReact from 'react';
253
+
300
254
  const __cache = globalThis.${REMOTE_CACHE_GLOBAL};
301
255
  const __id = ${idLiteral};
302
256
 
@@ -307,13 +261,12 @@ function generateRemoteProxyCode({ remoteId, reactAware }) {
307
261
  throw __cache.load(__id);
308
262
  }
309
263
 
310
- function __invoke(...args) {
264
+ function __FederatedProxy(props) {
311
265
  const mod = __getMod();
312
- const fn = mod.default ?? mod;
313
- return fn.apply(this, args);
266
+ return __mfReact.createElement(mod.default ?? mod, props);
314
267
  }
315
268
 
316
- const __proxy = new Proxy(__invoke, {
269
+ const __proxy = new Proxy(__FederatedProxy, {
317
270
  get(target, prop) {
318
271
  if (prop === '__esModule') {
319
272
  return true;
@@ -338,8 +291,9 @@ function generateRemoteProxyCode({ remoteId, reactAware }) {
338
291
  //#endregion
339
292
  //#region src/virtual/shared-shim.ts
340
293
  function generateSharedShimCode(sharedName) {
294
+ const key = JSON.stringify(sharedName);
341
295
  return dedent`
342
- const __mod = globalThis.${SHARED_REGISTRY_GLOBAL} && globalThis.${SHARED_REGISTRY_GLOBAL}[${JSON.stringify(sharedName)}];
296
+ const __mod = globalThis.${SHARED_REGISTRY_GLOBAL} && globalThis.${SHARED_REGISTRY_GLOBAL}[${key}];
343
297
  if (__mod == null) {
344
298
  throw new Error('[${PLUGIN_NAME}] shared module ${Q}${sharedName}${Q} is not registered on the host. Add it to the host config${Q}s ${Q}shared${Q} field.');
345
299
  }
@@ -399,10 +353,7 @@ function moduleFederationPlugin(config) {
399
353
  moduleType: "js"
400
354
  };
401
355
  if (id.startsWith(VIRTUAL_REMOTE_PROXY_PREFIX)) return {
402
- code: generateRemoteProxyCode({
403
- remoteId: id.slice(VIRTUAL_REMOTE_PROXY_PREFIX.length),
404
- reactAware: resolvedConfig?.mode !== "production"
405
- }),
356
+ code: generateRemoteProxyCode({ remoteId: id.slice(VIRTUAL_REMOTE_PROXY_PREFIX.length) }),
406
357
  moduleType: "js"
407
358
  };
408
359
  if (normalized == null) return null;
package/dist/runtime.d.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  //#region src/runtime.d.ts
2
- interface ModuleFederationScriptLoader {
2
+ export interface ModuleFederationScriptLoader {
3
3
  loadScript(args: {
4
4
  scriptId: string;
5
5
  url: string;
6
6
  parentUrl?: string;
7
7
  }): Promise<void>;
8
8
  }
9
- interface RemoteEntryExports {
9
+ export interface RemoteEntryExports {
10
10
  init(shareScope: unknown, initScope?: unknown[]): void | Promise<void>;
11
11
  get(modulePath: string): () => Promise<unknown>;
12
12
  }
13
13
  declare global {
14
14
  var __rollipop_script_loader__: ModuleFederationScriptLoader | undefined;
15
15
  }
16
- //#endregion
17
- export { ModuleFederationScriptLoader, RemoteEntryExports };
16
+ //#endregion
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@rollipop/plugin-module-federation",
3
- "version": "1.0.0-alpha.29",
4
- "stableVersion": "1.0.0-alpha.23",
3
+ "version": "1.0.0-alpha.30",
5
4
  "homepage": "https://github.com/rollipop-dev/rollipop#readme",
6
5
  "bugs": {
7
6
  "url": "https://github.com/rollipop-dev/rollipop/issues"
@@ -37,18 +36,23 @@
37
36
  "build": "vp pack"
38
37
  },
39
38
  "dependencies": {
40
- "@module-federation/runtime": "2.8.0",
39
+ "@module-federation/runtime": "2.9.1",
41
40
  "dedent": "1.7.2",
42
- "es-toolkit": "1.49.0"
41
+ "es-toolkit": "1.52.0"
43
42
  },
44
43
  "devDependencies": {
45
- "@vitest/coverage-v8": "4.1.10",
46
- "rollipop": "1.0.0-alpha.29",
47
- "typescript": "6.0.3",
48
- "vite-plus": "0.2.5",
49
- "vitest": "4.1.10"
44
+ "@types/react": "19.2.14",
45
+ "@vitest/coverage-v8": "4.1.11",
46
+ "react": "19.2.3",
47
+ "rollipop": "1.0.0-alpha.30",
48
+ "typescript": "7.0.2",
49
+ "vite-plus": "0.3.3",
50
+ "vitest": "4.1.11"
50
51
  },
51
52
  "peerDependencies": {
52
- "rollipop": "1.0.0-alpha.29"
53
+ "rollipop": "1.0.0-alpha.30"
54
+ },
55
+ "installConfig": {
56
+ "hoistingLimits": "none"
53
57
  }
54
58
  }