@mfeflow/rsbuild 0.4.0 → 0.5.0

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.d.ts CHANGED
@@ -100,5 +100,7 @@ export declare function shellFederationOptions(o: ShellOptions, canResolve: (s:
100
100
  export declare function assertAsyncBoundary(entryFile: string, read?: (file: string) => string | undefined): void;
101
101
  /** The `version` of the app's `package.json`, or `0.0.0` when it has none. */
102
102
  export declare function appVersion(cwd: string): string;
103
+ /** The shared packages of an app, once each: `react-dom/client` and `react-dom` count as `react-dom`. */
104
+ export declare function sharedPackages(canResolve: (s: string) => boolean, extra?: readonly string[]): string[];
103
105
  /** Rsbuild config for the shell (host). */
104
106
  export declare function createShellConfig(o: ShellOptions): RsbuildConfig;
package/dist/index.js CHANGED
@@ -317,6 +317,11 @@ function appVersion(cwd) {
317
317
  return '0.0.0';
318
318
  }
319
319
  }
320
+ function sharedPackages(canResolve, extra = []) {
321
+ return [
322
+ ...new Set(Object.keys(sharedSingletons(canResolve, extra)).map(packageNameOf))
323
+ ];
324
+ }
320
325
  function createShellConfig(o) {
321
326
  const cwd = o.cwd ?? process.cwd();
322
327
  const require = createRequire(node_path.join(cwd, 'package.json'));
@@ -342,7 +347,8 @@ function createShellConfig(o) {
342
347
  },
343
348
  define: {
344
349
  __MFEFLOW_SNAPSHOT__: JSON.stringify(snapshotEnabled(o)),
345
- __MFEFLOW_APP_VERSION__: JSON.stringify(appVersion(cwd))
350
+ __MFEFLOW_APP_VERSION__: JSON.stringify(appVersion(cwd)),
351
+ __MFEFLOW_SINGLETONS__: JSON.stringify(sharedPackages(resolvableFrom(cwd), o.shared))
346
352
  }
347
353
  },
348
354
  server: {
@@ -356,4 +362,4 @@ function createShellConfig(o) {
356
362
  }
357
363
  };
358
364
  }
359
- export { DEFAULT_SINGLETONS, RUNTIME_CONFIG_URL, appVersion, assertAsyncBoundary, createRemoteConfig, createShellConfig, esmTwin, headScriptTags, installedVersionFrom, isMfCjs, packageNameOf, pluginMfEsmRuntime, registerHeadScript, remoteFederationOptions, resolvableFrom, runtimeConfigEnv, runtimeConfigEnvs, runtimeConfigHandler, runtimeConfigSetup, sharedSingletons, shellFederationOptions, snapshotEnabled };
365
+ export { DEFAULT_SINGLETONS, RUNTIME_CONFIG_URL, appVersion, assertAsyncBoundary, createRemoteConfig, createShellConfig, esmTwin, headScriptTags, installedVersionFrom, isMfCjs, packageNameOf, pluginMfEsmRuntime, registerHeadScript, remoteFederationOptions, resolvableFrom, runtimeConfigEnv, runtimeConfigEnvs, runtimeConfigHandler, runtimeConfigSetup, sharedPackages, sharedSingletons, shellFederationOptions, snapshotEnabled };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfeflow/rsbuild",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Rsbuild presets for Module Federation 2.0 micro-frontends: createShellConfig and createRemoteConfig with shared singletons, external runtime, manifests, types and error reporting set up.",
5
5
  "keywords": [
6
6
  "micro-frontend",