needim / wdt-emoji-bundle

Slack like emoji picker with apple/ios, twitter/twemoji, google, emojione, facebook, messenger emoji support
http://ned.im/wdt-emoji-bundle
MIT License
419 stars 87 forks source link

Usage with ES6 style imports #12

Open cyorobert opened 7 years ago

cyorobert commented 7 years ago

Hey, thanks for the hard work - the library is great! When I try to use the library with ES6 imports like below


import wdtEmojiBundle from "wdt-emoji-bundle";

function addEmoji(){
    wdtEmojiBundle.init('.my-selector');
}

I get the error Uncaught ReferenceError: EmojiConvertor is not defined. I'm assuming this is because I haven't imported emoji.min.js, but why wouldn't the bundle import that module itself? Why do we need to create an extra global definition for that object?

In order to use the library I had to do the following:

import EmojiConvertor from "./../../../node_modules/wdt-emoji-bundle/emoji.min";
window.EmojiConvertor = EmojiConvertor;
import wdtEmojiBundle from "wdt-emoji-bundle";

function addEmoji(){
    wdtEmojiBundle.init('.my-selector');
}
needim commented 7 years ago

Hi @cyorobert, I guess I forgot to declare the dependency on wrapper.

I will check, thanks.

cyorobert commented 7 years ago

Excellent @needim thank you!

DaveSanders commented 6 years ago

I'm having a similar, but different problem with ES6. (v0.2.0)

import wdtEmojiBundle from 'wdt-emoji-bundle'

results in:

Error: Can't resolve 'js-emoji'

DaveSanders commented 6 years ago

Disregard - this looks to be an issue with a emoji js required package that is not compatible with webpack 3.

DaveSanders commented 6 years ago

Ok, now looking at it further, if I install wdt-emoji via NPM, my webpack complains:

This dependency was not found:
* js-emoji in ./node_modules/wdt-emoji-bundle/wdt-emoji-bundle.js
To install it, you can run: npm install --save js-emoji

The problem is that js-emoji npm doesn't exist. Maybe they've renamed it, because on their git, they refer to their package as 'emoji-js'. I install that, and then have to change the references in the wdt-emoji js to compensate. Don't know if this is correct, of if I'm stabbing in the dark here.

Pela647 commented 5 years ago

@DaveSanders were you able to solve the above issue, i am having similar problem?