ipfs / ipfs/ipld-explorer-components

feat: dynamically import codecs and hashers and remove from bundle

Open
#452 0 comments 0 reactions 0 assignees View on GitHub
effort/days exp/novice good first issue help wanted kind/architecture kind/enhancement P3 status/ready
Dominant language
TypeScript
Stars
26
Forks
25
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

When bundling this package, we want to make it possible for consumers to customize codecs and hashers. https://github.com/ipfs/ipld-explorer-components/issues/415 made it possible to customize the links; now, we should allow consumers bundling this package to decide whether they want to import all the hashers & codecs or only some.

**Describe the solution you'd like**

- [ ] Everything in https://github.com/ipfs/ipld-explorer-components/blob/5c9718335e81cb3a06f7540a0be5135fe6355ad5/src/lib/codec-importer.ts should be imported dynamically
- [ ] Everything in https://github.com/ipfs/ipld-explorer-components/blob/master/src/lib/hash-importer.ts should be imported dynamically
- [ ] All dynamic imports should be marked as `external` in `vite.config.ts` so they're not included in the bundle
- [ ] All dynamic imports should be marked as `optionalDependencies` but we should have some minimum-required hashers & codecs as `peerDependencies`

**Describe alternatives you've considered**

* Include all imports not-dynamically: this increases bundle size and requires us to come edit this package any time we want to edit the explorer in explore.ipld.io or ipfs-webui

**Additional context**

This package is only included in ipfs-webui and explore.ipld.io, but we may wish to add new hashers, or remove others, and it would be nice if we could do that easily.

**What is enabled by adding this feature**

We will be able to allow further customization without as many edits to this package

This issue isn't tracking the work to customize hashers & codecs, but that should be the next step. Ideally we could pass functions into `HeliaProvider` or `ExploreProvider` to load hashers & codecs.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.