<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Rslib Blog</title>
        <link>https://rslib.rs/</link>
        <description>Rslib is a library development tool that leverages the well-designed configurations and plugins of Rsbuild.</description>
        <lastBuildDate>Mon, 09 Nov 2026 06:31:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[Announcing Rslib 1.0]]></title>
            <link>https://rslib.rs/blog/v1-0</link>
            <guid isPermaLink="false">/blog/v1-0</guid>
            <pubDate>Thu, 03 Sep 2026 15:00:00 GMT</pubDate>
            <description><![CDATA[Rslib 1.0 is here, focusing on library build capabilities across use cases and the developer experience, with upgrade guidance and a look at what's next.]]></description>
            <content:encoded><![CDATA[<!--$--><h1 class="rp-toc-include" id="announcing-rslib-10"><a href="#announcing-rslib-10" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Announcing Rslib 1.0<!-- --> </h1>
<p><em>September 3, 2026</em></p>
<div class="group-n_jNI7 root-YZxMH8"><div class="root-Sr_5x3 groupItem-m5U5nn"><img src="https://github.com/Timeless0911.png" alt="Chenwei Dai" class="avatar-XCZJhu" loading="lazy" decoding="async"/><div class="content-BhgM4E"><div class="nameRow-U9Q3S8"><div class="name-k91bx6">Chenwei Dai</div><div class="links-jK83Yg"><a href="https://github.com/Timeless0911" target="_blank" rel="noopener noreferrer" class="link-yDHY4Y" aria-label="Chenwei Dai&#x27;s GitHub"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg></a></div></div><div class="title-MMKZdf">@Timeless0911</div></div></div><div class="root-Sr_5x3 groupItem-m5U5nn"><img src="https://github.com/elecmonkey.png" alt="Elecmonkey" class="avatar-XCZJhu" loading="lazy" decoding="async"/><div class="content-BhgM4E"><div class="nameRow-U9Q3S8"><div class="name-k91bx6">Elecmonkey</div><div class="links-jK83Yg"><a href="https://github.com/elecmonkey" target="_blank" rel="noopener noreferrer" class="link-yDHY4Y" aria-label="Elecmonkey&#x27;s GitHub"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg></a></div></div><div class="title-MMKZdf">@elecmonkey</div></div></div></div>
<p><img src="https://assets.rspack.rs/rslib/rslib-og-1-0.png" alt="Rslib 1.0, the Rsbuild-based library development tool released in September 2026"/></p>
<p>We&#x27;re excited to announce that Rslib 1.0 is now available!</p>
<p>Rslib is a library development tool based on <a href="https://rsbuild.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rsbuild</a>, designed to help developers build different types of JavaScript libraries in a simple and straightforward way, including utility libraries, UI component libraries, CLIs, and agent applications.</p>
<h2 class="rp-toc-include" id="why-rslib"><a href="#why-rslib" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Why Rslib</h2>
<p>Rslib supports a wide range of library publishing and consumption scenarios, enabling library developers to benefit from the mature capabilities and ecosystem of application build tooling. Its core strengths are:</p>
<ul>
<li><strong>Builds on the Rspack and webpack ecosystems</strong>: Rslib supports Rsbuild plugins, as well as many plugins and loaders from the <a href="https://rspack.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rspack</a> and <a href="https://webpack.js.org/" target="_blank" rel="noopener noreferrer" class="rp-link">webpack</a> ecosystems. If an application also uses Rsbuild or Rspack, developers can share configurations and plugins between the application and library, reuse their existing engineering experience, and reduce duplicate configuration and maintenance.</li>
<li><strong>Supports building Module Federation output</strong>: In addition to common formats such as ESM and CJS, Rslib can produce <a href="/guide/advanced/module-federation" class="rp-link">Module Federation output</a>, allowing libraries to be loaded by multiple applications as remote modules at runtime. It also provides support for local development and integration workflows.</li>
<li><strong>A unified library build pipeline</strong>: Rslib can compile JavaScript, transform framework syntax, generate declarations, and process static assets in a single build, eliminating the need to switch between multiple tools or manually stitch together a build pipeline. Rslib also keeps pace with developments in the TypeScript and framework ecosystems, supporting capabilities such as TypeScript 7 declaration generation and React Compiler.</li>
</ul>
<h2 class="rp-toc-include" id="from-v0-to-v1"><a href="#from-v0-to-v1" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>From 0.x to 1.0</h2>
<p>Since the <a href="/blog/introducing-rslib" class="rp-link">public launch of Rslib 0.7</a>, we have shipped 16 minor releases. During this period, Rslib introduced several features and improvements, including:</p>
<ul>
<li>
<p><strong>Faster builds and smaller output</strong>: In a benchmark project containing 10,000 React components, Rslib 1.0 reduced uncached build time by <strong>approximately 24.3%</strong>, cached build time by <strong>approximately 56.7%</strong>, output size before Gzip compression by <strong>approximately 32.2%</strong>, and output size after compression by <strong>approximately 4.1%</strong>, compared with Rslib 0.7.0.</p>
<div class="rp-table-scroll-container rp-scrollbar"><table><thead><tr><th>Rslib version</th><th>Production build (without cache)</th><th>Production build (with cache)</th><th>Output size (before/after Gzip)</th></tr></thead><tbody><tr><td>0.7.0</td><td><strong>1.212 s</strong></td><td><strong>1.125 s</strong></td><td><strong>7.64 MiB / 1.40 MiB</strong></td></tr><tr><td>1.0.0</td><td><strong>0.918 s</strong></td><td><strong>0.487 s</strong></td><td><strong>5.19 MiB / 1.35 MiB</strong></td></tr></tbody></table></div>
</li>
<li>
<p><strong>Faster declaration generation</strong>: Rslib supports faster declaration generation with <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/" target="_blank" rel="noopener noreferrer" class="rp-link">TypeScript 7</a> or <a href="/config/lib/dts#dtsisolated" class="rp-link">Isolated Declarations</a>, though actual gains vary by project. The following table compares the different approaches using the Rsbuild repository:</p>
<div class="rp-table-scroll-container rp-scrollbar"><table><thead><tr><th>Approach</th><th>Time</th><th>Performance improvement</th></tr></thead><tbody><tr><td>TypeScript 6</td><td><strong>9.7 s</strong></td><td>Baseline</td></tr><tr><td>TypeScript 7</td><td><strong>4.1 s</strong></td><td><strong>~2.4×</strong></td></tr><tr><td>Isolated Declarations</td><td><strong>2.3 s</strong></td><td><strong>~4.2×</strong></td></tr></tbody></table></div>
</li>
<li>
<p><strong>More comprehensive component library support</strong>: Rslib supports building React, Vue, Svelte, or Solid component libraries, and further improves style and asset handling for scenarios including <code>new URL()</code>, Web Workers, and Wasm.</p>
</li>
<li>
<p><strong>More flexible usage</strong>: Simple projects can be built without a configuration file, while configuration can be added as needed. Rslib can be used directly through the CLI or integrated into scripts and other tools through its JavaScript API.</p>
</li>
<li>
<p><strong>A smoother development experience</strong>: Rslib works with <a href="https://rstest.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rstest</a>, <a href="https://rspress.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rspress</a>, and <a href="https://rsdoctor.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rsdoctor</a> for testing, documentation, and output diagnostics. Through Agent Skills, it also provides Coding Agents with best practices for working with Rslib.</p>
</li>
</ul>
<p>As these capabilities have continued to improve and been validated across numerous production projects, Rslib&#x27;s configuration model and JavaScript API have also stabilized. Starting with 1.0, Rslib will continue to evolve on the foundation of a stable public API and in accordance with Semantic Versioning (SemVer).</p>
<h2 class="rp-toc-include" id="output-formats"><a href="#output-formats" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Output formats for different use cases</h2>
<p>A library can be published as an npm package or built as a remote module with <a href="https://module-federation.io/" target="_blank" rel="noopener noreferrer" class="rp-link">Module Federation</a> for multiple applications to load at runtime, enabling independent deployment and updates. Conventional library build tools primarily focus on npm package distribution, while Rslib also supports building Module Federation output and provides an HMR-enabled development mode for integration with host applications or Storybook.</p>
<p>For the runtime environments and consumption patterns described above, Rslib provides the following output formats:</p>
<div class="rp-table-scroll-container rp-scrollbar"><table><thead><tr><th>Output format</th><th>Use case</th><th>How it is used</th></tr></thead><tbody><tr><td><a href="/guide/basic/output-format#esm--cjs" class="rp-link">ESM</a>, <a href="/guide/basic/output-format#esm--cjs" class="rp-link">CJS</a></td><td>Node.js and downstream builds</td><td>Loaded by Node.js or passed as a dependency to application build tools</td></tr><tr><td><a href="/guide/basic/output-format#umd" class="rp-link">UMD</a>, <a href="/guide/basic/output-format#iife" class="rp-link">IIFE</a></td><td>Direct loading in browsers</td><td>Used directly in browsers through a <code>&lt;script&gt;</code> tag</td></tr><tr><td><a href="/guide/advanced/module-federation" class="rp-link">Module Federation</a></td><td>Cross-application runtime loading</td><td>Loaded as a remote module at runtime</td></tr></tbody></table></div>
<p>When you need to generate outputs in multiple formats, you can use the <a href="/config/lib/format" class="rp-link">format</a> configuration to define each output separately and configure its build settings as needed in the same file, without maintaining multiple build scripts.</p>
<p>Among these formats, Rslib has focused on optimizing ESM output, making it more amenable to static analysis and enabling code splitting. This makes it easier for downstream build tools to perform tree shaking and further processing. Rslib also optimizes the default handling of external dependencies in ESM output, preserving module-loading semantics from the source code more accurately and reducing behavioral differences introduced by build transformations.</p>
<p>In addition to common module formats, Rslib offers an experimental <a href="/config/lib/experiments#experimentsexe" class="rp-link">executable generation</a> capability. This feature is based on <a href="https://nodejs.org/api/single-executable-applications.html" target="_blank" rel="noopener noreferrer" class="rp-link">Node.js SEA</a> and supports a single bundled entry targeting Node.js. The generated executable can run on target systems where Node.js is not installed, making it suitable for distributing CLIs and other Node.js programs.</p>
<h2 class="rp-toc-include" id="build-modes"><a href="#build-modes" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Flexible build modes</h2>
<p>Output formats determine how a library is loaded, while build modes determine how its internal modules are organized. Rslib supports <a href="/guide/basic/output-structure#bundle--bundleless" class="rp-link">bundle and bundleless</a> build modes to accommodate different delivery requirements:</p>
<ul>
<li><strong>Bundle mode</strong> (<code>bundle: true</code>): Rslib starts from the entry point and bundles internal modules into fewer files. It can also produce multiple chunks as needed through code splitting, making it suitable for SDKs, CLIs, Node.js utility libraries, and other scenarios where a simpler output structure and easier distribution are preferred.</li>
<li><strong>Bundleless mode</strong> (<code>bundle: false</code>): Rslib compiles source files individually, preserves the directory and module structure of the source code, and handles module references, file extensions, styles, static assets, and more. This mode is suitable for component libraries, utility libraries, and internal monorepo packages, making debugging easier and allowing downstream consumers to perform on-demand loading and further builds.</li>
</ul>
<p>For a single-entry library with three source files, the two modes produce the following output structures:</p>
<img src="https://assets.rspack.rs/rslib/assets/rslib-v1-0-bundle-mode.png" alt="Comparison of output structures in bundle and bundleless modes" width="550" style="display:block;margin:0 auto"/>
<p>You can choose the appropriate build mode based on how the library is delivered and consumed. When you need to support different consumption scenarios, you can also generate both bundle and bundleless outputs in the same project.</p>
<h2 class="rp-toc-include" id="declaration-generation"><a href="#declaration-generation" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Fast declaration generation</h2>
<p>For TypeScript libraries, declaration files affect not only type hints in editors but also whether downstream projects can resolve the library&#x27;s types correctly. With the <a href="/config/lib/dts" class="rp-link">dts</a> configuration, Rslib can generate declaration files while building JavaScript output. In bundleless mode, Rslib also handles path aliases and import extensions in declaration files based on the actual output, keeping the declarations aligned with the JavaScript output and compatible with module resolution modes such as NodeNext.</p>
<p>As a project grows, declaration generation can become an increasingly time-consuming part of the build. Rslib provides two ways to speed it up:</p>
<ul>
<li><strong>Use TypeScript 7</strong>: When a project uses TypeScript 7 or later, Rslib automatically uses <a href="/config/lib/dts#dtstsgo" class="rp-link">native TypeScript (tsgo)</a> to generate declaration files, speeding up declaration generation while retaining type checking.</li>
<li><strong>Use isolated declarations</strong>: Projects that want to reduce build times further can use the experimental <a href="/config/lib/dts#dtsisolated" class="rp-link">isolated declarations</a> mode. During the Rspack build, Rslib quickly generates declaration files for modules in the build dependency graph, further reducing declaration generation overhead.</li>
</ul>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__title">rslib.config.ts</div><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts" data-title="rslib.config.ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">export</span><span style="color:var(--shiki-token-keyword)"> default</span><span style="color:var(--shiki-foreground)"> {</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  dts</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-foreground)"> {</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    isolated</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-constant)"> true</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  }</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">};</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p>Note that this mode does not perform type checking, so it is best used with a separate high-performance type-checking process. For example, in a monorepo, regular builds can use Rslib to generate declaration files quickly for each package, while CI or a <code>pre-commit</code> hook runs full type checking centrally through <a href="https://rslint.rs/guide/type-checking" target="_blank" rel="noopener noreferrer" class="rp-link">rslint --type-check</a>.</p>
<h2 class="rp-toc-include" id="framework-support"><a href="#framework-support" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Out-of-the-box multi-framework support</h2>
<p>Component libraries are one of Rslib&#x27;s primary use cases. React, Vue, Svelte, and Solid each have different component files, compilation methods, and runtime conventions. Rslib integrates their compilers through the corresponding <a href="/config/rsbuild/plugins" class="rp-link">Rsbuild plugins</a>. Library build capabilities such as output formats and build modes are configured consistently through Rslib, while plugins and compilers handle framework syntax. This gives component libraries across different frameworks similar configurations and build workflows.</p>
<p>When creating a new project, you can select the corresponding framework template through <code>create-rslib</code> to get the required plugins and base configuration out of the box. Existing projects can register the relevant plugins as needed.</p>
<p>For example, a React component library can register <a href="https://rsbuild.rs/plugins/list/plugin-react" target="_blank" rel="noopener noreferrer" class="rp-link">@rsbuild/plugin-react</a> to compile JSX and TSX. Through this plugin, you can also enable the Rust implementation of <a href="/guide/solution/react#react-compiler" class="rp-link">React Compiler</a> integrated into SWC to automatically optimize component code during the build, without requiring a separate Babel integration:</p>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__title">rslib.config.ts</div><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts" data-title="rslib.config.ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { pluginReact } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rsbuild/plugin-react&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { defineConfig } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rslib/core&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">export</span><span style="color:var(--shiki-token-keyword)"> default</span><span style="color:var(--shiki-token-function)"> defineConfig</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  bundle</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-constant)"> false</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  output</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-foreground)"> {</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    target</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;web&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  }</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  plugins</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-foreground)"> [</span></span>
<span class="line"><span style="color:var(--shiki-token-function)">    pluginReact</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      reactCompiler</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-constant)"> true</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    })</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  ]</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">});</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p>For component libraries that leave JSX compilation to the application, Rslib can <a href="/guide/solution/react#jsx-transform" class="rp-link">preserve JSX</a> in bundleless mode and emit <code>.jsx</code> files, allowing downstream applications to transform them according to their target environments and build configurations.</p>
<blockquote>
<p>See the <a href="/guide/solution/react" class="rp-link">React guide</a>, <a href="/guide/solution/vue" class="rp-link">Vue guide</a>, <a href="/guide/solution/svelte" class="rp-link">Svelte guide</a>, and <a href="/guide/solution/solid" class="rp-link">Solid guide</a> to learn more.</p>
</blockquote>
<h2 class="rp-toc-include" id="styles-and-assets"><a href="#styles-and-assets" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Comprehensive style and asset support</h2>
<p>Rslib can process styles, static assets, Web Workers, and Wasm while building JavaScript output, handling references between files according to the output format and build configuration so that the generated output can either be consumed directly or passed to a downstream build tool.</p>
<p><strong>Styles</strong></p>
<p>Rslib supports CSS Modules, PostCSS, style extraction, inlining, minification, and more out of the box, and selects an appropriate style output based on the build mode. Sass, Less, Stylus, and Tailwind CSS can be integrated through Rsbuild plugins.</p>
<div class="rp-codeblock language-js"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="js"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./style.scss&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> styles </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./button.module.css&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p><strong>Static assets</strong></p>
<p>Static assets such as images, fonts, audio, and video can be imported in JavaScript with <code>import</code> or referenced in CSS with <code>url()</code>. Rslib supports importing JSON files as JSON modules with <a href="https://github.com/tc39/proposal-import-attributes" target="_blank" rel="noopener noreferrer" class="rp-link">Import Attributes</a>. You can also import local assets with <code>new URL()</code>; Rslib emits the corresponding files and updates references to them in the generated output.</p>
<div class="rp-codeblock language-js"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="js"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> data </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./data.json&#x27;</span><span style="color:var(--shiki-token-keyword)"> with</span><span style="color:var(--shiki-foreground)"> { type</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;json&#x27;</span><span style="color:var(--shiki-foreground)"> };</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> logo </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./logo.svg&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">const</span><span style="color:var(--shiki-token-constant)"> dataFile</span><span style="color:var(--shiki-token-keyword)"> =</span><span style="color:var(--shiki-token-keyword)"> new</span><span style="color:var(--shiki-token-function)"> URL</span><span style="color:var(--shiki-foreground)">(</span><span style="color:var(--shiki-token-string-expression)">&#x27;./data.txt&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span><span style="color:var(--shiki-token-keyword)"> import</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">meta</span><span style="color:var(--shiki-foreground)">.url);</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p><strong>Web Workers and Wasm</strong></p>
<p>Rslib recognizes standard Web Worker syntax and builds Worker entries and their dependencies, without requiring separate entry points or copy scripts. For Wasm, Rslib supports syntax such as <a href="https://github.com/WebAssembly/esm-integration" target="_blank" rel="noopener noreferrer" class="rp-link">WebAssembly ESM Integration</a> and <a href="https://github.com/tc39/proposal-source-phase-imports" target="_blank" rel="noopener noreferrer" class="rp-link">Source Phase Imports</a>. It can generate the code required for loading and instantiation or preserve Wasm imports for downstream build tools or target runtimes that support the corresponding capabilities.</p>
<div class="rp-codeblock language-js"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="js"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { add } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./add.wasm&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> source addModule </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;./add.wasm&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">const</span><span style="color:var(--shiki-token-constant)"> worker</span><span style="color:var(--shiki-token-keyword)"> =</span><span style="color:var(--shiki-token-keyword)"> new</span><span style="color:var(--shiki-token-function)"> Worker</span><span style="color:var(--shiki-foreground)">(</span><span style="color:var(--shiki-token-keyword)">new</span><span style="color:var(--shiki-token-function)"> URL</span><span style="color:var(--shiki-foreground)">(</span><span style="color:var(--shiki-token-string-expression)">&#x27;./worker.ts&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span><span style="color:var(--shiki-token-keyword)"> import</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">meta</span><span style="color:var(--shiki-foreground)">.url));</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<blockquote>
<p>See <a href="/guide/advanced/css" class="rp-link">CSS</a>, <a href="/guide/advanced/static-assets" class="rp-link">Static assets</a>, <a href="/guide/advanced/web-workers" class="rp-link">Web Workers</a>, and <a href="/guide/advanced/wasm" class="rp-link">Wasm</a> to learn more.</p>
</blockquote>
<h2 class="rp-toc-include" id="usage-options"><a href="#usage-options" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Usage that adapts to your needs</h2>
<p>For simple projects, Rslib supports building directly with <a href="/guide/basic/cli#rslib" class="rp-link">command-line options</a>, without requiring a configuration file:</p>
<div class="rp-codeblock language-bash"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="bash"><code><span class="line"><span style="color:var(--shiki-token-function)">npx</span><span style="color:var(--shiki-token-string)"> rslib</span><span style="color:var(--shiki-token-string)"> build</span><span style="color:var(--shiki-token-string)"> --entry</span><span style="color:var(--shiki-token-string)"> src/index.ts</span><span style="color:var(--shiki-token-string)"> --format</span><span style="color:var(--shiki-token-string)"> esm</span><span style="color:var(--shiki-token-string)"> --dts</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p>As your build requirements grow, you can use a configuration file to gain more control over the build. Rslib 1.0 simplifies the configuration structure: if you only need a single default ESM output, you can omit the <code>lib</code> field and define the configuration directly at the top level. When you need multiple outputs, use the <code>lib</code> array to configure the format and build mode of each output.</p>
<p>Shared settings such as <code>syntax</code> and <code>plugins</code> can be placed at the top level. Each <code>lib</code> entry only needs to specify the settings that differ and can override top-level settings as needed, reducing duplication.</p>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__title">rslib.config.ts</div><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts" data-title="rslib.config.ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { defineConfig } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rslib/core&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">export</span><span style="color:var(--shiki-token-keyword)"> default</span><span style="color:var(--shiki-token-function)"> defineConfig</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  lib</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-foreground)"> [</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    {</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      format</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;esm&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    }</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    {</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      format</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;cjs&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      syntax</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;es2020&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    }</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  ]</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-token-comment)">  // Applied to all outputs; can be overridden in individual lib entries</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  syntax</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-string-expression)"> &#x27;es2023&#x27;</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">});</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p>If you need to use Rslib in scripts or other tools, you can create an instance and run a build through the <a href="/api/start/" class="rp-link">JavaScript API</a>. This is useful for tasks such as building multiple packages in a workspace, wrapping internal build commands, or integrating Rslib into a release pipeline. The JavaScript API works in Node.js, Deno, and Bun:</p>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { createRslib } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rslib/core&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">const</span><span style="color:var(--shiki-token-constant)"> rslib</span><span style="color:var(--shiki-token-keyword)"> =</span><span style="color:var(--shiki-token-keyword)"> await</span><span style="color:var(--shiki-token-function)"> createRslib</span><span style="color:var(--shiki-foreground)">();</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">const</span><span style="color:var(--shiki-token-constant)"> result</span><span style="color:var(--shiki-token-keyword)"> =</span><span style="color:var(--shiki-token-keyword)"> await</span><span style="color:var(--shiki-token-constant)"> rslib</span><span style="color:var(--shiki-token-function)">.build</span><span style="color:var(--shiki-foreground)">();</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">await</span><span style="color:var(--shiki-token-constant)"> result</span><span style="color:var(--shiki-token-function)">.close</span><span style="color:var(--shiki-foreground)">();</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<h2 class="rp-toc-include" id="library-development-workflow"><a href="#library-development-workflow" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>An integrated library development workflow</h2>
<p>Rslib works with tools and plugins across the Rstack ecosystem to support functional testing, documentation development, build analysis, and pre-release checks throughout the library development workflow.</p>
<p><strong>Testing</strong></p>
<p>New projects created with <code>create-rslib</code> are preconfigured with Rstest. With <a href="/guide/advanced/rstest#reusing-rslib-configuration" class="rp-link">@rstest/adapter-rslib</a>, Rstest can reuse the relevant Rslib configuration, reducing duplicate configuration while making module resolution and source processing during tests more closely match the actual build.</p>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__title">rstest.config.ts</div><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts" data-title="rstest.config.ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { withRslibConfig } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rstest/adapter-rslib&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { defineConfig } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rstest/core&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">export</span><span style="color:var(--shiki-token-keyword)"> default</span><span style="color:var(--shiki-token-function)"> defineConfig</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  extends</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-function)"> withRslibConfig</span><span style="color:var(--shiki-foreground)">()</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">});</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p><strong>Documentation</strong></p>
<p>Rslib projects can use Rspress to build documentation sites. Component libraries can use <a href="https://rspress.rs/plugin/official-plugins/preview" target="_blank" rel="noopener noreferrer" class="rp-link">@rspress/plugin-preview</a> to write runnable component examples in MDX and <a href="https://rspress.rs/plugin/official-plugins/api-docgen" target="_blank" rel="noopener noreferrer" class="rp-link">@rspress/plugin-api-docgen</a> to generate component API documentation from source code, making it easy to maintain usage guides, component examples, and API references on one site.</p>
<p><strong>Build output checks</strong></p>
<p>Before release, <a href="https://github.com/rstackjs/rsbuild-plugin-publint" target="_blank" rel="noopener noreferrer" class="rp-link">rsbuild-plugin-publint</a> can check for common issues in <code>package.json</code>, package structure, and export configuration, while <a href="https://github.com/rstackjs/rsbuild-plugin-arethetypeswrong" target="_blank" rel="noopener noreferrer" class="rp-link">rsbuild-plugin-arethetypeswrong</a> can check whether declarations work correctly under different module resolution modes. You can choose to enable these checks only in CI:</p>
<div class="rp-codeblock language-ts"><div class="rp-codeblock__title">rslib.config.ts</div><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="ts" data-title="rslib.config.ts"><code><span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { defineConfig } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;@rslib/core&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { pluginAreTheTypesWrong } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;rsbuild-plugin-arethetypeswrong&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">import</span><span style="color:var(--shiki-foreground)"> { pluginPublint } </span><span style="color:var(--shiki-token-keyword)">from</span><span style="color:var(--shiki-token-string-expression)"> &#x27;rsbuild-plugin-publint&#x27;</span><span style="color:var(--shiki-foreground)">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-keyword)">export</span><span style="color:var(--shiki-token-keyword)"> default</span><span style="color:var(--shiki-token-function)"> defineConfig</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  dts</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-constant)"> true</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  plugins</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-foreground)"> [</span></span>
<span class="line"><span style="color:var(--shiki-token-function)">    pluginPublint</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      enable</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-function)"> Boolean</span><span style="color:var(--shiki-foreground)">(</span><span style="color:var(--shiki-token-constant)">process</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">env</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">CI</span><span style="color:var(--shiki-foreground)">)</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    })</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-token-function)">    pluginAreTheTypesWrong</span><span style="color:var(--shiki-foreground)">({</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">      enable</span><span style="color:var(--shiki-token-keyword)">:</span><span style="color:var(--shiki-token-function)"> Boolean</span><span style="color:var(--shiki-foreground)">(</span><span style="color:var(--shiki-token-constant)">process</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">env</span><span style="color:var(--shiki-foreground)">.</span><span style="color:var(--shiki-token-constant)">CI</span><span style="color:var(--shiki-foreground)">)</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">    })</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">  ]</span><span style="color:var(--shiki-token-punctuation)">,</span></span>
<span class="line"><span style="color:var(--shiki-foreground)">});</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p><strong>Build analysis</strong></p>
<p>When you need a deeper analysis of the build process and output, you can use Rsdoctor to inspect build time, dependency relationships, and output size, helping identify problems with build performance, dependency size, and output structure.</p>
<blockquote>
<p>See <a href="/guide/advanced/rstest" class="rp-link">Using Rstest</a>, <a href="/guide/advanced/rspress" class="rp-link">Using Rspress</a>, and <a href="/guide/advanced/rsdoctor" class="rp-link">Using Rsdoctor</a> to learn more.</p>
</blockquote>
<h2 class="rp-toc-include" id="agent-friendly-development"><a href="#agent-friendly-development" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Agent-friendly development experience</h2>
<p>As coding agents become more involved in daily development workflows, providing them with accurate tool knowledge and project context becomes increasingly important.</p>
<p>To this end, Rslib provides Agent Skills:</p>
<ul>
<li><a href="https://github.com/rstackjs/agent-skills#rslib-best-practices" target="_blank" rel="noopener noreferrer" class="rp-link">rslib-best-practices</a>: Provides best practices for configuring and building Rslib projects.</li>
<li><a href="https://github.com/rstackjs/agent-skills#rslib-modern-package" target="_blank" rel="noopener noreferrer" class="rp-link">rslib-modern-package</a>: Provides guidance on designing and publishing modern JavaScript packages.</li>
<li><a href="https://github.com/rstackjs/agent-skills#migrate-to-rslib" target="_blank" rel="noopener noreferrer" class="rp-link">migrate-to-rslib</a>: Helps migrate projects built with tsc or tsup to Rslib.</li>
</ul>
<p>If your coding agent supports Skills, you can install a specific skill in an existing project or install one directly while creating a new project with <code>create-rslib</code>:</p>
<div class="rp-codeblock language-bash"><div class="rp-codeblock__content"><div class="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"><pre class="shiki css-variables" style="background-color:var(--shiki-background);color:var(--shiki-foreground)" tabindex="0" data-lang="bash"><code><span class="line"><span style="color:var(--shiki-token-comment)"># Install in an existing project</span></span>
<span class="line"><span style="color:var(--shiki-token-function)">npx</span><span style="color:var(--shiki-token-string)"> skills</span><span style="color:var(--shiki-token-string)"> add</span><span style="color:var(--shiki-token-string)"> rstackjs/agent-skills</span><span style="color:var(--shiki-token-string)"> --skill</span><span style="color:var(--shiki-token-string)"> rslib-best-practices</span></span>
<span class="line"></span>
<span class="line"><span style="color:var(--shiki-token-comment)"># Install while creating a new project</span></span>
<span class="line"><span style="color:var(--shiki-token-function)">npx</span><span style="color:var(--shiki-token-string)"> -y</span><span style="color:var(--shiki-token-string)"> create-rslib@latest</span><span style="color:var(--shiki-token-string)"> my-project</span><span style="color:var(--shiki-token-string)"> -t</span><span style="color:var(--shiki-token-string)"> react</span><span style="color:var(--shiki-token-string)"> --skill</span><span style="color:var(--shiki-token-string)"> rslib-best-practices</span></span></code></pre></div><div class="rp-code-button-group"><button class="rp-code-button-group__button rp-code-wrap-button" title="Toggle code wrap" aria-label="Toggle code wrap"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrapped"><path fill="currentColor" d="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-button-group__icon--wrap"><path fill="currentColor" d="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z"></path></svg></button><button class="rp-code-button-group__button rp-code-copy-button" title="Copy code"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"><path fill="currentColor" d="M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"></path><path fill="currentColor" d="M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" class="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"><path fill="currentColor" d="m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"></path></svg></button></div></div></div>
<p>In addition to Agent Skills, Rslib provides <a href="https://rslib.rs/llms.txt" target="_blank" rel="noopener noreferrer" class="rp-link">llms.txt</a> for looking up relevant documentation on demand and <a href="https://rslib.rs/llms-full.txt" target="_blank" rel="noopener noreferrer" class="rp-link">llms-full.txt</a> for accessing the complete documentation context. Each documentation page is also available in Markdown, making it easy to provide specific content to an agent.</p>
<p>New projects created with <code>create-rslib</code> also include an <code>AGENTS.md</code> file that lists common commands and relevant documentation links. Developers can extend it with details about the project structure, development workflow, and engineering conventions so agents understand both general Rslib practices and the current project context.</p>
<blockquote>
<p>See <a href="/guide/start/ai" class="rp-link">AI</a> to learn more.</p>
</blockquote>
<h2 class="rp-toc-include" id="using-rslib-v1"><a href="#using-rslib-v1" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Get started with Rslib 1.0</h2>
<ul>
<li>If you have not used Rslib before, try it with the <a href="https://stackblitz.com/~/github.com/rstackjs/rslib-stackblitz-example" target="_blank" rel="noopener noreferrer" class="rp-link">StackBlitz example</a>, or follow the <a href="/guide/start/quick-start" class="rp-link">Quick start</a> to create a new Rslib project.</li>
<li>If you are using Rslib 0.x, note that version 1.0 includes some breaking changes. See <a href="/guide/upgrade/v0-to-v1" class="rp-link">Upgrading from 0.x to v1</a> for migration instructions.</li>
<li>If you plan to migrate from tools such as tsc or tsup to Rslib, see <a href="/guide/start/quick-start#migrate-from-existing-projects" class="rp-link">Migrate from existing projects</a>.</li>
</ul>
<h2 class="rp-toc-include" id="whats-next"><a href="#whats-next" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>What&#x27;s next</h2>
<p>Rslib 1.0 is a stable starting point, not the finish line. Next, we will continue investing in two areas:</p>
<ol>
<li><strong>Continue improving build and output capabilities</strong>, including optimizing ESM and CJS output, exploring more comprehensive Node.js bundling capabilities and more flexible ways to preserve module structures, and continuing to improve the efficiency and experience of declaration generation and bundling.</li>
<li><strong>Improve the library development workflow</strong> by strengthening the integration of Rslib with testing, documentation, quality checks, and release processes, reducing duplicate configuration and maintenance across different stages.</li>
</ol>
<h2 class="rp-toc-include" id="acknowledgments"><a href="#acknowledgments" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Acknowledgments</h2>
<p>Parts of Rslib&#x27;s implementation and API design are derived from or inspired by excellent open source projects—including <a href="https://github.com/evanw/esbuild" target="_blank" rel="noopener noreferrer" class="rp-link">esbuild</a>, <a href="https://github.com/webpack/mini-css-extract-plugin" target="_blank" rel="noopener noreferrer" class="rp-link">mini-css-extract-plugin</a>, <a href="https://github.com/rolldown/tsdown" target="_blank" rel="noopener noreferrer" class="rp-link">tsdown</a>, <a href="https://github.com/egoist/tsup" target="_blank" rel="noopener noreferrer" class="rp-link">tsup</a>, and <a href="https://github.com/webpack/webpack" target="_blank" rel="noopener noreferrer" class="rp-link">webpack</a>—and we thank these projects and their contributors for the experience, ideas, and implementations they have shared.</p>
<p>Rslib&#x27;s growth also depends on every contribution from the community, and we thank everyone who has contributed code or documentation, opened issues, joined discussions, or shared feedback—as well as everyone who uses Rslib.</p>
<p>If you encounter any problems or have suggestions while using Rslib, please reach out through <a href="https://github.com/web-infra-dev/rslib/issues" target="_blank" rel="noopener noreferrer" class="rp-link">GitHub Issues</a>, <a href="https://github.com/web-infra-dev/rslib/discussions" target="_blank" rel="noopener noreferrer" class="rp-link">GitHub Discussions</a>, or our community channels.</p><!--/$-->]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rslib: Build library with Rspack]]></title>
            <link>https://rslib.rs/blog/introducing-rslib</link>
            <guid isPermaLink="false">/blog/introducing-rslib</guid>
            <pubDate>Wed, 14 May 2025 10:00:00 GMT</pubDate>
            <description><![CDATA[Rslib is officially released, helping developers create JavaScript libraries and UI component libraries in a simple and intuitive way.]]></description>
            <content:encoded><![CDATA[<!--$--><h1 class="rp-toc-include" id="rslib-build-library-with-rspack"><a href="#rslib-build-library-with-rspack" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Rslib: Build library with Rspack<!-- --> </h1>
<p><em>May 14, 2025</em></p>
<div class="group-n_jNI7 root-YZxMH8"><div class="root-Sr_5x3 groupItem-m5U5nn"><img src="https://github.com/fi3ework.png" alt="fi3ework" class="avatar-XCZJhu" loading="lazy" decoding="async"/><div class="content-BhgM4E"><div class="nameRow-U9Q3S8"><div class="name-k91bx6">fi3ework</div><div class="links-jK83Yg"><a href="https://github.com/fi3ework" target="_blank" rel="noopener noreferrer" class="link-yDHY4Y" aria-label="fi3ework&#x27;s GitHub"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg></a></div></div><div class="title-MMKZdf">@fi3ework</div></div></div><div class="root-Sr_5x3 groupItem-m5U5nn"><img src="https://github.com/Timeless0911.png" alt="Chenwei Dai" class="avatar-XCZJhu" loading="lazy" decoding="async"/><div class="content-BhgM4E"><div class="nameRow-U9Q3S8"><div class="name-k91bx6">Chenwei Dai</div><div class="links-jK83Yg"><a href="https://github.com/Timeless0911" target="_blank" rel="noopener noreferrer" class="link-yDHY4Y" aria-label="Chenwei Dai&#x27;s GitHub"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg></a></div></div><div class="title-MMKZdf">@Timeless0911</div></div></div></div>
<p><img src="https://assets.rspack.rs/rslib/rslib-banner.png" alt="banner"/></p>
<p>We are excited to introduce Rslib — <strong>a library development tool based on Rspack</strong>. Developed by ByteDance Web Infra Team, Rslib helps developers create JavaScript libraries and UI component libraries in a simple and intuitive way while enjoying the ultimate development experience brought by <a href="https://rspack.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rspack</a> and <a href="https://rsbuild.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rsbuild</a>.</p>
<blockquote>
<p>Repo：<a href="https://github.com/web-infra-dev/rslib" target="_blank" rel="noopener noreferrer" class="rp-link">https://github.com/web-infra-dev/rslib</a></p>
</blockquote>
<h2 class="rp-toc-include" id="why-rslib"><a href="#why-rslib" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Why Rslib</h2>
<p>In the past, webpack was mainly used for bundling web applications. When developing JavaScript libraries, developers typically introduced excellent bundlers like esbuild or Rollup, which could output high-quality ESM and CJS output to better meet JavaScript library bundling needs.</p>
<p>Within ByteDance, our development teams have created over 10,000 JavaScript libraries. During this process, we observed that the coexistence of multiple bundlers has led to ecosystem fragmentation. Additionally, in more complex library development scenarios, there are still many needs that haven&#x27;t been well addressed, such as:</p>
<ul>
<li><strong>Configuration Fragmentation</strong>: Library build configurations differ significantly from application development, requiring developers to learn different configuration rules and methods.</li>
<li><strong>Limited Ecosystem Reuse</strong>: Desire to reuse webpack plugins or loaders accumulated in the ecosystem.</li>
<li><strong>Insufficient Extensibility</strong>: Need for rich build lifecycle hooks to meet custom build requirements.</li>
<li><strong>High Cost of Multi-format Output</strong>: Libraries need to be bundled into multiple formats like ESM, CJS, UMD, and Module Federation, requiring repeated configuration with different tools.</li>
<li><strong>Weak Non-JS Resource Handling</strong>: Lack of standardized processing solutions for style schemes and static assets.</li>
<li><strong>Missing Declaration File Support</strong>: Need to bundle d.ts files of dependencies during build.</li>
</ul>
<p>Facing these pain points, we hope the ideal library development tool would:</p>
<ul>
<li><strong>Easy to Configure:</strong> Provide out-of-the-box configurations covering most scenarios, with plugin mechanisms for advanced feature extensions that work right after installation.</li>
<li><strong>Comprehensive Features:</strong> Support not only JavaScript / TypeScript transformation and multi-format output but also provide comprehensive style and resource processing solutions like web application building.</li>
<li><strong>Shared Ecosystem:</strong> Unify library building with application building configurations, reuse Rspack&#x27;s prosperous community, and promote unified toolchain ecosystem development.</li>
<li><strong>Performance First:</strong> The underlying bundler is implemented in Rust, offering excellent build performance and improving developer experience.</li>
</ul>
<p>Therefore, we created Rslib. <strong>Based on the well-designed configurations and plugins of <a href="https://rsbuild.rs" target="_blank" rel="noopener noreferrer" class="rp-link">Rsbuild</a>&#x27;s, it empowers library developers to take advantage of the extensive knowledge and ecosystem of webpack and Rspack, providing comprehensive library development features.</strong></p>
<p>We hope Rslib can provide more powerful features for library developers and become an important part of the Rspack ecosystem, continuously promoting the development of unified toolchains based on Rspack.</p>
<img src="https://assets.rspack.rs/others/assets/rslib/rslib-in-rstack.png" alt="Rslib in Rstack ecosystem" width="760" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">The location of Rslib in the Rstack ecosystem</p>
<h2 class="rp-toc-include" id="comprehensive-library-development-features"><a href="#comprehensive-library-development-features" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Comprehensive library development features</h2>
<p>Rslib provides a comprehensive library building solution that covers most current library building scenario needs:</p>
<ul>
<li>
<p><strong>Out-of-the-Box Configuration</strong></p>
<p>Rslib provides out-of-the-box library building configurations. With minimal adjustments, it can meet most library building requirements. Moreover, for more advanced integration needs, in most cases, you only need to install the corresponding Rsbuild plugin to complete the setup, avoiding complicated configuration processes.</p>
<p>Rslib&#x27;s configuration extends from Rsbuild, allowing developers to continue using Rsbuild&#x27;s configuration and ecosystem, maintaining consistent mental models between application and library development, and reusing build configuration-related code. This is particularly important in large monorepo projects that need to maintain multiple build configurations.</p>
</li>
<li>
<p><strong>Multi-Format Output Support</strong></p>
<p>Rslib supports bundling libraries into various module system formats, including ESM (ES modules), CJS (CommonJS), UMD (Universal Module Definition), and Module Federation. With just one build tool and one configuration file, it can handle all building scenarios, particularly suitable for library development scenarios requiring cross-project and cross-framework reuse. Additionally, through optimizing Rspack&#x27;s ESM format build output, Rslib can now produce clean, standard ESM output.</p>
<p>For TypeScript declaration files (d.ts), besides supporting d.ts file generation and related post-processing based on TypeScript Compiler API, it also supports bundling d.ts files using <a href="https://www.npmjs.com/package/@microsoft/api-extractor" target="_blank" rel="noopener noreferrer" class="rp-link">@microsoft/api-extractor</a>, suitable for handling complex dependency scenarios.</p>
<img src="https://assets.rspack.rs/others/assets/rslib/multiple-formats-config.png" alt="Multiple formats in one configuration file" width="400" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">Multiple formats in one configuration file</p>
<img src="https://assets.rspack.rs/others/assets/rslib/simple-esm-output.png" alt="Clean ESM output" width="400" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">Clean ESM output</p>
</li>
<li>
<p><strong>Bundle &amp; Bundleless</strong></p>
<p>Rslib supports both bundle and bundleless build modes during build process. For bundleless scenarios, it also supports <a href="/config/lib/redirect" class="rp-link">output path redirection</a> feature, solving common issues with alias replacement in JavaScript and d.ts output paths, as well as strict path reference requirements in ESM.</p>
<img src="https://assets.rspack.rs/rslib/rslib-bundleless-mode.png" alt="bundleless output structure" width="760" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">bundleless output structure</p>
</li>
<li>
<p><strong>Style Solutions</strong></p>
<p>Style building has always been a challenge in UI component library development. Compared to using Less loader, Sass loader, and PostCSS loader in application building, users often need to manually use the native tools of corresponding style solutions when building library output.</p>
<p>Leveraging Rsbuild&#x27;s plugin system and ecosystem, Rslib can directly reuse solutions for Sass, Less, Stylus, CSS Modules, and Tailwind CSS. Whether in bundle or bundleless scenarios, users can process styles just like building web application, directly through configuration or installing corresponding plugins.</p>
<img src="https://assets.rspack.rs/others/assets/rslib/multiple-styles-config.png" alt="Support multiple style solutions" width="760" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">Support multiple style solutions</p>
</li>
<li>
<p><strong>Web Resource Handling</strong></p>
<p>Rslib supports referencing static and inline assets like images, fonts, audio, and video in code, as well as static assets in CSS. After installing the appropriate plugins, users can also process SVG files through SVGR, while supporting JSON, TOML, and YAML formats. This feature provides great convenience when building UI component libraries containing resources.</p>
</li>
<li>
<p><strong>Framework Agnostic</strong></p>
<p>Rslib is a framework-agnostic library building solution, supporting Node.js and various UI component library builds. Different DSL UI frameworks only need to integrate corresponding plugins (including React, Preact, Vue, Solid, etc.) to complete underlying build configuration for development.</p>
</li>
</ul>
<h2 class="rp-toc-include" id="unlocking-rspack-ecosystem-possibilities"><a href="#unlocking-rspack-ecosystem-possibilities" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Unlocking Rspack ecosystem possibilities</h2>
<p>Beyond common JavaScript library development solutions, based on Rspack and the Rsbuild ecosystem, Rslib provides developers with more advanced features:</p>
<ul>
<li>
<p><strong>Module Federation</strong></p>
<p>Rslib provides first-class support for <a href="/guide/advanced/module-federation" class="rp-link">Module Federation</a>. Users only need to install the corresponding Rsbuild plugin to start debugging Module Federation and build MF format output. Users can publish libraries as remote modules to remote servers while building, or directly use remote modules.</p>
</li>
<li>
<p><strong>Leverage Rsbuild Features</strong></p>
<p>Rslib can reuse most of Rsbuild&#x27;s configurations, supporting advanced features including but not limited to: <a href="https://rsbuild.rs/config/source/transform-import" target="_blank" rel="noopener noreferrer" class="rp-link">import path transformation</a>, <a href="https://rsbuild.rs/config/output/inline-styles" target="_blank" rel="noopener noreferrer" class="rp-link">inline styles</a>, <a href="https://rsbuild.rs/config/output/polyfill" target="_blank" rel="noopener noreferrer" class="rp-link">polyfill</a>, and will continue to benefit from more features provided by Rsbuild&#x27;s iterations in the future.</p>
</li>
<li>
<p><strong>Share Rspack and Rsbuild Ecosystem</strong></p>
<p>Based on the Rspack and Rsbuild ecosystem, Rslib can reuse a series of ecosystem features, including but not limited to:</p>
<ul>
<li>Use <a href="https://storybook.rsbuild.rs/guide/integrations/rslib.html" target="_blank" rel="noopener noreferrer" class="rp-link">Storybook</a> to directly read Rslib&#x27;s configuration files for UI component library development debugging.</li>
<li>Use <a href="https://rsdoctor.rs/" target="_blank" rel="noopener noreferrer" class="rp-link">Rsdoctor</a> for build performance and output analysis.</li>
<li>Use <a href="https://github.com/rstackjs/rsbuild-plugin-node-polyfill" target="_blank" rel="noopener noreferrer" class="rp-link">Node.js polyfill</a> plugin to develop cross-runtime libraries.</li>
<li>Use <a href="https://github.com/rstackjs/rsbuild-plugin-eslint" target="_blank" rel="noopener noreferrer" class="rp-link">ESLint plugin</a> for ESLint validation during development.</li>
<li>Use <a href="https://github.com/rstackjs/rsbuild-plugin-publint" target="_blank" rel="noopener noreferrer" class="rp-link">publint plugin</a> to check if the library&#x27;s package.json is configured correctly.</li>
</ul>
<img src="https://assets.rspack.rs/others/assets/rslib/publint-screenshot.png" alt="Use publint to check package.json" width="760" style="display:block;margin:0 auto"/>
<p style="text-align:center;font-size:0.8rem;margin:0.5rem 0;color:#999">Use publint to check package.json</p>
<blockquote>
<p>For more plugin information, please refer to <a href="https://rsbuild.rs/plugins/list/" target="_blank" rel="noopener noreferrer" class="rp-link">Rsbuild Plugin Overview</a>.</p>
</blockquote>
</li>
</ul>
<h2 class="rp-toc-include" id="current-status-and-version-evolution"><a href="#current-status-and-version-evolution" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Current status and version evolution</h2>
<p>Currently, Rspack / Rsbuild / Rspress and other projects in the Rstack toolchain are using Rslib for building, with tens of thousands of weekly downloads, serving multiple businesses within ByteDance, and is also the <a href="https://module-federation.io/integrations/build-tool/rslib" target="_blank" rel="noopener noreferrer" class="rp-link">recommended solution</a> for Module Federation modules.</p>
<p>Rslib is currently in the 0.x stage and we plan to release v1.0 after achieving the following key goals:</p>
<ul>
<li>Stabilize the final configuration and API design</li>
<li>Optimize the quality of the build output</li>
<li>Support bundleless mode for Vue, Solid and more frameworks</li>
</ul>
<p>You can track the progress by checking v1.0 <a href="https://github.com/web-infra-dev/rslib/milestone/1" target="_blank" rel="noopener noreferrer" class="rp-link">Milestone</a> on GitHub.</p>
<h2 class="rp-toc-include" id="start-using-rslib"><a href="#start-using-rslib" class="rp-header-anchor rp-link" aria-hidden="true" tabindex="-1">#</a>Start using Rslib</h2>
<p>We provide the scaffold tool <a href="/guide/start/quick-start" class="rp-link">create-rslib</a> for quickly creating Rslib projects. This scaffold supports creating Node.js / React library projects and supporting development tools. Additionally, we provide <a href="/guide/migration/tsup" class="rp-link">migration documentation</a> to help users migrate from other build tools to Rslib. Read <a href="/guide/start/quick-start" class="rp-link">Quick start</a> to learn how to get started with Rslib.</p>
<p>We believe that a unified toolchain based on Rspack will provide developers with more possibilities. Looking forward to your feedback and contributions to help us build a more complete frontend toolchain ecosystem together.</p><!--/$-->]]></content:encoded>
        </item>
    </channel>
</rss>