Replace moment with dayjs

Drop in replacement, but smaller
This commit is contained in:
Pavel Djundik 2019-11-14 17:30:42 +02:00
parent 7584f47c7d
commit 111c3665f9
8 changed files with 20 additions and 18 deletions

View file

@ -7,7 +7,10 @@
</template>
<script>
const moment = require("moment");
import dayjs from "dayjs";
import calendar from "dayjs/plugin/calendar";
dayjs.extend(calendar);
export default {
name: "DateMarker",
@ -16,7 +19,7 @@ export default {
},
computed: {
localeDate() {
return moment(this.message.time).format("D MMMM YYYY");
return dayjs(this.message.time).format("D MMMM YYYY");
},
},
mounted() {
@ -40,7 +43,7 @@ export default {
},
friendlyDate() {
// See http://momentjs.com/docs/#/displaying/calendar-time/
return moment(this.message.time).calendar(null, {
return dayjs(this.message.time).calendar(null, {
sameDay: "[Today]",
lastDay: "[Yesterday]",
lastWeek: "D MMMM YYYY",

View file

@ -68,12 +68,12 @@
</template>
<script>
import dayjs from "dayjs";
import Username from "./Username.vue";
import LinkPreview from "./LinkPreview.vue";
import ParsedMessage from "./ParsedMessage.vue";
import MessageTypes from "./MessageTypes";
const moment = require("moment");
const constants = require("../js/constants");
MessageTypes.ParsedMessage = ParsedMessage;
@ -94,7 +94,7 @@ export default {
? constants.timeFormats.msgWithSeconds
: constants.timeFormats.msgDefault;
return moment(this.message.time).format(format);
return dayjs(this.message.time).format(format);
},
messageComponent() {
return "message-" + this.message.type;

View file

@ -1,7 +1,7 @@
"use strict";
const moment = require("moment");
import dayjs from "dayjs";
module.exports = function(time) {
return moment(time).format("D MMMM YYYY, HH:mm:ss");
export const localetime = function(time) {
return dayjs(time).format("D MMMM YYYY, HH:mm:ss");
};

View file

@ -4,7 +4,7 @@ const Vue = require("vue").default;
const store = require("./store").default;
const App = require("../components/App.vue").default;
const localetime = require("./helpers/localetime");
const {localetime} = require("./helpers/localetime");
const storage = require("./localStorage");
const {router, navigate} = require("./router");
const constants = require("./constants");

View file

@ -84,6 +84,7 @@
"css-loader": "3.2.0",
"css.escape": "1.5.1",
"cssnano": "4.1.10",
"dayjs": "1.8.17",
"emoji-regex": "8.0.0",
"eslint": "6.7.0",
"eslint-config-prettier": "6.7.0",
@ -96,7 +97,6 @@
"mini-css-extract-plugin": "0.8.0",
"mocha": "6.2.2",
"mochapack": "1.1.11",
"moment": "2.24.0",
"mousetrap": "1.6.3",
"npm-run-all": "4.1.5",
"nyc": "14.1.1",

View file

@ -50,7 +50,7 @@ const colors = require("chalk");
const fs = require("fs");
const path = require("path");
const GraphQLClient = require("graphql-request").GraphQLClient;
const moment = require("moment");
const dayjs = require("dayjs");
const semver = require("semver");
const util = require("util");
const log = require("../src/log");
@ -836,7 +836,7 @@ async function generateChangelogEntry(changelog, targetVersion) {
}
items.version = targetVersion;
items.date = moment().format("YYYY-MM-DD");
items.date = dayjs().format("YYYY-MM-DD");
items.fullChangelogUrl = fullChangelogUrl(previousVersion, targetVersion);
return {

View file

@ -116,7 +116,6 @@ const config = {
to: "themes/[name].[ext]",
},
]),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// socket.io uses debug, we don't need it
new webpack.NormalModuleReplacementPlugin(
/debug/,

View file

@ -2515,6 +2515,11 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
dayjs@1.8.17:
version "1.8.17"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.17.tgz#53ec413f2a7b02afbea1846d61bb260fa8567cea"
integrity sha512-47VY/htqYqr9GHd7HW/h56PpQzRBSJcxIQFwqL3P20bMF/3az5c3PWdVY3LmPXFl6cQCYHL7c79b9ov+2bOBbw==
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
@ -5433,11 +5438,6 @@ mochapack@1.1.11:
toposort "^2.0.2"
yargs "14.0.0"
moment@2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
mousetrap@1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.3.tgz#80fee49665fd478bccf072c9d46bdf1bfed3558a"