diff --git a/README.md b/README.md index 3134a6560fa..669696346d8 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Come and chat with us on [Discussions](https://github.com/module-federation/univ Please read the [Contributing Guide](https://github.com/module-federation/core/blob/main/CONTRIBUTING.md). -![Alt](https://repobeats.axiom.co/api/embed/856dc1d4a6965d225232b1bd2da5d54549dc169e.svg "Repobeats analytics image") +![Alt](https://repobeats.axiom.co/api/embed/856dc1d4a6965d225232b1bd2da5d54549dc169e.svg 'Repobeats analytics image') ## 🙌 Code of Conduct diff --git a/apps/rslib-module/README.md b/apps/rslib-module/README.md index 46a832785f3..3ad43d0342b 100644 --- a/apps/rslib-module/README.md +++ b/apps/rslib-module/README.md @@ -18,7 +18,7 @@ nx serve rslib-module Dev package -1. +1. ``` nx dev rslib-module diff --git a/packages/assemble-release-plan/README.md b/packages/assemble-release-plan/README.md index 60e003ea44a..00b7c37c27a 100644 --- a/packages/assemble-release-plan/README.md +++ b/packages/assemble-release-plan/README.md @@ -7,11 +7,11 @@ Assemble a release plan for changesets from data about a repository. Usage ```ts -import assembleReleasePlan from "@changesets/assemble-release-plan"; -import readChangesets from "@changesets/read"; -import { read } from "@changesets/config"; -import { getPackages } from "@manypkg/get-packages"; -import { readPreState } from "@changesets/pre"; +import assembleReleasePlan from '@changesets/assemble-release-plan'; +import readChangesets from '@changesets/read'; +import { read } from '@changesets/config'; +import { getPackages } from '@manypkg/get-packages'; +import { readPreState } from '@changesets/pre'; const packages = await getPackages(cwd); const preState = await readPreState(cwd); @@ -24,14 +24,10 @@ const releasePlan = assembleReleasePlan(changesets, packages, config, preState); Signature ```ts -import { NewChangeset, Config, ReleasePlan } from "@changesets/types"; -import { Packages } from "@manypkg/get-packages"; - -assembleReleasePlan = ( - changesets: NewChangeset[], - packages: Packages, - config: Config -) => ReleasePlan; +import { NewChangeset, Config, ReleasePlan } from '@changesets/types'; +import { Packages } from '@manypkg/get-packages'; + +assembleReleasePlan = (changesets: NewChangeset[], packages: Packages, config: Config) => ReleasePlan; ``` This package exists so assembling a release plan can be done without reading from disc. diff --git a/packages/create-module-federation/templates/provider-rslib-storybook-ts/README.md b/packages/create-module-federation/templates/provider-rslib-storybook-ts/README.md index f8d0efb3119..1b5c57ef66a 100644 --- a/packages/create-module-federation/templates/provider-rslib-storybook-ts/README.md +++ b/packages/create-module-federation/templates/provider-rslib-storybook-ts/README.md @@ -12,7 +12,7 @@ pnpm build Dev package -1. +1. ``` pnpm mf-dev diff --git a/packages/create-module-federation/templates/provider-rslib-ts/README.md b/packages/create-module-federation/templates/provider-rslib-ts/README.md index cffe4ed5fd3..c88b48dd19d 100644 --- a/packages/create-module-federation/templates/provider-rslib-ts/README.md +++ b/packages/create-module-federation/templates/provider-rslib-ts/README.md @@ -12,8 +12,6 @@ pnpm build Dev package - ``` pnpm mf-dev ``` - diff --git a/packages/data-prefetch/src/plugin.ts b/packages/data-prefetch/src/plugin.ts index 102ba1f6b77..e9b6256acda 100644 --- a/packages/data-prefetch/src/plugin.ts +++ b/packages/data-prefetch/src/plugin.ts @@ -104,8 +104,10 @@ export const prefetchPlugin = (): ModuleFederationRuntimePlugin => ({ return options; } + // Check if prefetch is already initiated by initContainer const inited = loadingArray.some((info) => info.id === id); - if (!inited) { + if (inited) { + // Prefetch already set up by initContainer, don't interfere return options; } @@ -125,11 +127,7 @@ export const prefetchPlugin = (): ModuleFederationRuntimePlugin => ({ prefetchUrl = getResourceUrl(snapshot, snapshot.prefetchEntry as string); } - const index = loadingArray.findIndex((loading) => loading.id === id); - // clear cache - if (index !== -1) { - loadingArray.splice(index, 1); - } + // Only set up prefetch if not already done by initContainer const promise = instance.loadEntry(prefetchUrl).then(async () => { const projectExports = instance!.getProjectExports(); if (projectExports instanceof Promise) { diff --git a/packages/esbuild/src/adapters/lib/manifest.ts b/packages/esbuild/src/adapters/lib/manifest.ts index 6aaaa3280a0..3a7004103fe 100644 --- a/packages/esbuild/src/adapters/lib/manifest.ts +++ b/packages/esbuild/src/adapters/lib/manifest.ts @@ -98,7 +98,7 @@ export const writeRemoteManifest = async (config: any, result: BuildResult) => { const envType = process.env['NODE_ENV'] === 'development' ? 'local' - : process.env['NODE_ENV'] ?? ''; + : (process.env['NODE_ENV'] ?? ''); const publicPath = config.publicPath || 'auto'; let containerName: string = ''; diff --git a/packages/rsbuild-plugin/README.md b/packages/rsbuild-plugin/README.md index bbf537dd4c3..1ed0d41acce 100644 --- a/packages/rsbuild-plugin/README.md +++ b/packages/rsbuild-plugin/README.md @@ -11,7 +11,8 @@ npm install @module-federation/enhanced ``` ### Rsbuild App -``` js + +```js import { pluginModuleFederation } from '@module-federation/rsbuild-plugin'; import { defineConfig } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; @@ -34,7 +35,8 @@ export default defineConfig({ ``` ### Rslib Module -``` js + +```js import { pluginModuleFederation } from '@module-federation/rsbuild-plugin'; import { defineConfig } from '@rslib/core'; diff --git a/packages/rspress-plugin/README.md b/packages/rspress-plugin/README.md index 46a832785f3..3ad43d0342b 100644 --- a/packages/rspress-plugin/README.md +++ b/packages/rspress-plugin/README.md @@ -18,7 +18,7 @@ nx serve rslib-module Dev package -1. +1. ``` nx dev rslib-module diff --git a/packages/runtime-plugins/inject-external-runtime-core-plugin/README.md b/packages/runtime-plugins/inject-external-runtime-core-plugin/README.md index 692932534d5..672651f15a2 100644 --- a/packages/runtime-plugins/inject-external-runtime-core-plugin/README.md +++ b/packages/runtime-plugins/inject-external-runtime-core-plugin/README.md @@ -1,7 +1,7 @@ -# `@module-federation/inject-external-runtime-core-plugin` +# `@module-federation/inject-external-runtime-core-plugin` -This runtime plugin will inject `@module-federation/runtime-core` . +This runtime plugin will inject `@module-federation/runtime-core` . -And the plugin will be automatic applied when set `experiments.externalRuntime: 'provide'` by build plugin. +And the plugin will be automatic applied when set `experiments.externalRuntime: 'provide'` by build plugin. The provider can use host's runtime when set `experiments.externalRuntime: true`. diff --git a/tools/rslib-plugin/README.md b/tools/rslib-plugin/README.md index 32a2d9e1970..8ed6b8dbe15 100644 --- a/tools/rslib-plugin/README.md +++ b/tools/rslib-plugin/README.md @@ -9,6 +9,7 @@ An Nx plugin that provides executors for building and developing with [Rslib](ht Builds your library using Rslib. **Options:** + - `configFile` (string): Path to the rslib config file (default: `rslib.config.ts`) - `outputPath` (string): Output directory for build artifacts - `watch` (boolean): Enable watch mode (default: `false`) @@ -36,6 +37,7 @@ Builds your library using Rslib. Runs Rslib in development mode with hot reloading. **Options:** + - `configFile` (string): Path to the rslib config file (default: `rslib.config.ts`) - `port` (number): Port to serve on (default: `3001`) - `host` (string): Host to serve on (default: `localhost`) @@ -65,6 +67,7 @@ Runs Rslib in development mode with hot reloading. Simple echo executor for testing the plugin. **Options:** + - `message` (string): Message to echo (default: `"Hello from rslib executor!"`) ## Usage @@ -72,11 +75,13 @@ Simple echo executor for testing the plugin. To use this plugin in your Nx workspace: 1. Install the required dependencies: + ```bash npm install @rslib/core ``` 2. Register the plugin in your `nx.json`: + ```json { "plugins": ["tools/rslib-plugin"] @@ -84,6 +89,7 @@ To use this plugin in your Nx workspace: ``` 3. Configure your project's `project.json` to use the rslib executors: + ```json { "targets": { @@ -98,6 +104,7 @@ To use this plugin in your Nx workspace: ``` 4. Create an `rslib.config.ts` file in your project root: + ```typescript import { defineConfig } from '@rslib/core'; @@ -109,7 +116,7 @@ To use this plugin in your Nx workspace: }, { format: 'cjs', - } + }, ], }); ``` @@ -117,21 +124,25 @@ To use this plugin in your Nx workspace: ## Examples ### Building a library + ```bash nx run my-lib:build ``` ### Running in development mode + ```bash nx run my-lib:dev ``` ### Building with custom config + ```bash nx run my-lib:build --configFile=custom.rslib.config.ts ``` ### Running in watch mode + ```bash nx run my-lib:dev --mode=watch ``` @@ -158,4 +169,4 @@ This plugin supports Rslib's Module Federation capabilities. Use the `mf-dev` mo - Nx >= 21.0.0 - @rslib/core >= 0.5.0 -- Node.js >= 18.0.0 \ No newline at end of file +- Node.js >= 18.0.0