8

We are using a lot of ES6 proxy in our lightning application. The API version for all components is set as 39. Everything works fine.

The problem appears when we try to switch API version to 40. Suddenly every time when we construct js proxy ( like new Proxy(...) ) it starts throwing an error:

'Proxy is not a constructor'.

From what I understand setting version as 40.0 enables (basically forces) locker service for components. Does it mean that ES6 proxy is considered to be insecure and is blocked by Locker service? Should we get rid off all the proxies from our code base? Are there any other alternatives or are we doing something wrong?

9

@wesaw Your question touches various subjects, an I will try to answer best:

  1. Lightning components were not designed for ES6, but we don't prevent the use of ES6 features or post ES6 features. As of today, the choice is yours, but some are incompatible with the current structure of Lightning components, or with some browsers in your targeted audience.

  2. The question is more about compatibility. We try to support a wide range of browser engines, and we have a minimal set of polyfills (as of today). Proxy isn't one of them because it's probably impossible to emulate correctly.

  3. Proxy was made available to Lightning in Fall '17.

Outdated:

3. Proxy only became usable last September when Safari on MacOS and iOS were updated. Proxy isn't supported on IE11 and we still have a large customer base relying on compatibility with that browser.

4. For various reasons, Proxy isn't allowed in LockerService at this time although other ES6 and post ES6 features are allowed. We are working hard to improve this situation.

  • Thanks for the explanation. So now we have a dilemma - stick for a while with version 39 waiting for you, guys, to implement proxy support or just switch to some external solution like jQuery proxy right away in order not to have dependency from some future feature. – wesaw Jul 28 '17 at 16:13
  • jQuery's proxy or other solutions would make more sense at this point because they are usually cross-platform compatible, so you maintain support for IE11 which will keep supporting until 2020. You can choose a library that supports the exact features that you are looking for. – JF Paradis Jul 28 '17 at 16:35
  • @JFParadis wait a second. Isn't locker service itself using proxies? Then how are you supporting IE11 in first place? – dzh Aug 2 '17 at 18:39
  • CSP isn't supported on IE11 and reduces the security of LockerService. For that reason, we simply disable it on that platform. – JF Paradis Aug 9 '17 at 20:47

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.