npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

packrs

v1.0.11

Published

rsbuild for react

Readme


✨ 特性

📦 安装

# npm
npm install packrs --save-dev

# yarn
yarn add -D packrs

# pnpm
pnpm add -D packrs

🚀 快速开始

开发模式

const { run } = require('packrs');

run({
  index: './src/index',
  dist: './dist',
});

启动开发服务器,支持热更新和快速刷新。

生产构建

const { build } = require('packrs');

build({
  index: './src/index',
  dist: './dist',
});

构建优化后的生产版本。

🔧 配置示例

完整配置

const { run } = require('packrs');

run({
  // 入口文件
  index: ['eventsource-polyfill', './src/index'],

  // 输出目录
  dist: './dist',

  // 开发服务器端口
  port: 9001,

  // 开发服务器代理
  proxy: [
    {
      context: ['/api'],
      target: 'https://api.example.com',
      changeOrigin: true,
    },
  ],

  // 构建横幅
  banner: 'My App v1.0.0',

  // Rsbuild 配置
  rsConfig: {
    html: {
      template: './index.html',
      favicon: './src/assets/favicon.ico',
    },
    resolve: {
      aliasStrategy: 'prefer-tsconfig',
    },
  },
});

多入口配置

const { build } = require('packrs');

build({
  index: {
    main: './src/index',
    admin: './src/admin',
  },
  dist: './dist',
});

自定义 React 运行时

const { run } = require('packrs');

run({
  index: './src/index',
  // React 16.14.0 之前的版本使用 classic
  reactRuntime: 'classic',
});

📚 API 参考

run(params) / build(params)

参数配置

| 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | index | string \| string[] \| RsbuildEntryDescription | './src/index' | 入口文件路径 | | dist | string | './dist' | 输出目录 | | port | number | 3000 | 开发服务器端口 | | less | boolean | true | 是否启用 Less 支持 | | sass | boolean | true | 是否启用 Sass 支持 | | proxy | ProxyConfig | - | 开发服务器代理配置 | | banner | string | - | 构建横幅文本 | | reactRuntime | 'automatic' \| 'classic' | 'automatic' | JSX 运行时模式 | | rsConfig | RsbuildConfig | - | Rsbuild 完整配置 |

TypeScript 类型定义

type Params = {
  /** 是否使用 Less(默认: true) */
  less?: boolean;

  /** 是否使用 Sass(默认: true) */
  sass?: boolean;

  /** 项目入口文件(默认: './src/index') */
  index?: string | string[] | (RsbuildEntryDescription & { html?: boolean });

  /** 输出目录(默认: './dist') */
  dist?: string;

  /** 开发服务器端口(默认: 3000) */
  port?: number;

  /** 开发服务器代理设置 */
  proxy?: ProxyConfig;

  /** 构建横幅文本 */
  banner?: string;

  /** JSX 运行时模式(默认: 'automatic') */
  reactRuntime?: 'automatic' | 'classic';

  /** Rsbuild 配置 */
  rsConfig?: RsbuildConfig;
};

💡 设计理念

为什么只提供 Node.js API?

packrs 专注于提供灵活且强大的 Node.js API,而不是传统的 CLI 工具。这种设计带来以下优势:

  • 🎯 最大灵活性 - 完全控制构建流程,无需受限于预设配置
  • 🔌 无缝集成 - 轻松集成到现有的构建脚本和工作流
  • 🚀 充分利用 - 发挥 Rsbuild 的全部能力,支持自定义插件和配置
  • 📦 轻量简洁 - 避免 CLI 层的复杂性,保持核心功能简单高效

如果需要 CLI,可以在项目的 package.json 中轻松创建自定义脚本:

{
  "scripts": {
    "dev": "node scripts/dev.js",
    "build": "node scripts/build.js"
  }
}

📖 更多资源

📄 开源协议

MIT © leonwgc