ealush / emoji-picker-react

The most popular React Emoji Picker
https://ealush.com/emoji-picker-react/
MIT License
1.06k stars 173 forks source link

EmojiPicker component produces 404's in console from jsdelivr #289

Open firxworx opened 2 years ago

firxworx commented 2 years ago

Sweet little library you added here, its a helpful contribution to the FOSS world!

Issue

EmojiPicker component produces 404's in console from jsdelivr.

Ideally the component shouldn't depend on being able to hit 3rd party URL's for any data, i.e. it should be self contained.

There are countless use-cases for an app UI to render without connectivity and/or because the deploy environment has a strict content security policy or other configuration that will block access to third party URL's.

Replication

See screenshot for example of 404's related to apple icons in the console from jsdelivr.

image

jimaek commented 2 years ago

Indeed it looks like either the library is not generating the correct URLs or some images were not pushed to NPM.

The demo has GET https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/apple/64/2695-fe0f.png 404

And if you check the NPM package that file is not present there, although there are similar looking files. https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/apple/64/

ealush commented 2 years ago

Hey👋

Unfortunately, there's nothing much to do here. The reason the picker uses a CDN is that the images need to come from somewhere. Storing them on the package itself would increase the bundlebsize significantly, and would make it slow as it would not benefit from the speed of a CDN.

Some images do not exist on the CDN, as the emoji standard keeps growing. The picker tries to self correct by removing failed images from render.

I'd love to hear other suggestions on how to treat this.

jimaek commented 2 years ago

Have you tried hosting the images in a separate Github repo? jsDelivr should be able to use any repo of any size when serving individual files, it just wont be able to show a browsing UI. Then the CDN specific JS code hosted on NPM could load the images from the jsDelivr Github endpoint and you wouldn't need to remove any images to keep the size low. Example https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react/scripts/prepare.js