js: Use Moment.js as a module.

Note that require("moment") and require("moment-timezone") resolve to
the same thing, but the latter adds timezone support as a side effect.
So I went with the latter in every file where .tz is used.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-27 16:48:47 -07:00 committed by Tim Abbott
parent 584d6bfa41
commit a43307bc4e
15 changed files with 19 additions and 11 deletions

View File

@ -177,7 +177,6 @@
"message_store": false,
"message_util": false,
"message_viewport": false,
"moment": false,
"muting": false,
"muting_ui": false,
"narrow": false,

View File

@ -16,8 +16,6 @@ set_global("location", {
origin: "http://zulip.zulipdev.com",
});
set_global("moment", require("moment-timezone"));
const emoji_params = {
realm_emoji: {
1: {

View File

@ -1,6 +1,10 @@
const _ = require("lodash");
const moment = require("moment-timezone");
const rewiremock = require("rewiremock/node");
zrequire("people");
rewiremock.proxy(() => zrequire("people"), {
"moment-timezone": () => moment("20130208T080910"),
});
set_global("message_store", {});
set_global("page_params", {});
set_global("settings_data", {});
@ -391,9 +395,6 @@ run_test("user_timezone", () => {
global.page_params.twenty_four_hour_time = false;
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
const actual_moment = zrequire("actual_moment", "moment-timezone");
set_global("moment", () => actual_moment("20130208T080910"));
global.page_params.twenty_four_hour_time = true;
assert.equal(people.get_user_time(me.user_id), "0:09");

View File

@ -1,5 +1,4 @@
const rm = zrequire("rendered_markdown");
set_global("moment", zrequire("moment", "moment-timezone"));
zrequire("people");
zrequire("user_groups");
zrequire("stream_data");

View File

@ -1,10 +1,10 @@
const moment = require("moment");
const XDate = require("xdate");
set_global("$", global.make_zjquery());
set_global("page_params", {
twenty_four_hour_time: true,
});
set_global("moment", require("moment-timezone"));
zrequire("timerender");

View File

@ -7,8 +7,6 @@ import "../csrf.js";
import "../blueslip.js";
import "../../third/bootstrap/js/bootstrap.js";
import "../common.js";
import "moment/min/moment.min.js";
import "moment-timezone/builds/moment-timezone-with-data.min.js";
import "../../third/bootstrap/css/bootstrap.css";
import "../../third/bootstrap/css/bootstrap-btn.css";
import "../../third/bootstrap/css/bootstrap-responsive.css";

View File

@ -1,5 +1,6 @@
const autosize = require("autosize");
const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js");
const moment = require("moment");
const pygments_data = require("../generated/pygments_data.json");
const emoji = require("../shared/js/emoji");

View File

@ -1,5 +1,6 @@
const katex = require("katex/dist/katex.min.js");
const _ = require("lodash");
const moment = require("moment");
const emoji = require("../shared/js/emoji");
const fenced_code = require("../shared/js/fenced_code");

View File

@ -1,5 +1,6 @@
const md5 = require("blueimp-md5");
const _ = require("lodash");
const moment = require("moment-timezone");
require("unorm"); // String.prototype.normalize polyfill for IE11
const typeahead = require("../shared/js/typeahead");

View File

@ -1,5 +1,6 @@
const ClipboardJS = require("clipboard");
const confirmDatePlugin = require("flatpickr/dist/plugins/confirmDate/confirmDate.js");
const moment = require("moment");
const render_actions_popover_content = require("../templates/actions_popover_content.hbs");
const render_mobile_message_buttons_popover = require("../templates/mobile_message_buttons_popover.hbs");

View File

@ -1,3 +1,5 @@
const moment = require("moment-timezone");
$(() => {
// NB: this file is included on multiple pages. In each context,
// some of the jQuery selectors below will return empty lists.

View File

@ -1,3 +1,5 @@
const moment = require("moment-timezone");
const util = require("./util");
const deferred_message_types = {

View File

@ -1,3 +1,5 @@
const moment = require("moment");
/*
rendered_markdown

View File

@ -1,3 +1,5 @@
const moment = require("moment-timezone");
const render_settings_tab = require("../templates/settings_tab.hbs");
const settings_config = require("./settings_config");

View File

@ -1,3 +1,4 @@
const moment = require("moment");
const XDate = require("xdate");
let next_timerender_id = 0;