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

@holix/builder

v0.3.0

Published

Builder utilities for the Holix framework

Readme

@holix/builder

Holix 构建工具,基于 Rolldown 提供高性能的构建能力。

功能特性

🎯 多入口分目录输出

自动根据配置将不同的入口文件输出到不同的子目录:

  • 主入口 (app.entry) → dist/main/
  • 预加载脚本 (preload) → dist/preload/

📦 配置示例

// holix.config.ts
import { defineHolixConfig } from '@holix/cli/config'

export default defineHolixConfig({
  app: {
    entry: 'src/main.ts', // 主入口
  },
  preload: {
    bridge: 'src/bridge.ts', // 预加载脚本
    worker: 'src/worker.ts',
  },
  outDir: 'dist',
})

📂 输出结构

构建后会生成以下目录结构:

dist/
├── main/
│   └── main.js          # 主入口输出
├── preload/
│   ├── bridge.js        # 预加载脚本
│   └── worker.js
└── _chunks/
    └── shared-*.js      # 共享代码块

API

createBuildConfig(holixConfig, packageJson)

根据 HolixConfig 创建 Rolldown 构建配置。

参数:

  • holixConfig: HolixConfig - Holix 配置对象
  • packageJson: PackageJson - package.json 内容

返回: BuildOptions - Rolldown 构建配置

resolveEntries(holixConfig)

从 HolixConfig 解析所有入口文件配置。

参数:

  • holixConfig: HolixConfig - Holix 配置对象

返回: EntryOutputConfig[] - 入口文件配置数组

示例:

import { resolveEntries } from '@holix/builder'

const entries = resolveEntries({
  app: { entry: 'src/main.ts' },
  preload: {
    bridge: 'src/bridge.ts',
    worker: 'src/worker.ts',
  },
})

// 返回:
// [
//   { path: '/project/src/main.ts', subDir: 'main', name: 'main' },
//   { path: '/project/src/bridge.ts', subDir: 'preload', name: 'bridge' },
//   { path: '/project/src/worker.ts', subDir: 'preload', name: 'worker' }
// ]

Preload 配置格式

支持三种格式:

1. 字符串 (单个文件)

{
  preload: 'src/preload.ts'
}
// 输出: dist/preload/preload.js

2. 数组 (多个文件)

{
  preload: ['src/preload1.ts', 'src/preload2.ts']
}
// 输出:
// - dist/preload/preload-0.js
// - dist/preload/preload-1.js

3. 对象 (命名文件)

{
  preload: {
    bridge: 'src/bridge.ts',
    worker: 'src/worker.ts'
  }
}
// 输出:
// - dist/preload/bridge.js
// - dist/preload/worker.js

插件

External 插件

自动外部化依赖:

  • externalNode() - 外部化 Node.js 内置模块
  • externalDeps() - 外部化 package.json 中的依赖
  • externalElectron() - 外部化 Electron 模块

使用示例

import { externalDeps, externalNode } from '@holix/builder'

{
  plugins: [
    externalNode(),
    externalDeps({
      strategy: 'production', // 'all' | 'production' | 'none'
      packageJson
    })
  ]
}

工具函数

JSX 配置

import { getJsxConfigFromPackageJson } from '@holix/builder'

const jsxConfig = getJsxConfigFromPackageJson(packageJson)
// 自动从 package.json 推断 React/Vue 配置

模块类型解析

import { resolvePackageModuleType } from '@holix/builder'

const format = resolvePackageModuleType(packageJson)
// 返回: 'esm' | 'cjs'

License

MIT