-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Is there a option to build a ES5 React App? #914
Comments
Hi! I'm not sure I fully understand the question. The result code is ES5. When you run If you want to, you can also write the code in ES5 since it's just a subset of ES6. I don't see a good reason for doing it though. I hope this helps! |
perhaps he ment for CRA to work in some "not-so-ES6-compliant" browsers
to work, e.g. IE11. for example IE11 nags about Symbols undefined and
other stuff. perhaps quick workaround is to include es-shim scripts for
those who want this?
|
@themre If create-react-app doesn't work in IE11, I think this is a bug. |
there was some discussion around this topic and I think CRA was meant to provide easy-to-start tool for React. However I think now CRA has become so widespread that a lot of the community expects to work in all major browsers which is not the case. Perhaps there should be some guidance how to step in such cases. |
Can you show some example code where CRA doesn't work in IE11? Are you talking about ES6 features that are not transpiled by babel, but work natively in chrome? If so, that has not so much to do with CRA, but more with not knowing which ES6 features are transpiled and which are only working natively. |
This is done with CRA: apps.sentinel-hub.com/sentinel-playground/. This
is only issue with native support of ES6 features (eg. Symbol).
|
CRA is expected to work in all major browsers including and newer than IE9. If it doesn't, file issues 😉. We can't guess that something is wrong if people just think "oh it's not working" and don't file issues. Please create a specific issue describing the problem you see, affected browsers, and the source code reproducing it. Thanks. |
FWIW I agree there should be a docs section explaining that only syntax is compiled, and if you choose to use Symbols or other runtime ES6 features, it is up to you to polyfill them. Maybe we should include a polyfill.io link to HTML to gently explain this without forcing everyone to use giant polyfills. |
A lot of this is already discussed here: #269 |
I think CRA doesn't force anybody to use Symbols. AFAIK examples in #269 only apply when you spread over something that isn't an array. I agree it's grey territory if you haven't looked at what spread compiles to. Would you like to make a PR adding ES6 polyfills from polyfills.io to HTML file? It seems like this would be the best compromise because people who know which features they're using can just remove it. |
Yeah, it isn't CRAs fault that we all want to use latest JS syntax and stuff. I found that adding this 2 lines into HTML saves all my troubles:
So maybe this is up to each individual if he wants to use this 2 scripts or not, but I don't think they provide too much garbage (correct me if I'm wrong). Writing nicer code is better than keeping your bundle extra small just for handling browsers that will be or they are already out of date. |
As I mentioned above, the syntax should work. If it doesn't, that's a bug. But there are special cases (like iterating over a non-array) that can't possibly work without Symbols. Maybe we should just give up and bundle Symbol polyfill by default. |
For what it's worth, the following has solved my IE11 problems: npm install --save-dev babel-polyfill then require it at the top of import 'babel-polyfill'; |
Please provide an example reproducing the problem. Babel polyfill is huge and I don't recommend using it. Instead I would recommend figuring out which ES6 runtime features you use, and picking polyfills just for them. |
Sorry about that - CRE works just fine in IE11 and most browsers as far as I can tell, but here are features I used that broke it:
Yes, I didn't realize how relatively big it was: 56% increase (from 48kb to 75kb) - thank you Now I want to find a way to generate a compatibility table of features I'm using so I can either remove them or add specific polyfills (as opposed to waiting for error events in my error logger) |
We probably need to explain that somewhere.. Create React App does not polyfill ES6 runtime features. It only gives you the syntax. The idea is that you yourself should decide how much of runtime ES6 features you want to use, and polyfill them yourself. But we don't document that well. As for spread operator, can you provide a specific example when it breaks? As long as it's used on arrays, it should work fine in ES5 environments. |
I'm using const propTypes = {
...formPropTypes,
}; So how can I add support for using spread operator in objects? |
This is not related to this thread. The syntax is supported in Create React App just fine. However it won't work inside a third party package. Third party packages are expected to be written (or compiled down to) ES5. This may change in the future but we won't be processing third party modules with Babel because it is extremely slow and sometimes breaks them. |
no, I agree that we shouldn't include any babel for this kind of things. I think we should close this and update the User Guide how to handle various ES6 syntax (importing polyfill js, various ES6 shims or custom handling - look code below). code for handling symbols:
|
@Gearon, you mentioned above:
What do you recommend for the react-native excosystem, which usually relies on babel for compilation? It's really easy to start a project using Would hate to need to run the |
Sorry, I just don't have a good solution for this. This project will prioritize the needs of web users so you either need to eject or persuade maintainers of those projects to ship ES5. |
Closing in favor of #969: we need to document available polyfills. |
Hello there.
This App is awesome, but I´ve just wondereing if I can build a React App with ES5? If is there a support to it?
Thanks for the enlightening
The text was updated successfully, but these errors were encountered: