# @module-federation/sdk

> A sdk for support module federation

Latest version **2.9.0** (published 2026-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @module-federation/sdk
pnpm add @module-federation/sdk
yarn add @module-federation/sdk
bun add @module-federation/sdk
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.9.0 |
| Published | 2026-08-24 |
| First published | 2023-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 320.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2644 |
| Author | zhanghang |
| Maintainers | zackljackson, heal, shawzhou, gioboa |
| Keywords | Module Federation, sdk |

## Links

- npm: https://www.npmjs.com/package/@module-federation/sdk
- Repository: https://github.com/module-federation/core
- Homepage: https://github.com/module-federation/core#readme
- Issues: https://github.com/module-federation/core/issues
- npm.io page: https://npm.io/package/@module-federation/sdk

## Recent versions

- 2.9.0 (latest) — 2026-08-24
- 0.0.0-feat-mf-ssr-clear-cache-20260914081229 (next) — 2026-09-14
- 0.0.0-feat-node-support-1703050615268 (experimental) — 2023-12-20
- 1.1.0-canary.1 (canary) — 2023-12-05
- 0.0.0-perf-website-code-usage-20260914033703 — 2026-09-14
- 0.0.0-release-v2-9-0-20260824030637 — 2026-08-24
- 0.0.0-fix-runtime-core-set-shared-lib-20260819111025 — 2026-08-19
- 0.0.0-feat-preload-asset-url-dedupe-20260819073808 — 2026-08-19
- 0.0.0-feat-preload-asset-url-dedupe-20260819072341 — 2026-08-19
- 2.8.2 — 2026-08-06
- 0.0.0-feat-operate-openruntime-20260803054425 — 2026-08-03
- 0.0.0-feat-operate-openruntime-20260729120109 — 2026-07-29
- 0.0.0-feat-operate-openruntime-20260729082849 — 2026-07-29
- 2.8.1 — 2026-07-28
- 0.0.0-feat-operate-openruntime-20260726151341 — 2026-07-26
- … 1225 more at https://npm.io/package/@module-federation/sdk/versions

## README

# `@module-federation/sdk` Documentation

- This SDK provides utilities and tools to support the implementation of Module Federation in your projects.
- It contains utility functions for parsing, encoding, and decoding module names, as well as generating filenames for exposed modules and shared packages.
- It also includes a logger for debugging and environment detection utilities.
- Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.

## Usage

```javascript
// The SDK can be used to parse entry strings, encode and decode module names, and generate filenames for exposed modules and shared packages.
// It also includes a logger for debugging and environment detection utilities.
// Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.
import { parseEntry, encodeName, decodeName, generateExposeFilename, generateShareFilename, createLogger, isBrowserEnv, isBrowserEnvValue, isDebugMode, getProcessEnv, generateSnapshotFromManifest } from '@module-federation/sdk';

// Parse an entry string into a RemoteEntryInfo object
parseEntry('entryString');

// Encode a module name with a prefix and optional extension
encodeName('moduleName', 'prefix');

// Decode a module name with a prefix and optional extension
decodeName('encodedModuleName', 'prefix');

// Generate a filename for an exposed module
generateExposeFilename('exposeName', true);

// Generate a filename for a shared package
generateShareFilename('packageName', true);

// Create a logger
const logger = createLogger('identifier');

// Check if the current environment is a browser
const inBrowser = isBrowserEnv();
const inBrowserStatic = isBrowserEnvValue;

// Check if the current environment is in debug mode
isDebugMode();

// Get the process environment
getProcessEnv();

// Generate a snapshot from a manifest
generateSnapshotFromManifest(manifest, options);
```

### parseEntry

- Type: `parseEntry(str: string, devVerOrUrl?: string, separator?: string) `
- Parses a string into a RemoteEntryInfo object.

### encodeName

- Type: `encodeName(name: string, prefix?: string, withExt?: boolean)`
- Encodes a name with a prefix and optional extension.

### decodeName

- Type: `decodeName(name: string, prefix?: string, withExt?: boolean)`
- Decodes a name with a prefix and optional extension.

### generateExposeFilename

- Type: `generateExposeFilename(exposeName: string, withExt: boolean)`
- Generates a filename for an expose.

### generateShareFilename

- Type: `generateShareFilename(pkgName: string, withExt: boolean)`
- Generates a filename for a shared package.

### createLogger

- Type: `createLogger(prefix: string)`
- Creates a logger for debugging.

### isBrowserEnv

- Type: `isBrowserEnv(): boolean`
- Checks if the current environment is a browser.

### isBrowserEnvValue

- Type: `isBrowserEnvValue: boolean`
- Static browser environment flag (tree-shakable when ENV_TARGET is defined).

### isDebugMode

- Type: `isDebugMode()`
- Checks if the current environment is in debug mode.

### getProcessEnv

- Type: `getProcessEnv()`
- Gets the process environment.

### generateSnapshotFromManifest

- Type: `generateSnapshotFromManifest(manifest: Manifest, options?: IOptions)`
- Generates a snapshot from a manifest.

## Testing

The SDK uses Jest for testing. The configuration can be found in `jest.config.js`. The tests are located in the **tests** directory.

---
_Source: https://npm.io/package/@module-federation/sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
