jsr-io / jsr

The open-source package registry for modern JavaScript and TypeScript
https://jsr.io
MIT License
2.52k stars 117 forks source link

If a library has a single export, show that instead of `import * as _library_name from` #800

Open nicolo-ribaudo opened 3 weeks ago

nicolo-ribaudo commented 3 weeks ago

If a library has a simple export, such as https://jsr.io/@nic/local-highlight-registry which only exports LocalHighlightRegistry, it would be much more useful if the sidebar showed

import { LocalHighlightRegistry } from "@nic/local-highlight-registry";

rather than

import * as _nic_local_highlight_registry from "@nic/local-highlight-registry";

By doing so, users can just copy-paste the snipped without having to then modify it, making the "copy" button actually useful :)

This should only be done when there is a single export, since with multiple exports the example would probably become too long and users would likely still have to modify it manually.