@ariestools/json-rpc-engine

中文文档
9.0.3发布于 2026/11/06LGPL-3.0-onlyTypeScriptES Module近 30 天下载 6037

Browser-safe @metamask/json-rpc-engine v2 re-export that tree-shakes the legacy events drag-along

原始使用文档
文档目录6 节
  1. Why this package?
  2. Install
  3. Usage
  4. Not exported
  5. Provenance
  6. License

logo

@ariestools/json-rpc-engine

npm license

Browser-safe re-export of @metamask/json-rpc-engine v2 that tree-shakes the legacy events drag-along

Why this package?

@metamask/json-rpc-engine/v2 re-exports asLegacyMiddleware, which statically imports the legacy v1 engine → @metamask/safe-event-emitter → bare events. Browser consumers then need a bundler alias/polyfill for Node's events module even when they only use the v2 API.

This package re-exports the public v2 API without asLegacyMiddleware, and inlines the engine at compile time so the unused legacy chain is tree-shaken out of the published dist. Node and browser behavior for the v2 surface is unchanged.

Install

pnpm add @ariestools/json-rpc-engine

Usage

Drop-in for @metamask/json-rpc-engine/v2:

import {
  JsonRpcEngineV2,
  JsonRpcServer,
  createScaffoldMiddleware,
} from '@ariestools/json-rpc-engine'

// or, for a 1:1 path migration:
// import { JsonRpcEngineV2 } from '@ariestools/json-rpc-engine/v2'

const engine = JsonRpcEngineV2.create({
  middleware: [
    createScaffoldMiddleware({
      eth_chainId: () => '0x1',
    }),
  ],
})

Not exported

  • asLegacyMiddleware — intentionally omitted (this is the events drag path)
  • The legacy v1 root API (JsonRpcEngine, createAsyncMiddleware, …) — use MetaMask's package directly if you need v1 on Node only

Provenance

Runtime code is derived from @metamask/json-rpc-engine (ISC). Type re-exports still resolve against that package at publish time.

License

See the LICENSE file for license rights and limitations (LGPL-3.0-only). Bundled MetaMask engine code remains under its ISC license.

版本与发布记录

@ariestools/json-rpc-engine 共发布 12 个版本,首次发布于 2026/07/23;过去 12 个月发布了 12 个版本。

版本发布日期距今
9.0.3latest2026/11/062 天前
9.0.22026/10/2711 天前
9.0.12026/09/251 个月前
9.0.02026/09/171 个月前
8.3.02026/09/062 个月前
8.2.02026/08/282 个月前

关于 @ariestools/json-rpc-engine 的常见问题

@ariestools/json-rpc-engine 是什么?

Browser-safe @metamask/json-rpc-engine v2 re-export that tree-shakes the legacy events drag-along

如何安装 @ariestools/json-rpc-engine?

在项目目录运行 npm install @ariestools/json-rpc-engine,或使用 pnpm add / yarn add / bun add。

@ariestools/json-rpc-engine 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ariestools/json-rpc-engine 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ariestools/json-rpc-engine 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=26。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ariestools/json-rpc-engine 可以商用吗?

@ariestools/json-rpc-engine 使用 LGPL-3.0-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@ariestools/json-rpc-engine 的下载量有多少?

根据 npm 官方下载统计,@ariestools/json-rpc-engine 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,037 次,日均约 201 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ariestools/json-rpc-engine 还在维护吗?

最新版本 9.0.3 发布于 2026/11/06(2 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/07/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。