rslib-best-practices
Skill97 starsChanged 3 months agoMITView on GitHub
Configure, review, or troubleshoot Rslib library builds, output formats, declarations, dependency handling, and integrations.
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 2 are distinctive, and 17 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use rslib.config.ts and defineConfig
- Very specific: line 13
Check Rslib-specific configurations first (e.g., lib.*), and also leverage Rsbuild configurations (e.g., source.*, output.*, tools.*) as …
- Very specific: line 19
Use rslib to build
- Very specific: line 20
Use rslib --watch to build in watch mode for local development
- Very specific: line 21
Use rslib inspect to inspect final Rslib/Rsbuild/Rspack configs
- Very specific: line 25
Prefer to build pure-ESM package with "type": "module" in package.json
- Very specific: line 26
Prefer to use bundleless mode with output.target set to 'web' when building component libraries
- Very specific: line 27
Prefer to use bundle mode when building Node.js utility libraries
- Very specific: line 28
Ensure exports field in package.json is correctly configured and matches the actual JavaScript output and declaration files output of …
- Very specific: line 32
Prefer to enable declaration file generation with lib.dts: true or detailed configurations
- Very specific: line 37
Prefer to place dependencies to be bundled in devDependencies in bundle mode and dependencies in dependencies and peerDependencies will be …
- Very specific: line 38
Verify the build output and dependency specifiers in package.json carefully to ensure no missing dependency errors occur when consumers …
- Very specific: line 42
Keep syntax target in lib.syntax aligned with real compatibility requirements to enable better optimizations
- Distinctive: line 43
Avoid format-specific APIs in source code for better compatibility with different output formats
- Distinctive: line 44
Prefer lightweight dependencies to reduce bundle size
- Very specific: line 48
Prefer to use Rstest with @rstest/adapter-rslib for writing tests
- Very specific: line 49
Prefer to use Rspress for writing library documentation, with @rspress/plugin-preview and @rspress/plugin-api-docgen for component previews …
- Very specific: line 53
Run with DEBUG=rsbuild when diagnosing config resolution or plugin behavior
- Very specific: line 54
Read generated files in dist/.rsbuild to confirm final Rsbuild/Rspack config, not assumed config
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
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
- Prefer to enable declaration file generation with
lib.dts: trueor detailed configurations - For faster type generation, enable
lib.dts.tsgoexperimental feature with@typescript/native-previewinstalled
Dependencies
- Prefer to place dependencies to be bundled in
devDependenciesin bundle mode and dependencies independenciesandpeerDependencieswill be automatically externalized (not bundled) by default - Verify the build output and dependency specifiers in
package.jsoncarefully to ensure no missing dependency errors occur when consumers install and use this package
Build optimization
- Keep syntax target in
lib.syntaxaligned with real compatibility requirements to enable better optimizations - Avoid format-specific APIs in source code for better compatibility with different output formats
- Prefer lightweight dependencies to reduce bundle size
Toolchain integration
- Prefer to use Rstest with
@rstest/adapter-rslibfor writing tests - Prefer to use Rspress for writing library documentation, with
@rspress/plugin-previewand@rspress/plugin-api-docgenfor component previews and API docs
Debugging
- Run with
DEBUG=rsbuildwhen diagnosing config resolution or plugin behavior - Read generated files in
dist/.rsbuildto confirm final Rsbuild/Rspack config, not assumed config
Documentation
- For the latest Rslib docs, read https://rslib.rs/llms.txt
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- create-draft-release-notesSkill
- mdx-to-markdownSkill
- pr-creatorSkill
- release-blog-writerSkill
- rstack-docs-writerSkill
- rstack-eco-ci-debugSkill
- rstack-repo-maintainSkill
- rstack-skill-evaluatorSkill
- migrate-to-rsbuildSkill
- migrate-to-rslibSkill
- migrate-to-rslintSkill
- migrate-to-rstestSkill
- rsbuild-best-practicesSkill
- rsbuild-v2-upgradeSkill
- rsdoctor-analysisSkill
- rsdoctor-v2-upgradeSkill
- rslib-modern-packageSkill
- rspack-best-practicesSkill
- rspack-debuggingSkill
- rspack-split-chunksSkill
- rspack-tracingSkill
- rspack-v2-upgradeSkill
- rspress-best-practicesSkill
- rspress-custom-themeSkill
- rspress-description-generatorSkill
- rspress-docs-generatorSkill
- rspress-v2-upgradeSkill
- rstest-best-practicesSkill
- rstest-debuggingSkill
- storybook-rsbuildSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

