mathiasbynens / emoji-regex

A regular expression to match all Emoji-only symbols as per the Unicode Standard.
https://mths.be/emoji-regex
MIT License
1.73k stars 174 forks source link

Additionally, export ES2015-style Unicode regexes #22

Closed ticky closed 7 years ago

ticky commented 7 years ago

This is a PR to include the updated behaviour I put together in devongovett/regexgen#17 in emoji-regex.

In addition to the existing exports, which are always compiled down to UCS-2 codepoints, this allows instead importing emoji-regex/unicode or emoji-regex/unicode/text, which retrieve UTF-8 versions of the same regexes, compatible with modern Node versions, as well as some current browsers.

In order to achieve this, it updates the inject-sequences command to convert the sequences to UCS-2 as well as UTF-8, and adds additional files in which to use the UTF-8 version. Likewise, it updates the Babel configuration for these files to toggle the useUnicodeFlag option of transform-unicode-property-regex.

It also updates .gitignore to support these new changes, and not attempt to ignore the original source files.

Todo:

ticky commented 7 years ago

Looks like there may yet be some specificity bugs in devongovett/regexgen#17! 😅

mathiasbynens commented 7 years ago

Thanks for your work on this so far! I’m open to this :)

Let’s get the open regexgen issue resolved first.

ticky commented 7 years ago

Thanks for your positivity and feedback, @mathiasbynens! I suspect the upstream change this relies on is very nearly ready, now! :smile:

ticky commented 7 years ago

regexgen got updated, and I’ve bumped the dependency version in this PR to match, and everything still looks solid! 😃

ticky commented 7 years ago

I’ve updated this based on your feedback, @mathiasbynens! It no longer duplicates the source files on-disk, instead tweaking the Babel config so the two versions are built from the single source, and updating the supplementary files to match. 😸

mathiasbynens commented 7 years ago

Thanks for your work on this, @ticky!

ticky commented 7 years ago

No problem – thanks so much for accepting it :smile: