Skip to content
rstackjs avatar

Rslib Best Practices

Rules and workflow guide for configuring, building, and troubleshooting Rslib library projects.

CCM score
55 of 100
skills.sh installs
1.1K
GitHub stars
101
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers Rslib config, CLI workflow, output formats, declaration files, dependency handling, and build optimization
  • Includes rslib.config.ts setup, rslib --watch for development, and rslib inspect for verifying resolved configs
  • Enforces pure-ESM output and package.json exports that match emitted JavaScript and declaration files
  • Designed for library authors integrating Rstest, Rspress, and DEBUG=rsbuild troubleshooting

Install

$ npx -y skills add rstackjs/agent-skills --skill rslib-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Rslib best practices

Apply these rules when writing or reviewing Rslib library projects.

Configuration

  • Use rslib.config.ts and defineConfig
  • Check Rslib-specific configurations first (e.g., lib.*), and also leverage Rsbuild configurations (e.g., source.*, output.*, tools.*) as needed
  • For deep-level or advanced configuration needs, use tools.rspack or tools.bundlerChain to access Rspack's native configurations
  • In TypeScript projects, prefer tsconfig.json path aliases

CLI

  • Use rslib to build
  • Use rslib --watch to build in watch mode for local development
  • Use rslib inspect to inspect final Rslib/Rsbuild/Rspack configs

Output

  • Prefer to build pure-ESM package with "type": "module" in package.json
  • Prefer to use bundleless mode with output.target set to 'web' when building component libraries
  • Prefer to use bundle mode when building Node.js utility libraries
  • Ensure exports field in package.json is correctly configured and matches the actual JavaScript output and declaration files output of different formats (ESM, CJS, etc.)

Declaration files

Details

Repository
github.com/rstackjs/agent-skills
Category
Frontend & UI Code
First seen
Jun 3, 2026

More from rstackjs/agent-skills

All 12

Similar to Rslib Best Practices

More Frontend & UI Code