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

@llehtahw/mpsqlite-vite-build

v0.1.2

Published

Vite 插件,用于在 uni-app 项目构建时自动安装 mpsqlite 所需的静态文件。

Downloads

290

Readme

@llehtahw/mpsqlite-vite-build

Vite 插件,用于在 uni-app 项目构建时自动安装 mpsqlite 所需的静态文件。

注意:目前仅支持微信小程序平台。

安装

npm install --save-dev @llehtahw/mpsqlite-vite-build

使用方法

1. 在 vite.config.ts 中配置插件

主包路径

import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { mpsqliteFilesPlugin } from "@llehtahw/mpsqlite-vite-build";

export default defineConfig({
  plugins: [
    mpsqliteFilesPlugin({
      staticDir: "static/",
    }),
    uni(),
  ],
  optimizeDeps: {
    exclude: ["@llehtahw/mpsqlite-vite-build"],
  },
});

分包路径

import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { mpsqliteFilesPlugin } from "@llehtahw/mpsqlite-vite-build";

export default defineConfig({
  plugins: [
    mpsqliteFilesPlugin({
      staticDir: "subpackages/A/static/",
    }),
    uni(),
  ],
  optimizeDeps: {
    exclude: ["@llehtahw/mpsqlite-vite-build"],
  },
});

2. 在代码中配置 mpsqlite

在调用 initSQLite 之前,使用相同的 staticDir 路径配置:

主包路径

import { configureMPSQLite } from "@llehtahw/mpsqlite";

configureMPSQLite({
  staticDir: "static/",
});

分包路径

import { configureMPSQLite } from "@llehtahw/mpsqlite";

configureMPSQLite({
  staticDir: "subpackages/A/static/",
});

配置说明

  • staticDir (必需): 小程序代码包内的静态文件路径
    • 主包示例: 'static/' - 文件放在主包根目录
    • 分包示例: 'subpackages/A/static/' - 文件放在分包 A 目录
    • 重要: vite 插件和 configureMPSQLite 中的路径必须完全一致

功能

构建完成后自动:

  • 压缩并复制 sql-wasm.wasm 为 Brotli 格式
  • 复制 mpsqlite/static 目录下的所有必要文件

依赖

  • @llehtahw/mpsqlite
  • sql.js

故障排除

如果遇到 ESM file cannot be loaded by require 错误:

  1. 确保在 vite.config.ts 中添加了 optimizeDeps.exclude 配置(见上方示例)
  2. 删除 node_modulespackage-lock.json,然后重新运行 npm install
  3. 确保使用 import 而不是 require 导入插件

License

MIT