Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js: Use Moment.js as a module.

Anders Kaseorga43307bc4e21
diff --git a/.eslintrc.json b/.eslintrc.json
index 912bb7114f1..ef9c8a183f1 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -177,7 +177,6 @@
"message_store": false,
"message_util": false,
"message_viewport": false,
- "moment": false,
"muting": false,
"muting_ui": false,
"narrow": false,
diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js
index 22bcb313d71..333b72ee97f 100644
--- a/frontend_tests/node_tests/markdown.js
+++ b/frontend_tests/node_tests/markdown.js
@@ -16,8 +16,6 @@ set_global("location", {
origin: "http://zulip.zulipdev.com",
});
-set_global("moment", require("moment-timezone"));
-
const emoji_params = {
realm_emoji: {
1: {
diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js
index 1f6e1aa8ee7..eac1fe00878 100644
--- a/frontend_tests/node_tests/people.js
+++ b/frontend_tests/node_tests/people.js
@@ -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");
diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js
index 0bfba9ab642..db62c1cd0f6 100644
--- a/frontend_tests/node_tests/rendered_markdown.js
+++ b/frontend_tests/node_tests/rendered_markdown.js
@@ -1,5 +1,4 @@
const rm = zrequire("rendered_markdown");
-set_global("moment", zrequire("moment", "moment-timezone"));
zrequire("people");
zrequire("user_groups");
zrequire("stream_data");
diff --git a/frontend_tests/node_tests/timerender.js b/frontend_tests/node_tests/timerender.js
index cb615eeb666..99933f53a96 100644
--- a/frontend_tests/node_tests/timerender.js
+++ b/frontend_tests/node_tests/timerender.js
@@ -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");
diff --git a/static/js/bundles/common.js b/static/js/bundles/common.js
index 85882eee348..19a312cc598 100644
--- a/static/js/bundles/common.js
+++ b/static/js/bundles/common.js
@@ -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";
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js
index 3527bba2bb1..df3d197a42d 100644
--- a/static/js/composebox_typeahead.js
+++ b/static/js/composebox_typeahead.js
@@ -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");
diff --git a/static/js/markdown.js b/static/js/markdown.js
index ddba285d027..9d974b6b68e 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -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");
diff --git a/static/js/people.js b/static/js/people.js
index 02b83795aa8..1ee53834ef7 100644
--- a/static/js/people.js
+++ b/static/js/people.js
@@ -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");
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 6dd78e70b1b..a8c994e115c 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -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");
diff --git a/static/js/portico/signup.js b/static/js/portico/signup.js
index 6abfa22cc4d..11328da9948 100644
--- a/static/js/portico/signup.js
+++ b/static/js/portico/signup.js
@@ -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.
diff --git a/static/js/reminder.js b/static/js/reminder.js
index 98f47b637d3..bf336e7461f 100644
--- a/static/js/reminder.js
+++ b/static/js/reminder.js
@@ -1,3 +1,5 @@
+const moment = require("moment-timezone");
+
const util = require("./util");
const deferred_message_types = {
diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js
index 6d28727aae4..b15c7b0f1d6 100644
--- a/static/js/rendered_markdown.js
+++ b/static/js/rendered_markdown.js
@@ -1,3 +1,5 @@
+const moment = require("moment");
+
/*
rendered_markdown
diff --git a/static/js/settings.js b/static/js/settings.js
index 78e5ba0b52a..2e602c97705 100644
--- a/static/js/settings.js
+++ b/static/js/settings.js
@@ -1,3 +1,5 @@
+const moment = require("moment-timezone");
+
const render_settings_tab = require("../templates/settings_tab.hbs");
const settings_config = require("./settings_config");
diff --git a/static/js/timerender.js b/static/js/timerender.js
index f1135e446c8..fbefc1668b9 100644
--- a/static/js/timerender.js
+++ b/static/js/timerender.js
@@ -1,3 +1,4 @@
+const moment = require("moment");
const XDate = require("xdate");
let next_timerender_id = 0;