function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinod Merwade27Vinod Merwade27 

Error message thrown when locker service is Activated--- [ReferenceError: define is not defined]

Hi All,

I'm using custom Lookup lightning component which uses RequireJS, this is working smoothly, untill we have Locker Service deactivated. Once the Service is Activated it is throwing an Exception message as "Something has gone wrong. Error in $A.getCallback() [ReferenceError: define is not defined] Failing descriptor: {markup://c:CustomLookupComp}. Please try again.". Whereas define is defined already in teh RequireJS by default.

I have also refered some sites, where they mention to use the commments in the function to let the Aura to identify the variable/element.
http://jshint.com/docs/  
/* globals define */

Still No luck on this.

please let me know if you have any solution or alternative for this ?

Thanks

 
Prachi SPrachi S
Hi Vinod,
Have you tried running CLI on your lightning controllers? If your lightning JS is not CLI complaint then the locker services will prohibit them from running once you enable this critical update. I was able to resolve a similar issue in the past when I ran the CLI and fixed issues that it reported.

For more information on CLI you can visit :
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/cli_usage.htm

Hope it helps!
Vinod Merwade27Vinod Merwade27
Thanks Prachi for the reply.

Yeah, I have tried CLI, only one warning was there I have corrected it, still the issue continues.!!

Do you want me to do CLI check for requireJS too ??

Regards,
Vinod
Prachi SPrachi S
No you are not expected to run CLI on RequireJS if the JS resource you have specified is a third party or external JS library.

But LockerService enforces modern JS standards and new security rules. So depending how the component is built, they will need to be upgraded to meet these standards provided they are served from Static Resources and approved by security. In short you are expected to use the latest version of any such external libraries you might be using.

Also a lot of issues has been reported with using external libraries after locker service has been enabled hence salesforce has extended the Locker service critical update to next release WInter 17 as well till they can come up with tools that validate if the external libraries are complaint with Lightning CLI.

You can see FAQ section in this blog. A number of people have reported similar issues:
https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html