
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-codeInstalls 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.tsanddefineConfig - 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.rspackortools.bundlerChainto access Rspack's native configurations - In TypeScript projects, prefer
tsconfig.jsonpath aliases
CLI
- Use
rslibto build - Use
rslib --watchto build in watch mode for local development - Use
rslib inspectto inspect final Rslib/Rsbuild/Rspack configs
Output
- Prefer to build pure-ESM package with
"type": "module"inpackage.json - Prefer to use bundleless mode with
output.targetset to'web'when building component libraries - Prefer to use bundle mode when building Node.js utility libraries
- Ensure
exportsfield inpackage.jsonis 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