@ariestools/json-rpc-engine
v9.0.0
Published
Browser-safe @metamask/json-rpc-engine v2 re-export that tree-shakes the legacy events drag-along
Readme
@ariestools/json-rpc-engine
Browser-safe re-export of
@metamask/json-rpc-enginev2 that tree-shakes the legacyeventsdrag-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-engineUsage
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 theeventsdrag 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.
