MetaMask / MetaMask/core

[utils] Consider adding exports for individual files

Open
#10,204 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

As time has grown, this package has grown to include a lot of different types of utilities. That's great, but at the same time, the size of this package has grown as well:

- [NPM reports an unpacked size of 487KB](https://www.npmjs.com/package/@metamask/utils/v/8.3.0)
- [`pkg-size` reports a total size (including dependencies) of 4.5MB](https://pkg-size.dev/@metamask%2Futils)

Some projects may only need one or two utilities and may not wish to import this entire package to get them. If we get to a point where both extension and mobile support tree-shaking, then we don't have to worry about unnecessarily bloat, but in the meantime, we might consider creating an export for each file in the `src/` directory (minus `node.ts`, which we've already done).

Before we go down this path, however, we should verify that this indeed would be a viable solution — i.e., that if we create a file-specific export, a project which uses this import would add far less to that project than it would in importing all of `@metamask/utils`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the package exports and the files under src/, noting that node.ts already has a file-specific export. Compare the reported package sizes for importing all of @metamask/utils versus a single utility export. Done means establishing whether per-file exports materially reduce project size and documenting the result and viable export approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.