Skip to content

Commit

Permalink
json-rpc-engine: Wildcard exports -> named exports (#4462)
Browse files Browse the repository at this point in the history
Using wildcard exports makes it difficult to understand what a package
exports and makes it possible for new exports to get added accidentally.

This commit updates the `@metamask/json-rpc-engine` package to use named
exports instead of wildcard exports, and adds a test to verify non-type
exports following other packages.
  • Loading branch information
mcmire authored Jul 3, 2024
1 parent 0d19993 commit 7903e05
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
16 changes: 16 additions & 0 deletions packages/json-rpc-engine/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as allExports from '.';

describe('@metamask/json-rpc-engine', () => {
it('has expected JavaScript exports', () => {
expect(Object.keys(allExports)).toMatchInlineSnapshot(`
Array [
"createAsyncMiddleware",
"createScaffoldMiddleware",
"getUniqueId",
"createIdRemapMiddleware",
"JsonRpcEngine",
"mergeMiddleware",
]
`);
});
});
24 changes: 18 additions & 6 deletions packages/json-rpc-engine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
export * from './createAsyncMiddleware';
export * from './createScaffoldMiddleware';
export * from './getUniqueId';
export * from './idRemapMiddleware';
export * from './JsonRpcEngine';
export * from './mergeMiddleware';
export type {
AsyncJsonRpcEngineNextCallback,
AsyncJsonrpcMiddleware,
} from './createAsyncMiddleware';
export { createAsyncMiddleware } from './createAsyncMiddleware';
export { createScaffoldMiddleware } from './createScaffoldMiddleware';
export { getUniqueId } from './getUniqueId';
export { createIdRemapMiddleware } from './idRemapMiddleware';
export type {
JsonRpcEngineCallbackError,
JsonRpcEngineReturnHandler,
JsonRpcEngineNextCallback,
JsonRpcEngineEndCallback,
JsonRpcMiddleware,
JsonRpcNotificationHandler,
} from './JsonRpcEngine';
export { JsonRpcEngine } from './JsonRpcEngine';
export { mergeMiddleware } from './mergeMiddleware';

0 comments on commit 7903e05

Please sign in to comment.