babel: Enable loose mode.

Due to try-catch deoptimization, Babel strict mode for…of loops run
about 5× slower in Firefox than Babel loose mode for…of, native
for…of, or forEach (which are all about the same speed).  Chrome
doesn’t seem to care.

For some reason we need to explicitly add the core-js Symbol polyfill
near the beginning of the common bundle.  Otherwise it gets loaded at
the wrong time and the Casper tests fail.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-02-04 14:48:49 -08:00 committed by Tim Abbott
parent de3146c137
commit ea9212a92d
3 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,7 @@ module.exports = {
"@babel/preset-env",
{
corejs: 3,
loose: true, // Loose mode for…of loops are 5× faster in Firefox
useBuiltIns: "usage",
},
],

View File

@ -1,4 +1,5 @@
import "core-js/features/promise";
import "core-js/features/symbol";
import "jquery/dist/jquery.js";
import "underscore/underscore.js";
import "../page_params.js";

View File

@ -297,7 +297,7 @@ exports.unread_topic_counter = (function () {
return {
pretty_name: topic_name,
message_id: Math.max(...msgs),
message_id: Math.max(...Array.from(msgs)),
};
});