When my sandbox was updated from winter 17 to spring 17 I noticed the format function doesn’t work any more.
Instead of returning a string with the correct format, it returns a string with a function.
I’ve been reading through the releases notes and there is no mention of the eval function not supported anymore, however, it’s not used in that library.
I found a workaround by using the Lightning’s LocalizationService for formatting in conjunction with the rest of the momentjs library now to make it work so I’m not actually looking for a solution to my problem but more of an explanation as to why it doesn’t work any more. What does the momentjs format function do that Lightning doesn’t support any more?
We are already working on this one – its a bit tricky to explain the cause but it has to do with one of the remaining changes required in Lightning to fully support the Content Security Policy requirements from our Security team. There is a use of instanceof (long listed as something that will cause an issue once this last phase of Locker goes live) in momentjs to determine if a value is a function if not momentjs treats it as a string (hence the bizarre display of the source).
If you have a case open on this already you can let support know that the R&D bug for this is W-3575534. Our plan is to get this fixed in Spring’17.