Skip to content

Commit cbea407

Browse files
committed
Remove lodash deps to reduce bundle size more
1 parent 0403fa9 commit cbea407

File tree

8 files changed

+36
-29
lines changed

8 files changed

+36
-29
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"name": "pterodactyl-panel",
33
"dependencies": {
4-
"@fortawesome/fontawesome-svg-core": "^1.2.19",
4+
"@fortawesome/fontawesome-svg-core": "1.2.19",
55
"@fortawesome/free-solid-svg-icons": "^5.9.0",
6-
"@fortawesome/react-fontawesome": "^0.1.4",
6+
"@fortawesome/react-fontawesome": "0.1.4",
77
"@types/react-google-recaptcha": "^1.1.1",
88
"axios": "^0.19.2",
99
"ayu-ace": "^2.0.4",
1010
"brace": "^0.11.1",
1111
"chart.js": "^2.8.0",
1212
"date-fns": "^2.14.0",
13+
"debounce": "^1.2.0",
14+
"deepmerge": "^4.2.2",
1315
"easy-peasy": "^3.3.1",
1416
"events": "^3.0.0",
1517
"formik": "^2.1.4",
@@ -18,11 +20,11 @@
1820
"i18next-localstorage-backend": "^3.0.0",
1921
"i18next-xhr-backend": "^3.2.2",
2022
"jquery": "^3.3.1",
21-
"lodash-es": "^4.17.15",
2223
"path": "^0.12.7",
2324
"query-string": "^6.7.0",
2425
"react": "^16.13.1",
2526
"react-dom": "npm:@hot-loader/react-dom",
27+
"react-fast-compare": "^3.2.0",
2628
"react-google-recaptcha": "^2.0.1",
2729
"react-hot-loader": "^4.12.21",
2830
"react-i18next": "^11.2.1",
@@ -52,10 +54,8 @@
5254
"@babel/preset-typescript": "^7.7.4",
5355
"@babel/runtime": "^7.7.5",
5456
"@types/chart.js": "^2.8.5",
57+
"@types/debounce": "^1.2.0",
5558
"@types/events": "^3.0.0",
56-
"@types/feather-icons": "^4.7.0",
57-
"@types/lodash": "^4.14.119",
58-
"@types/lodash-es": "^4.17.3",
5959
"@types/node": "^12.6.9",
6060
"@types/query-string": "^6.3.0",
6161
"@types/react": "^16.9.41",

resources/scripts/components/dashboard/search/SearchModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Modal, { RequiredModalProps } from '@/components/elements/Modal';
33
import { Field, Form, Formik, FormikHelpers, useFormikContext } from 'formik';
44
import { Actions, useStoreActions, useStoreState } from 'easy-peasy';
55
import { object, string } from 'yup';
6-
import { debounce } from 'lodash-es';
6+
import debounce from 'debounce';
77
import FormikFieldWrapper from '@/components/elements/FormikFieldWrapper';
88
import InputSpinner from '@/components/elements/InputSpinner';
99
import getServers from '@/api/getServers';
@@ -57,6 +57,7 @@ export default ({ ...props }: Props) => {
5757
setLoading(true);
5858
setSubmitting(false);
5959
clearFlashes('search');
60+
6061
getServers(term)
6162
.then(servers => setServers(servers.items.filter((_, index) => index < 5)))
6263
.catch(error => {

resources/scripts/components/elements/InputError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2-
import capitalize from 'lodash-es/capitalize';
32
import { FormikErrors, FormikTouched } from 'formik';
43
import tw from 'twin.macro';
4+
import { capitalize } from '@/helpers';
55

66
interface Props {
77
errors: FormikErrors<any>;

resources/scripts/components/server/StatGraphs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react';
22
import Chart, { ChartConfiguration } from 'chart.js';
33
import { ServerContext } from '@/state/server';
44
import { bytesToMegabytes } from '@/helpers';
5-
import merge from 'lodash-es/merge';
5+
import merge from 'deepmerge';
66
import TitledGreyBox from '@/components/elements/TitledGreyBox';
77
import { faMemory, faMicrochip } from '@fortawesome/free-solid-svg-icons';
88
import tw from 'twin.macro';
@@ -59,7 +59,7 @@ const chartDefaults: ChartConfiguration = {
5959
};
6060

6161
const createDefaultChart = (ctx: CanvasRenderingContext2D, options?: ChartConfiguration): Chart => new Chart(ctx, {
62-
...merge({}, chartDefaults, options),
62+
...merge(chartDefaults, options || {}),
6363
data: {
6464
labels: Array(20).fill(''),
6565
datasets: [

resources/scripts/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ export const bytesToMegabytes = (bytes: number) => Math.floor(bytes / 1000 / 100
1313
export const randomInt = (low: number, high: number) => Math.floor(Math.random() * (high - low) + low);
1414

1515
export const cleanDirectoryPath = (path: string) => path.replace(/(^#\/*)|(\/(\/*))|(^$)/g, '/');
16+
17+
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();

resources/scripts/plugins/useDeepMemo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRef } from 'react';
2-
import isEqual from 'lodash-es/isEqual';
2+
import isEqual from 'react-fast-compare';
33

44
export const useDeepMemo = <T, K> (fn: () => T, key: K): T => {
55
const ref = useRef<{ key: K, value: T }>();

webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ module.exports = {
7373
files: `${path.join(__dirname, '/resources/scripts')}/**/*.{ts,tsx}`,
7474
},
7575
}) : null,
76-
process.env.ANALYZE_BUNDLE ? new BundleAnalyzerPlugin() : null
76+
process.env.ANALYZE_BUNDLE ? new BundleAnalyzerPlugin({
77+
analyzerHost: '0.0.0.0',
78+
analyzerPort: 8081,
79+
}) : null
7780
].filter(p => p),
7881
optimization: {
7982
usedExports: true,

yarn.lock

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,10 @@
892892
version "0.2.19"
893893
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.19.tgz#754a0f85e1290858152e1c05700ab502b11197f1"
894894

895-
"@fortawesome/fontawesome-svg-core@^1.2.19":
895+
"@fortawesome/fontawesome-svg-core@1.2.19":
896896
version "1.2.19"
897897
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.19.tgz#0eca1ce9285c3d99e6e340633ee8f615f9d1a2e0"
898+
integrity sha512-D4ICXg9oU08eF9o7Or392gPpjmwwgJu8ecCFusthbID95CLVXOgIyd4mOKD9Nud5Ckz+Ty59pqkNtThDKR0erA==
898899
dependencies:
899900
"@fortawesome/fontawesome-common-types" "^0.2.19"
900901

@@ -904,9 +905,10 @@
904905
dependencies:
905906
"@fortawesome/fontawesome-common-types" "^0.2.19"
906907

907-
"@fortawesome/react-fontawesome@^0.1.4":
908+
"@fortawesome/react-fontawesome@0.1.4":
908909
version "0.1.4"
909910
resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.4.tgz#18d61d9b583ca289a61aa7dccc05bd164d6bc9ad"
911+
integrity sha512-GwmxQ+TK7PEdfSwvxtGnMCqrfEm0/HbRHArbUudsYiy9KzVCwndxa2KMcfyTQ8El0vROrq8gOOff09RF1oQe8g==
910912
dependencies:
911913
humps "^2.0.1"
912914
prop-types "^15.5.10"
@@ -935,6 +937,11 @@
935937
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
936938
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
937939

940+
"@types/debounce@^1.2.0":
941+
version "1.2.0"
942+
resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.2.0.tgz#9ee99259f41018c640b3929e1bb32c3dcecdb192"
943+
integrity sha512-bWG5wapaWgbss9E238T0R6bfo5Fh3OkeoSt245CM7JJwVwpw6MEBCbIxLq5z8KzsE3uJhzcIuQkyiZmzV3M/Dw==
944+
938945
"@types/eslint-visitor-keys@^1.0.0":
939946
version "1.0.0"
940947
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
@@ -943,10 +950,6 @@
943950
version "3.0.0"
944951
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
945952

946-
"@types/feather-icons@^4.7.0":
947-
version "4.7.0"
948-
resolved "https://registry.yarnpkg.com/@types/feather-icons/-/feather-icons-4.7.0.tgz#ec66bc046bcd1513835f87541ecef54b50c57ec9"
949-
950953
"@types/glob@^7.1.1":
951954
version "7.1.1"
952955
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
@@ -980,16 +983,6 @@
980983
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
981984
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
982985

983-
"@types/lodash-es@^4.17.3":
984-
version "4.17.3"
985-
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.3.tgz#87eb0b3673b076b8ee655f1890260a136af09a2d"
986-
dependencies:
987-
"@types/lodash" "*"
988-
989-
"@types/lodash@*", "@types/lodash@^4.14.119":
990-
version "4.14.141"
991-
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.141.tgz#d81f4d0c562abe28713406b571ffb27692a82ae6"
992-
993986
"@types/minimatch@*":
994987
version "3.0.3"
995988
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@@ -2411,6 +2404,7 @@ date-now@^0.1.4:
24112404
debounce@^1.2.0:
24122405
version "1.2.0"
24132406
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131"
2407+
integrity sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==
24142408

24152409
debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
24162410
version "2.6.9"
@@ -3759,6 +3753,7 @@ https-browserify@^1.0.0:
37593753
humps@^2.0.1:
37603754
version "2.0.1"
37613755
resolved "https://registry.yarnpkg.com/humps/-/humps-2.0.1.tgz#dd02ea6081bd0568dc5d073184463957ba9ef9aa"
3756+
integrity sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao=
37623757

37633758
i18next-chained-backend@^2.0.0:
37643759
version "2.0.0"
@@ -4355,7 +4350,7 @@ locate-path@^5.0.0:
43554350
dependencies:
43564351
p-locate "^4.1.0"
43574352

4358-
lodash-es@^4.17.11, lodash-es@^4.17.14, lodash-es@^4.17.15:
4353+
lodash-es@^4.17.11, lodash-es@^4.17.14:
43594354
version "4.17.15"
43604355
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78"
43614356

@@ -5407,6 +5402,7 @@ promise-inflight@^1.0.1:
54075402
prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
54085403
version "15.7.2"
54095404
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
5405+
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
54105406
dependencies:
54115407
loose-envify "^1.4.0"
54125408
object-assign "^4.1.1"
@@ -5568,6 +5564,11 @@ react-fast-compare@^2.0.1:
55685564
version "2.0.4"
55695565
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
55705566

5567+
react-fast-compare@^3.2.0:
5568+
version "3.2.0"
5569+
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
5570+
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==
5571+
55715572
react-google-recaptcha@^2.0.1:
55725573
version "2.0.1"
55735574
resolved "https://registry.yarnpkg.com/react-google-recaptcha/-/react-google-recaptcha-2.0.1.tgz#3276b29659493f7ca2a5b7739f6c239293cdf1d8"

0 commit comments

Comments
 (0)