mirror of
https://github.com/go-sigma/sigma.git
synced 2026-10-28 15:05:06 +08:00
refactor(web): import lodash helpers from lodash-es
The web app only uses `size` and `orderBy`, and `lodash` is the CommonJS build that the bundler cannot tree-shake. Import the helpers by name from `lodash-es` instead, drop `lodash` and declare `@types/lodash-es` (it was only reachable through bytemd before). Verification: - bunx tsc --noEmit - bun run lint - bun run build
This commit is contained in:
1 parent
fb4ae986d1
commit
2b47c02f4e
5 files changed
+10
-13
No files matched your search
+1
-3
@@ -27,7 +27,6 @@
|
||||
"csstype": "^3.2.3",
|
||||
"dayjs": "^1.11.23",
|
||||
"human-format": "^1.4.0",
|
||||
"lodash": "^4.18.1",
|
||||
"lodash-es": "^4.18.1",
|
||||
"lucide-react": "^1.62.0",
|
||||
"react": "^19.3.1",
|
||||
@@ -48,6 +47,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.13",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^26.6.5",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
@@ -799,8 +799,6 @@
|
||||
|
||||
"locate-path": ["locate-path@3.0.0", "", { "dependencies": { "p-locate": "^3.0.0", "path-exists": "^3.0.0" } }, "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A=="],
|
||||
|
||||
"lodash": ["lodash@4.18.1", "", {}, "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q=="],
|
||||
|
||||
"lodash-es": ["lodash-es@4.18.1", "", {}, "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A=="],
|
||||
|
||||
"log-symbols": ["log-symbols@6.0.0", "", { "dependencies": { "chalk": "^5.3.0", "is-unicode-supported": "^1.3.0" } }, "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw=="],
|
||||
|
||||
+1
-1
@@ -33,7 +33,6 @@
|
||||
"csstype": "^3.2.3",
|
||||
"dayjs": "^1.11.23",
|
||||
"human-format": "^1.4.0",
|
||||
"lodash": "^4.18.1",
|
||||
"lodash-es": "^4.18.1",
|
||||
"lucide-react": "^1.62.0",
|
||||
"react": "^19.3.1",
|
||||
@@ -54,6 +53,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.13",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^26.6.5",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
ChevronRight,
|
||||
ChevronUp,
|
||||
@@ -604,7 +603,7 @@ function UpdateProfileModal({ open, onOpenChange, localServer, username: initial
|
||||
const data: { [key: string]: any } = {};
|
||||
if (usernameInput.length > 0) data.username = usernameInput;
|
||||
if (emailInput.length > 0) data.email = emailInput;
|
||||
if (_.size(data) > 0) {
|
||||
if (Object.keys(data).length > 0) {
|
||||
axios.put(`${localServer}/api/v1/users/self`, data).then(response => {
|
||||
if (response?.status === 204) {
|
||||
Toast({ level: "success", title: t("common.success"), message: t("menu.profileUpdated") });
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import { ChevronUpDownIcon } from '@heroicons/react/20/solid';
|
||||
import { Info } from 'lucide-react';
|
||||
import axios from "axios";
|
||||
import _ from 'lodash';
|
||||
import { orderBy } from "lodash-es";
|
||||
import { Fragment, useCallback, useEffect, useState } from 'react';
|
||||
import { Helmet, HelmetProvider } from 'react-helmet-async';
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||
@@ -128,7 +128,7 @@ export default function ({ localServer }: { localServer: string }) {
|
||||
axios.get(url).then(response => {
|
||||
if (response?.status === 200) {
|
||||
const namespaceListData = response.data as INamespaceList;
|
||||
setNamespaceList(_.orderBy(namespaceListData.items, ['name']));
|
||||
setNamespaceList(orderBy(namespaceListData.items, ['name']));
|
||||
} else {
|
||||
const errorcode = response.data as IHTTPError;
|
||||
Toast({ level: "warning", title: errorcode.title, message: errorcode.description });
|
||||
@@ -160,7 +160,7 @@ export default function ({ localServer }: { localServer: string }) {
|
||||
axios.get(url).then(response => {
|
||||
if (response?.status === 200) {
|
||||
const repositoryListData = response.data as IRepositoryList;
|
||||
setRepositoryList(_.orderBy(repositoryListData.items, ['name']));
|
||||
setRepositoryList(orderBy(repositoryListData.items, ['name']));
|
||||
} else {
|
||||
const errorcode = response.data as IHTTPError;
|
||||
Toast({ level: "warning", title: errorcode.title, message: errorcode.description });
|
||||
@@ -228,7 +228,7 @@ export default function ({ localServer }: { localServer: string }) {
|
||||
axios.get(`${localServer}/api/v1/coderepos/${codeRepositoryProviderSelected.provider}/owners`).then(response => {
|
||||
if (response.status == 200) {
|
||||
const data = response.data as ICodeRepositoryOwnerList;
|
||||
setCodeRepositoryOwnerList(_.orderBy(data.items, ['is_org']));
|
||||
setCodeRepositoryOwnerList(orderBy(data.items, ['is_org']));
|
||||
} else {
|
||||
const errorcode = response.data as IHTTPError;
|
||||
Toast({ level: "warning", title: errorcode.title, message: errorcode.description });
|
||||
@@ -261,7 +261,7 @@ export default function ({ localServer }: { localServer: string }) {
|
||||
axios.get(url).then(response => {
|
||||
if (response.status == 200) {
|
||||
const data = response.data as ICodeRepositoryList;
|
||||
setCodeRepositoryList(_.orderBy(data.items, ['name']));
|
||||
setCodeRepositoryList(orderBy(data.items, ['name']));
|
||||
} else {
|
||||
const errorcode = response.data as IHTTPError;
|
||||
Toast({ level: "warning", title: errorcode.title, message: errorcode.description });
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import axios from "axios";
|
||||
import dayjs from "dayjs";
|
||||
import _ from "lodash";
|
||||
import { orderBy } from "lodash-es";
|
||||
import { CornerDownLeft, RefreshCw } from "lucide-react";
|
||||
import { Fragment, useEffect, useRef, useState } from "react";
|
||||
import { Helmet, HelmetProvider } from "react-helmet-async";
|
||||
@@ -91,7 +91,7 @@ export default function ({ localServer }: { localServer: string }) {
|
||||
.then((response) => {
|
||||
if (response.status == 200) {
|
||||
const data = response.data as ICodeRepositoryOwnerList;
|
||||
setCodeRepositoryOwners(_.orderBy(data.items, ["is_org"]));
|
||||
setCodeRepositoryOwners(orderBy(data.items, ["is_org"]));
|
||||
for (let i = 0; i < data.items.length; i++) {
|
||||
if (!data.items[i].is_org) {
|
||||
setOrganization(data.items[i].owner);
|
||||
|
||||
Reference in new issue
Block a user