Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile after update #982

Closed
geniuz opened this issue Oct 28, 2019 · 11 comments
Closed

Cannot compile after update #982

geniuz opened this issue Oct 28, 2019 · 11 comments

Comments

@geniuz
Copy link

geniuz commented Oct 28, 2019

Failed to compile.

./node_modules/react-i18next/src/withTranslation.js
SyntaxError: ./node_modules/react-i18next/src/withTranslation.js: Unexpected token (28:39)

26 | I18nextWithTranslation.WrappedComponent = WrappedComponent;
27 |

28 | const forwardRef = (props, ref) => <I18nextWithTranslation {...props} forwardedRef={ref} />;
| ^
29 |
30 | return options.withRef ? React.forwardRef(forwardRef) : I18nextWithTranslation;
31 | };

@jamuhl
Copy link
Member

jamuhl commented Oct 28, 2019

Why and how are you transpiling?

@jamuhl
Copy link
Member

jamuhl commented Oct 28, 2019

Did you clone the repo? npm i? npm run build?

@geniuz
Copy link
Author

geniuz commented Oct 28, 2019

No. I run command npm update.
install latest version of react (16.11.0), i18next, react-i18next (11.0.0) and other pkgs.

@jamuhl
Copy link
Member

jamuhl commented Oct 28, 2019

Failed to compile.

./node_modules/react-i18next/src/withTranslation.js <---- that is the source files

your app should use the compiled files

do you import like: import { withTranslation } from 'react-i18next'

@jamuhl
Copy link
Member

jamuhl commented Oct 28, 2019

https://github.com/i18next/react-i18next/tree/master/example/react is an example...with react (16.11.0), i18next, react-i18next (11.0.0)

@geniuz
Copy link
Author

geniuz commented Oct 28, 2019

Can I use new version, if my project not used babel?

@jamuhl
Copy link
Member

jamuhl commented Oct 28, 2019

I would say yes - when you know what you're doing...there are builds for commonjs, esm, umd in build folder

@koverg70
Copy link
Contributor

koverg70 commented Nov 12, 2019

We have a create-react-app project which uses Typescript, created 10 months ago, and yarn upgraded to the latest nmp packages. (Do not know if Typescript is relevant here.)

The problem is that our app tries to compile withTranslation.js as a Javascript but since the above mentioned commit it contains some JSX language constrcuctions. So our build system (which is create-react-app based, not we configured) can not compile it.

Since this is the only .js file with JSX in our whole node_modules directory (which enumerates more than 50 thousand files) I kindly ask if it is possible to go back to plain Javascript in this only one withTranslation.js file? Only one programmable JSX instantiation is needed here...

Thanks in advance.

@mcmxc
Copy link

mcmxc commented Nov 12, 2019

I've got here because of the same issue, and in my case the problem was in VSCode automatic import. The translation hook was imported by VSC like so:

import { useTranslation } from '~/../node_modules/react-i18next/src/index';

Changing the line above to import { useTranslation } 'react-i18next'; solved this for me, hopefully it will be helpful to someone.

@jamuhl
Copy link
Member

jamuhl commented Nov 13, 2019

@koverg70 PR welcome

koverg70 added a commit to koverg70/react-i18next that referenced this issue Nov 13, 2019
@jamuhl
Copy link
Member

jamuhl commented Nov 20, 2019

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

If you liked my support / work - I would enjoy a coffee sponsored using the “:purple_heart:Sponsor Button”.

There are many ways to help this project 🙏

@jamuhl jamuhl closed this as completed Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants