Skip to content

Commit

Permalink
Use deep imports for date-fns to improve tree-shaking
Browse files Browse the repository at this point in the history
Change-type: patch
See: https://balena.zulipchat.com/#narrow/stream/346007-balena-io.2FbalenaCloud/topic/moment.20-.3E.20date-fns
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
  • Loading branch information
thgreasi committed Nov 4, 2022
1 parent 04ac82d commit 22ac680
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/util/date.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { formatDistance } from 'date-fns';
// TODO: Remvove the deep imports once we start offering an esm build
// and confirm that tree-shaking date-fns still works.
import formatDistance from 'date-fns/formatDistance';
import * as memoizee from 'memoizee';

const now = memoizee(() => new Date(), { maxAge: 1000 });
Expand Down
6 changes: 5 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": "./node_modules/@balena/lint/config/tslint-prettier.json",
"rules": {
"import-blacklist": [true, "lodash"]
"import-blacklist": [
true,
"date-fns",
"lodash"
]
}
}

0 comments on commit 22ac680

Please sign in to comment.