rstackjs avatar

Rslib Best Practices

This covers the practical stuff you need when building libraries with Rslib: config patterns with defineConfig, when to use bundle versus bundleless mode, setting up declaration files with the experimental tsgo feature, and getting your package.json exports field right so consumers don't hit missing dependency errors. It pushes you toward pure ESM and includes specific CLI commands for watch mode and config inspection. The dependency guidance is solid, especially the bit about devDependencies in bundle mode. If you're shipping a component library or Node utility with Rslib, this gives you the opinionated defaults and debugging patterns to avoid the common gotchas.

skills.sh installs
1.1K
GitHub stars
98
last updated
Aug 21, 2026

Install

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

Installs into .claude/skills of the current project.

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

Sponsors

Details

Repository
github.com/rstackjs/agent-skills
Categories
DevOps & CI/CD, Documentation, AI & Agent Building, Debugging, Automation & Workflows, CLI & Terminal
First seen
Jun 3, 2026

More from rstackjs/agent-skills

All 12
1niaka3dayo avatarunity-vrc-world-sdk-3niaka3dayo/agent-skills-vrc-udonVRChat World SDK 3 guide for scene and Inspector setup, component placement, optimization, and upload. Use for VRChat world scene configuration, VRC SDK compone1.1Kskills.sh installs
2orchestra-research avatarweights-and-biasesorchestra-research/ai-research-skillsTrack ML experiments with automatic logging, visualize training in real-time, optimize hyperparameters with sweeps, and manage model registry with W&B - collabo1.1Kskills.sh installs
3K-Dense-AI avatarpkpd-modelingK-Dense-AI/scientific-agent-skillsPharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK/PD and exposure-response, TMDD, P1.1Kskills.sh installs
4eronred avatarweb-to-app-funneleronred/aso-skillsWhen the user wants to design or optimize the funnel that takes web visitors into installing and onboarding the app — including smart app banners, web-to-app de1.1Kskills.sh installs
5mlflow avatarinstrumenting-with-mlflow-tracingmlflow/skillsInstruments Python and TypeScript code with MLflow Tracing for observability. Must be loaded when setting up tracing as part of any workflow including agent eva1.1Kskills.sh installs
6digitalsamba avatarfrontend-designdigitalsamba/claude-code-video-toolkitCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applicat1.1Kskills.sh installs