rslib

Configure Rspack library builds with auto-discovered entries and multi-format outputs.

1|Updated Dec 30, 2025
One-click install
npx skills add https://github.com/Hyperxq/modular-frontend-architecture --skill rslib
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rslib
Source: https://github.com/Hyperxq/modular-frontend-architecture/tree/main/.claude/skills/rslib
Command: npx skills add https://github.com/Hyperxq/modular-frontend-architecture --skill rslib

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rslib codifies reliable, high-performance library build patterns for Rspack-based component libraries so teams avoid brittle manual configs, slow builds, and runtime bundle drift when using Module Federation.

Core Features & Use Cases

  • Auto-discovered entries: Use fast-glob to discover component entries so new components are included automatically without manual registration.
  • Multi-target outputs: Produce Module Federation remotes, ESM, and CJS artifacts to support runtime sharing, native import maps, and npm consumers.
  • Build hygiene: Enforce tsconfig.build.json, exclude tests, gate .d.ts generation to local dev, and require peerDependencies to keep output zero-runtime.
  • Use Case: Build a UI component library that exposes each component as an independent MF remote entry for a Preact shell while also shipping tree-shakable ESM packages.

Quick Start

Run the rslib build command in your library package to produce Module Federation, ESM, and CJS outputs with auto-discovered component entries.

Frequently Asked Questions about rslib

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a component library with Module Federation remotes using Rspack?

Building a component library with Module Federation remotes using Rspack requires defining configurations with @rslib/core. This produces multi-format outputs, including MF remote entries, ESM, and CJS artifacts, ensuring runtime bundle consistency.

What is the best way to auto-discover component entries for a library build?

Auto-discovering component entries for a library build is best achieved using fast-glob. It automatically includes new components without manual registration, ensuring reproducible and fast Rspack builds for your library.

Can I output ESM, CJS, and Module Federation artifacts from a single library package?

You can output ESM, CJS, and Module Federation artifacts from a single library package. This multi-target output approach supports runtime sharing, native import maps, and npm consumers simultaneously.

How do I enforce peerDependencies and exclude tests for a zero-runtime library build?

To enforce peerDependencies and exclude tests for a zero-runtime library build, configure tsconfig.build.json. This build hygiene practice gates .d.ts generation to local dev, keeping the output zero-runtime.

Why does my Rspack library build suffer from runtime bundle drift with Module Federation?

Runtime bundle drift with Module Federation in a Rspack library build occurs due to brittle manual configurations. Codifying reliable build patterns with @rslib/core prevents this drift and ensures reproducible outputs.