Open dasilvacontin opened 8 years ago
Hi @dasilvacontin I know, the module is not compatible with Node.js right now. Actually I didn't thought about that use case... If I get your point you would like to use gh-emoji in your Node app in order to return html with the github emojis as img tags?
Just wondering about how helpful might be to support Node, but we can do it for sure!
@zzarcon For now I was just doing a proof of concept for my website redesign in which I fetch all my public repos, and parse the emoji in the repos' description. I was currently logging the result to the terminal. (or trying to)
It can be useful for trying out the library, creating CLI and pre-rendered/static content (in which parsing the emojis in the browser will be unnecessary overhead).
Chiming in to let you know this module cannot be server-rendered. In building an isomorphic react app, I cannot hand off the rendering from the server to the client because window
fails in node. Can you use a conditional to ensure window
exists?
I wanted to take care of implementing this and PR it, but out of the box, tests fail on my system.
Here's my system information and what steps I followed.
npm install
npm test
> gh-emoji@0.2.5 test /private/tmp/gh-emoji
> npm run test:browser
> gh-emoji@0.2.5 test:browser /private/tmp/gh-emoji
> browserify -t babelify ./test | tape-run | tap-spec
SyntaxError: /private/tmp/gh-emoji/src/index.js: Unexpected token, expected ; (19:49)
17 | */
18 |
> 19 | const fetch = window.fetch || (endpoint: string) : Promise <Object> => {
| ^
20 | return new Promise((resolve, reject) => {
21 | const xhr = new XMLHttpRequest();
22 |
at Parser.pp$5.raise (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:4246:13)
at Parser.pp.unexpected (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1627:8)
at Parser.pp.semicolon (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1608:38)
at Parser.pp$1.parseVarStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:2037:8)
at Parser.pp$1.parseStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1729:19)
at Parser.parseStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:5218:22)
at Parser.pp$1.parseBlockBody (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:2133:21)
at Parser.pp$1.parseTopLevel (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1645:8)
at Parser.parse (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1537:17)
at parse$1 (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:6466:37)
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: javascript required
at Stream.<anonymous> (/private/tmp/gh-emoji/node_modules/browser-run/index.js:27:34)
at _end (/private/tmp/gh-emoji/node_modules/through/index.js:65:9)
at Stream.stream.end (/private/tmp/gh-emoji/node_modules/through/index.js:74:5)
at Stream.method [as end] (/private/tmp/gh-emoji/node_modules/duplexer/index.js:47:39)
at Stream.<anonymous> (/private/tmp/gh-emoji/node_modules/throughout/index.js:7:25)
at _end (/private/tmp/gh-emoji/node_modules/through/index.js:65:9)
at Stream.stream.end (/private/tmp/gh-emoji/node_modules/through/index.js:74:5)
at Stream.onend (stream.js:59:10)
at emitNone (events.js:91:20)
at Stream.emit (events.js:185:7)
npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/dawsonbotsford/.nvm/versions/node/v6.2.1/bin/node" "/Users/dawsonbotsford/.nvm/versions/node/v6.2.1/bin/npm" "run" "test:browser"
npm ERR! node v6.2.1
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! gh-emoji@0.2.5 test:browser: `browserify -t babelify ./test | tape-run | tap-spec`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gh-emoji@0.2.5 test:browser script 'browserify -t babelify ./test | tape-run | tap-spec'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gh-emoji package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify -t babelify ./test | tape-run | tap-spec
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs gh-emoji
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls gh-emoji
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /private/tmp/gh-emoji/npm-debug.log
npm ERR! Test failed. See above for more details.
sist output:
Darwin
x64
uname
: Darwin
echo $SHELL
: /bin/zsh
echo $TERM
: xterm-256color
echo $TERM_PROGRAM
: iTerm.app
npm -v
: 3.10.9
node --version
: v6.2.1
Time created: Fri Nov 25 2016 20:27:13 GMT-0800 (PST)