Skip to content

Commit

Permalink
Simplified ESM import.
Browse files Browse the repository at this point in the history
The issue #303 was opened because twemoji library cannot be
imported through modern browsers as ECMAScript module.

This commit adds the simplest way to make any generic namespace
exported as default (esm.sh) and the raw copy of the minified library
exported as default `twemoji` module.
  • Loading branch information
Andrea Giammarchi committed Jul 17, 2018
1 parent 5ce900d commit 1acf40d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 2/esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions esm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

if [ ! -f "$1" ] || [ "$2" = "" ]; then
echo '
usage example:
./esm.sh ./path/module.js modname
will append:
export default modname;
at the end of:
./path/esm.js
'
else
cp "$1" "$(dirname "$1")/esm.js"
echo "
export default $2;
" >> "$(dirname "$1")/esm.js"
echo "
exported $2 as default
"
fi

0 comments on commit 1acf40d

Please sign in to comment.