rhysd / remark-emoji

Remark markdown transformer to replace :emoji: in text
MIT License
124 stars 18 forks source link

issue with create-react-app #4

Closed elmasse closed 6 years ago

elmasse commented 6 years ago

Hello, first of all, thanks for this remark plugin!

I'm having a weird issue when using this within a create-react-app. And I cannot spot the error so far: Here is the output I got when running npm run build

Failed to minify the code from this file:

        ./node_modules/remark-emoji/index.js:19

Read more here: http://bit.ly/2tRViJ9

Any ideas? I'll give it a try by just copying the file to my src folder for now.

Thanks

elmasse commented 6 years ago

Seems to be related to the arrow function in the visitor.

function transformer(tree) {
        visit(tree, 'text', node => {
            node.value = node.value.replace(RE_EMOJI, getEmoji);
        });
    }

Would you accept a PR to change that into a regular fn so CRA doesn't complain when building a prod version?

wooorm commented 6 years ago

Is the word 'skip' in there somewhere? 🤔 https://github.com/syntax-tree/unist-util-visit/blob/master/index.js#L8

elmasse commented 6 years ago

Hey @wooorm thanks for jumping in. I don't think that's the issue. As I noted in my second comment CRA build complains because of the arrow function on index.js line 19

rhysd commented 6 years ago

Thank you for reporting this issue. I'm not sure because I haven't used create-react-app, but I guess minifier does not support ES6 syntax.

Would you accept a PR to change that into a regular fn so CRA doesn't complain when building a prod version?

It's welcome. Please ensure that this issue is solved when () => {...} is changed to function () {...} before creating a PR.

elmasse commented 6 years ago

Awesome! Thanks.

Let me know when you plan to publish a new version containing this change.

rhysd commented 6 years ago

@elmasse I published 2.0.1 :+1: