Skip to content

Commit aca33f2

Browse files
authored
Merge pull request #774 from raheeliftikhar5/lowcoder-sdk-webpack-bundle
[WIP] Reduce lowcoder-sdk initial bundle size
2 parents 8283f52 + 33bd8f7 commit aca33f2

File tree

201 files changed

+12800
-3009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+12800
-3009
lines changed

client/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"mq-polyfill": "^1.1.8",
5252
"prettier": "^3.1.0",
5353
"rimraf": "^3.0.2",
54-
"rollup": "^2.79.0",
5554
"shelljs": "^0.8.5",
5655
"svgo": "^3.0.0",
5756
"typescript": "^4.8.4",
@@ -75,11 +74,12 @@
7574
"@testing-library/react": "^14.1.2",
7675
"@testing-library/user-event": "^14.5.1",
7776
"@types/styled-components": "^5.1.34",
78-
"antd-mobile": "^5.28.0",
77+
"antd-mobile": "^5.34.0",
7978
"chalk": "4",
8079
"number-precision": "^1.6.0",
8180
"react-player": "^2.11.0",
8281
"resize-observer-polyfill": "^1.5.1",
82+
"rollup": "^4.13.0",
8383
"simplebar": "^6.2.5",
8484
"tui-image-editor": "^3.15.3"
8585
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/lib
22
/node_modules
3+
/package
34
*.tgz

client/packages/lowcoder-comps/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "ESNext",
44
"experimentalDecorators": true,
55
"lib": ["dom", "dom.iterable", "esnext"],
66
"allowJs": true,

client/packages/lowcoder-design/src/components/GlobalInstances.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { App } from 'antd';
2-
import type { MessageInstance } from 'antd/es/message/interface';
3-
import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
4-
import type { NotificationInstance } from 'antd/es/notification/interface';
1+
import { default as App } from "antd/es/app";
2+
import type { MessageInstance } from "antd/es/message/interface";
3+
import type { ModalStaticFunctions } from "antd/es/modal/confirm";
4+
import type { NotificationInstance } from "antd/es/notification/interface";
55

66
let messageInstance: MessageInstance;
77
let notificationInstance: NotificationInstance;

client/packages/lowcoder-design/src/components/Trees.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled, { css } from "styled-components";
22
import { ReactComponent as Folded } from "icons/icon-folded.svg";
3-
import { DataNode, TreeProps } from "antd/lib/tree";
4-
import DirectoryTree from "antd/lib/tree/DirectoryTree";
3+
import { DataNode, TreeProps } from "antd/es/tree";
4+
import DirectoryTree from "antd/es/tree/DirectoryTree";
55

66
export const Treediv = styled.div<{ $height?: number }>`
77
padding-left: 24px;

client/packages/lowcoder-design/src/components/audio.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { CSSProperties } from "react";
2-
import { Ref } from "react";
3-
import ReactPlayer from "react-player";
2+
import { lazy, Ref } from "react";
3+
import type {default as ReactPlayerType} from "react-player";
44
import styled from "styled-components";
55

6+
const ReactPlayer = lazy(() => import("react-player"));
7+
68
const Audio = styled(ReactPlayer)`
79
height: 32px !important;
810
`;
@@ -14,7 +16,7 @@ export function TacoAudio(props: {
1416
onEnded?: () => void;
1517
className?: string;
1618
style?: CSSProperties;
17-
audioRef?: Ref<ReactPlayer>;
19+
audioRef?: Ref<ReactPlayerType>;
1820
autoPlay?: boolean;
1921
loop?: boolean;
2022
}) {

client/packages/lowcoder-design/src/components/colorSelect/colorUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { colord, extend } from "colord";
22
import namesPlugin from "colord/plugins/names";
3-
import { generate } from "@ant-design/colors";
3+
import { generate } from "@ant-design/colors/es";
44

55
extend([namesPlugin]);
66

client/packages/lowcoder-design/src/components/iconSelect/index.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import type { IconDefinition } from "@fortawesome/free-regular-svg-icons";
33
// import type { IconDefinition as IconDefinitionBrands } from "@fortawesome/free-brands-svg-icons";
4-
import { Popover } from "antd";
5-
import { ActionType } from "@rc-component/trigger/lib/interface";
4+
import { default as Popover } from "antd/lib/popover";
5+
import type { ActionType } from "@rc-component/trigger/lib/interface";
66
import { TacoInput } from "components/tacoInput";
77
import { Tooltip } from "components/toolTip";
88
import { trans } from "i18n/design";
9-
import _ from "lodash";
9+
import { upperFirst, sortBy } from "lodash";
1010
import {
1111
ReactNode,
1212
useEffect,
1313
useCallback,
1414
useMemo,
1515
useRef,
1616
useState,
17+
Suspense
1718
} from "react";
1819
import Draggable from "react-draggable";
19-
import { default as List, ListRowProps } from "react-virtualized/dist/es/List";
20+
import { default as List, type ListRowProps } from "react-virtualized/dist/es/List";
2021
import styled from "styled-components";
2122
import { CloseIcon, SearchIcon } from "icons";
2223
import { ANTDICON } from "icons/antIcon";
23-
import { Divider } from "antd-mobile";
2424

2525
const PopupContainer = styled.div`
2626
width: 580px;
@@ -141,7 +141,7 @@ class Icon {
141141
readonly title: string;
142142
constructor(readonly def: IconDefinition | any, readonly names: string[]) {
143143
if (def?.iconName) {
144-
this.title = def.iconName.split("-").map(_.upperFirst).join(" ");
144+
this.title = def.iconName.split("-").map(upperFirst).join(" ");
145145
} else {
146146
this.title = names[0].slice(5);
147147
this.def = def;
@@ -231,7 +231,7 @@ function search(
231231
.toLowerCase()
232232
.split(/\s+/g)
233233
.filter((t) => t);
234-
return _.sortBy(
234+
return sortBy(
235235
Object.entries(allIcons).filter(([key, icon]) => {
236236
if (icon.names.length === 0) {
237237
return false;
@@ -297,7 +297,11 @@ const IconPopup = (props: {
297297
onChangeIcon(key);
298298
}}
299299
>
300-
<IconWrapper>{icon.getView()}</IconWrapper>
300+
<IconWrapper>
301+
<Suspense fallback={null}>
302+
{icon.getView()}
303+
</Suspense>
304+
</IconWrapper>
301305
<IconKeyDisplay>{key}</IconKeyDisplay>
302306
</IconItemContainer>
303307
</Tooltip>

client/packages/lowcoder-design/src/components/markdown.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { css } from "styled-components";
2-
import ReactMarkdown from "react-markdown";
2+
import { lazy } from "react";
3+
// import ReactMarkdown from "react-markdown";
34
import rehypeRaw from "rehype-raw";
45
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
56
import remarkGfm from "remark-gfm";
6-
import { ReactMarkdownOptions } from "react-markdown/lib/react-markdown";
7+
import type { ReactMarkdownOptions } from "react-markdown/lib/react-markdown";
8+
9+
const ReactMarkdown = lazy(() => import('react-markdown'));
710

811
export const markdownCompCss = css`
912
.markdown-body {

client/packages/lowcoder-design/src/components/query.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled, { css } from "styled-components";
22
import { default as Alert } from "antd/es/alert";
33
import { ReactNode } from "react";
4-
import { AlertProps } from "antd/lib/alert";
4+
import { AlertProps } from "antd/es/alert";
55
import { ToolTipLabel } from "./toolTip";
66
import { DocLink } from "components/ExternalLink";
77

client/packages/lowcoder-design/src/components/video.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import ReactPlayer from "react-player";
1+
// import ReactPlayer from "react-player";
2+
import { lazy } from 'react';
23
import styled from "styled-components";
34
import { videoPlayTriangle } from "icons";
45

6+
const ReactPlayer = lazy(() => import("react-player"));
7+
58
export const Video = styled(ReactPlayer)`
69
height: 100% !important;
710
width: 100% !important;

0 commit comments

Comments
 (0)