13

As I understand it, the platform uses closure compiler to transpile code. And closure compiler officially supports ECMAScript 6 since 2015. But lightning-cli is configured to not allow version 6 or higher inside lightning components. Although, it is allowed to use it outside of component.

The question is:

Will we be allowed to use some ES2015 features at some point in the future?

  • 4
    I do know that support for ECMAScript 6 it's in the Lightning Component Team's product plan, but can't say when it will be delivered. Security and Locker Service compliance is their #1 priority. Without a secure Lightning platform, it won't matter to your org what version of ECMAScript you're using when writing your components. – crmprogdev Mar 17 '17 at 15:35
6

It is possible to use some features of ECMAScript 6 in lightning components, here are some of the ones that I am aware of:

Documentation links for the aformentioned ES6 Features (if any):

Ideas for ES6 Features on the success community:

Unfortunately, there doesnt seem to be any official documentation on ES6 Supported features

| improve this answer | |
  • do you have any Salesforce documentation that says what ECMAScript 6 is safe to use in Lightning Components? – Scott Pelak Jul 26 '18 at 14:15
  • Other than testing myself - I know there was a presentation at dreamforce 2 years ago on the subject. I can dig a bit to see if i find any documetnation links, but I have tested the above in my lightning components, and those specific features are supported. I think there is a Developer blog for the ES6 promises – glls Jul 26 '18 at 14:17
  • I found the reference for Using JavaScript Promies in Lightning but haven't found anything describing specific support for ES6. Does lightning shim the ES6 if not supported on a Client? I don't want my Component to break on older browsers – Scott Pelak Jul 26 '18 at 14:40
  • Unfortunately, there doesnt seem to be any official documentation on ES6 Supported features. =( , the above links are the only ones I was able to find. – glls Jul 26 '18 at 14:42
0

Will we be allowed to use some ES2015 features at some point in the future? yes definitely.

At the moment this what the documentation says and there is no explicit error thrown when we use ES6 syntax but it might not work in IE11. If you are building products in AppExchange better to stick to ES5

Supported JavaScript

The Aura Components programming model supports ES5 syntax and ES6 Promises. For the most reliable experience, use ES5 to develop Aura components because the pipeline from authoring to serialization to execution was built for ES5. Promises from ES6 are also available. Using any other syntax or feature is not supported, and does not work in IE11.

This developer guide explains how to develop Aura components and documents the JavaScript usage that's unique to the Aura Components programming model.

If you want to use ES6 or later for development, use the Lightning Web Components programming model, which has been architected for modern JavaScript development.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.