-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
issue using in a create-react-app app #4
Comments
Could you please try this and let me know where it fails? import translate from 'translate/translate.js'; So that the specific bit is clear; there seems to be no async/await in that file nor in the minified version (using normal promises). I suspect it comes from |
That said, writing |
Including |
I agree with the idea that you should not have to decide what browser versions a user of your library wants to support. But looking at the web page referenced in the error message (http://bit.ly/2tRViJ9) it doesn't seem that there are any easy solutions for me. It says the following: Some third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years. To resolve this:
I'm on option 1 now. ;-) |
A little more info ... I now suspect the issue is that the generated file translate.min.js that your library builds uses template literal strings (with the backticks). It seems that create-react-app's It's not clear to me what I can do to cause an I see it is Rollup that creates this file, not Babel. It appears to me that you don't configure Rollup to use Babel for any transpiling which allows the resulting file to use ES6 features. I suspect that is going to limit the number of apps that can use your library. The recommendation from the React team is that libraries should deploy a version of the code that only uses ES5 to make it compatible with more apps. |
I am sorry, but after much thought about this, my previous answer and reading this excellent answer by Sindre Sorhus I have decided not to support ES5. Please feel free to do Sindre's 4th recommendation:
Since rollup results in smaller files and supporting n-2 browsers in time now is arbitrary and meaningless for the future, I'll keep releasing my libraries under modern Javascript. EDIT: I am using |
Also note, options 2 and 3 might be tricky to do by yourself since I'm doing a conditional |
The Sindre Sorhus issue seems to have been about an issue with “require”, not whether he was going to support ES5. Are you expecting Webpack to handle transpiling code under node_modules from ES6+ to ES5 when it bundles apps that use your library? Unless I’m misunderstanding something, if you choose to not release an ES5 version of your library, a large number of web apps will not be able to use it. |
Exactly, Webpack transpiling ES6+ to ES5 (or whatever you specify like
|
I am using your wonderful library in a library I created. See https://github.com/mvolkmann/web-translate. Thank you so much!
When I run
npm run build
in an app created with create-react-app, I get the following error:I believe this happens because there is something missing in your
.babelrc
file.You have this:
The following may fix it because it will produce transpiled code that doesn't use async/await which is needed to run in some browsers.
The text was updated successfully, but these errors were encountered: