rslib-best-practices_skill

This skill helps you implement and review Rslib best practices across configuration, CLI, outputs, and dependencies to ensure robust libraries.
  • JavaScript

36

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

3 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill rstackjs/agent-skills --skill rslib-best-practices

  • SKILL.md2.7 KB

Overview

This skill documents Rslib best practices for configuration, CLI workflows, output formats, declaration files, dependency handling, build optimization, and toolchain integrations. It is written to help you write, review, or troubleshoot Rslib library projects with clear, actionable guidance. Use it to align projects with common conventions and to avoid common packaging and build pitfalls.

How this skill works

The skill inspects recommended Rslib configuration patterns (rslib.config.ts with defineConfig) and common Rsbuild/Rspack interactions. It summarizes CLI commands, output format recommendations, declaration file settings, dependency placement rules, build optimization tips, testing and documentation integration, and debugging steps. Apply these checks when authoring or auditing a library to ensure compatibility and reliable consumer installs.

When to use it

  • When creating a new Rslib library and setting up rslib.config.ts
  • When reviewing build output, package.json exports, or declaration files
  • When choosing bundle vs bundleless mode for component or Node libraries
  • When troubleshooting missing dependencies or incorrect runtime resolution
  • When integrating tests and docs with Rstest and Rspress

Best practices

  • Author rslib.config.ts and use defineConfig; check lib.* and rsbuild-related options first
  • Prefer pure ESM packages with "type": "module" for web/component libraries
  • Use bundleless mode (output.target = 'web') for component libraries and bundle mode for Node utilities
  • Enable declaration generation (lib.dts: true) and consider lib.dts.tsgo for faster types
  • Place bundle-included libs in devDependencies for bundle mode; keep runtime libs in dependencies/peerDependencies
  • Align lib.syntax target with actual compatibility needs and avoid format-specific APIs

Example use cases

  • Set up a component library: bundleless build, ESM output, correct exports, and TypeScript declarations
  • Migrate a Node utility to bundle mode and move bundled libs into devDependencies
  • Audit a package.json exports to match actual ESM/CJS outputs and .d.ts locations
  • Speed up type emission with the experimental tsgo feature when using @typescript/native-preview
  • Add tests and docs using @rstest/adapter-rslib and @rspress plugins for previews and API docs

FAQ

Run rslib inspect and read generated files under dist/.rsbuild; use DEBUG=rsbuild to trace resolution.

When should I choose bundleless vs bundle mode?

Prefer bundleless (web target) for component libraries to keep consumption flexible; use bundle mode for Node-focused utilities that need a single bundled artifact.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
rslib-best-practices skill by rstackjs/agent-skills | VeilStrat