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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hw-weapp-compiler

v1.0.27

Published

基于 webpack5 的小程序构建工具,兼容 Node.js 14~24

Readme

weapp-compiler

版本改动

  1. OpenSSL 3.0 兼容: Node.js >= 17 时自动注入 --openssl-legacy-provider
  2. wxml-loader 空值守卫: loadModule 失败时不再崩溃

安装

npm i [email protected] -D

使用

# 开发调试
npm run dev        # 测试环境
npm run dev -s     # 预发环境
npm run dev -p     # 生产环境

# 生产发布
npm run build -d   # 测试环境
npm run build -s   # 预发环境
npm run build      # 生产环境

配置

项目根目录下创建 .weapp.js:

const path = require('path');

module.exports = {
  // 路径别名
  alias: {
    '@utils': path.resolve(__dirname, 'src/utils'),
    '@config': path.resolve(__dirname, 'src/config'),
  },
  // 资源公共路径
  publicPath: 'https://cdn.example.com/weapp/',
  // 要同步的目录
  copyFiles: [{
    from: 'images',
    to: 'images',
  }],
  // OBS 或 OSS 配置(二选一)
  obsConfig: {
    access_key_id: 'XXX',
    secret_access_key: 'XXX',
    server: 'XXX',
    bucket: 'XXX',
    dir: 'weapp',
    // 可选:单次 SDK 请求超时、重试次数,以及编译器无进展兜底超时(秒)
    timeout: 15,
    max_retry_count: 1,
    operation_timeout: 35,
  },
  ossConfig: {
    region: '<Your region>',
    accessKeyId: '<Your AccessKeyId>',
    accessKeySecret: '<Your AccessKeySecret>',
    bucket: '<Your Bucket>',
    dir: 'weapp',
  },
};

在 project.config.json 中忽略构建产物:

"packOptions": {
  "ignore": [
    { "type": "folder", "value": "assets" },
    { "type": "regexp", "value": "\\.map$" }
  ]
}

独立分包(受限支持)

在 src/app.json 中配置 independent: true,subpackages 和 subPackages 两种写法均可:

{
  "pages": ["pages/index/index"],
  "subpackages": [{
    "root": "activity",
    "pages": ["pages/index/index"],
    "independent": true
  }]
}

主包和普通分包沿用原有编译流程;每个独立分包单独编译,生成包内的 runtime、公共 JS/WXSS 和资源。 页面及组件入口会自动加载所需的包内公共文件。没有独立分包时仍使用单份 webpack 配置。

  • 独立分包的原生组件、JSON、WXML、WXS、样式和本地资源必须位于自己的 root 内;跨包原生引用会在构建时报错。
  • usingComponents 需显式写在独立包的页面或组件 JSON 中,使用包内相对路径或 /activity/... 路径。不自动搬迁主包组件、npm 原生组件或插件组件。
  • 可以静态引用包外的普通 JS 模块和纯 JS npm 依赖,编译器会将它们编入该独立包。依赖若继续引用包外样式、JSON 等原生文件,也会报错。同一包内共享模块实例,不同包之间不共享模块缓存。
  • 本地资源自动输出到 <root>/assets/,引用使用小程序根路径;配置 CDN publicPath 时沿用 CDN。动态拼接的资源路径不能自动收集,需通过 copyFiles 将包内资源复制到同一包内,例如 { from: 'activity/images', to: 'activity/images' }。
  • 业务代码不能假设主包的 App 已初始化,也不能依赖 app.wxss 的样式。本版不支持独立包内产生异步 chunk 的动态 import() 或分包异步化。
  • 修改已有 JS、模板、样式或资源可以增量构建;修改分包配置、增删页面或组件、改变组件依赖关系后,需要重启 dev。

分包的 root 不能重复或互相嵌套。各包会重复编入自身使用的共享 JS/npm 依赖,因此可能增加总产物体积和编译耗时。 多包构建只在启动时统一清理 dist;-a 分析模式会生成各包的 bundle-report.html 静态报告。