Skip to content

Commit

Permalink
Use lodash-es to reduce bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
PurkkaKoodari committed Jan 5, 2024
1 parent 3ba073c commit 10dffc5
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/ilmomasiina-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
},
"dependencies": {
"@tietokilta/ilmomasiina-models": "workspace:2.0.0-alpha13",
"@types/lodash": "^4.14.182",
"@types/lodash-es": "^4.17.9",
"@types/react": "^17 || ^18",
"bootstrap": "^4.6.1",
"final-form": "^4.20.10",
"formik": "^2.4.5",
"i18next": "^22.4.11",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"react": "^17 || ^18",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { ReactNode } from 'react';

import { useField } from 'formik';
import find from 'lodash/find';
import reject from 'lodash/reject';
import without from 'lodash/without';
import find from 'lodash-es/find';
import reject from 'lodash-es/reject';
import without from 'lodash-es/without';
import { Form } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import filter from 'lodash/filter';
import filter from 'lodash-es/filter';
import { Table } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import filter from 'lodash/filter';
import find from 'lodash/find';
import filter from 'lodash-es/filter';
import find from 'lodash-es/find';
import moment from 'moment-timezone';
import { useTranslation } from 'react-i18next';

Expand Down
4 changes: 2 additions & 2 deletions packages/ilmomasiina-components/src/utils/eventListUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import every from 'lodash/every';
import sumBy from 'lodash/sumBy';
import every from 'lodash-es/every';
import sumBy from 'lodash-es/sumBy';
import moment, { Moment } from 'moment-timezone';

import type {
Expand Down
6 changes: 3 additions & 3 deletions packages/ilmomasiina-components/src/utils/signupUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import find from 'lodash/find';
import orderBy from 'lodash/orderBy';
import sumBy from 'lodash/sumBy';
import find from 'lodash-es/find';
import orderBy from 'lodash-es/orderBy';
import sumBy from 'lodash-es/sumBy';
import moment from 'moment-timezone';

import type {
Expand Down
6 changes: 4 additions & 2 deletions packages/ilmomasiina-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@tietokilta/ilmomasiina-components": "workspace:2.0.0-alpha13",
"@tietokilta/ilmomasiina-models": "workspace:2.0.0-alpha13",
"@types/history": "^4.7.11",
"@types/lodash": "^4.14.182",
"@types/lodash-es": "^4.17.9",
"@types/node": "^16.11.41",
"@types/node-sass": "^4.11.2",
"@types/react": "^17.0.47",
Expand All @@ -39,7 +39,7 @@
"history": "^4.10.1",
"i18next": "^22.4.11",
"i18next-browser-languagedetector": "^7.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"react": "^17.0.2",
Expand All @@ -65,8 +65,10 @@
"typescript": "~4.9"
},
"devDependencies": {
"@types/lodash": "^4.14.199",
"@types/ws": "^8.5.3",
"rimraf": "^3.0.2",
"lodash": "^4.17.21",
"ws": "^8.8.0"
}
}
6 changes: 3 additions & 3 deletions packages/ilmomasiina-frontend/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ build(config)
const totals = new Map<string, number>();
for (const [path, { bytesInOutput }] of Object.entries(inputs)) {
// extract package name from path
const names = path.replace(/\\/g, '/').match(/\/node_modules\/(?:@[^/]+\/)?[^/]+/g) || ['.'];
const lastName = names[names.length - 1].replace('/node_modules/', '');
// const names = path.replace(/\\/g, '/').match(/\/node_modules\/(?:@[^/]+\/)?[^/]+/g) || ['.'];
// const lastName = names[names.length - 1].replace('/node_modules/', '');
// count size
totals.set(lastName, (totals.get(lastName) ?? 0) + bytesInOutput);
totals.set(path, (totals.get(path) ?? 0) + bytesInOutput);
}

// sort by name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { MouseEvent } from 'react';

import sumBy from 'lodash/sumBy';
import sumBy from 'lodash-es/sumBy';
import moment from 'moment-timezone';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
Expand Down
29 changes: 21 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10dffc5

Please sign in to comment.