From d6a3776d37ee4b0664d4d0c5741eb45516e24ce6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 28 Mar 2023 18:24:58 +0200 Subject: [PATCH] perf: remove `dayjs` dependency saves ~16KB bundle size --- package.json | 1 - pnpm-lock.yaml | 7 ------- src/reporters/basic.ts | 6 +----- src/reporters/fancy.ts | 2 +- src/utils/date.ts | 5 ----- 5 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 src/utils/date.ts diff --git a/package.json b/package.json index 52ca782c..6a5e4e46 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "@vitest/coverage-c8": "^0.29.8", "changelogen": "^0.5.2", "colorette": "^2.0.19", - "dayjs": "^1.11.7", "eslint": "^8.36.0", "eslint-config-unjs": "^0.1.0", "figures": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0d03008..2d588607 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,9 +13,6 @@ devDependencies: colorette: specifier: ^2.0.19 version: 2.0.19 - dayjs: - specifier: ^1.11.7 - version: 1.11.7 eslint: specifier: ^8.36.0 version: 8.36.0 @@ -1354,10 +1351,6 @@ packages: which: 2.0.2 dev: true - /dayjs@1.11.7: - resolution: {integrity: sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==} - dev: true - /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: diff --git a/src/reporters/basic.ts b/src/reporters/basic.ts index 5a76c0b1..4ad45bcf 100644 --- a/src/reporters/basic.ts +++ b/src/reporters/basic.ts @@ -1,10 +1,8 @@ import util from "node:util"; import { parseStack } from "../utils/error"; import { writeStream } from "../utils/stream"; -import { formatDate } from "../utils/date"; const DEFAULTS = { - dateFormat: "HH:mm:ss", formatOptions: { date: true, colors: false, @@ -41,9 +39,7 @@ export default class BasicReporter { } formatDate(date) { - return this.options.formatOptions.date - ? formatDate(this.options.dateFormat, date) - : ""; + return this.options.formatOptions.date ? date.toLocaleTimeString() : ""; } filterAndJoin(arr) { diff --git a/src/reporters/fancy.ts b/src/reporters/fancy.ts index 4f626981..84f56c2f 100644 --- a/src/reporters/fancy.ts +++ b/src/reporters/fancy.ts @@ -6,7 +6,7 @@ import { TYPE_COLOR_MAP, LEVEL_COLOR_MAP } from "../utils/fancy"; import BasicReporter from "./basic"; const DEFAULTS = { - secondaryColor: "grey", + secondaryColor: "gray", formatOptions: { date: true, colors: true, diff --git a/src/utils/date.ts b/src/utils/date.ts deleted file mode 100644 index 616c7f02..00000000 --- a/src/utils/date.ts +++ /dev/null @@ -1,5 +0,0 @@ -import dayjs from "dayjs"; - -export function formatDate(timeFormat, date) { - return dayjs(date).format(timeFormat); -}