Programmers put decade-old package out to pasture, advise devs to find alternatives
"We recognize that many existing projects may continue to use Moment, but we would like to discourage Moment from being used in new projects going forward," a project status update read this week. "We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done."
That means there will be no new features, API changes, performance improvements, or major changes. There will be security fixes and data updates related to IANA time zone database changes, though the idea is to wean apps from Moment.js if possible.
And a recent Twitter post by Google Chrome engineering manager Addy Osmani may have helped push the Moment maintainers to abandon ship. Three days ago, he announced that Lighthouse, a performance measurement application that's part of Chrome's developer tools, has been updated to spot bloated libraries and suggest lighter-weight alternatives.
Developers discussing the matter on Twitter aren't all enthusiastic about Google shaming underfunded open-source projects for size, performance, or other supposed shortcomings.
"This is going to be an incredibly toxic tool that is weaponized against already overburdened maintainers," wrote Tierney Cyren, senior cloud developer advocate at Microsoft, a sentiment shared by other coders.
At the same time, one of Moment's maintainers, Maggie Johnson-Pint, senior software engineering lead at Microsoft, appears to have taken Google's hectoring in her stride.
In answer to Cyren's tweeted concerns about Lighthouse's unsolicited recommendation, she said, "I've said this a few times, but as the maintainer in question in this case – good, move on to a modern library. Moment was a huge emotional pain for all of its maintainers until we accepted the reality that people could move on, and that actually didn't impact us one bit."
Also, the library makes Moment objects mutable, meaning the use of methods like addition and subtraction change not only the variable receiving the assignment but value in the original object.
var a = moment('2016-01-01'); var b = a.add(1, 'week'); a.format(); "2016-01-08T00:00:00-06:00"
Both the variable
a were changed in the assignment process, which can create problems if not expected or not worked around using the clone method.
Moment's maintainers acknowledge this is a common source of complaints, though they say that making Moment objects immutable would break backwards compatibility.
It's that commitment to legacy stability over modernization that signals Moment cannot last. Changes to browsers, browser engines, or other aspects of web architecture may require adaptations in open source browser-oriented code, work that volunteer projects may not want or be able to undertake.
In response to Osmani's Lighthouse announcement, developer Sunil Pai suggested that Google should do more to fund renovation work on open source projects if it's going to be endorsing particular projects.
Osmani said he agrees.
"Chrome currently has a yearly web performance and frameworks fund for sponsoring work like this," he said. "We’ve been working with OpenCollective to expand on this for 2021 and will have more funding to announce soon."