I have been using some of the third party libraries e.g. pdf.js and html2canvas.js for a customer project. Now when I activate the LockerService, these libraries do not work as expected. Is there any way to validate these third party libraries against Lightning LockerService?
I know there is one utility from Salesforce called Lightning CLI but i guess it supports only lightning component JavaScript code only not the third party libraries.
Best Answer
Unfortunately, there is no silver bullet to know if a library is 100% LockerService compliant or not. The easiest thing to do is to create a small sample app and test the library out yourself. This will at least verify the library loads without error and you can call basic functionality.
Here are some common violations I see libraries making that cause the library not to work with LockerService enabled that you can try to manually check yourself:
window
rather than trying to declare a variable that becomes global. More info.eval
,new Function()
, or<script>
tags.More details about Locker rules here.