Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(whiteboard): Lazy load the whiteboard dependeny.

damenchod11a9daf4130
diff --git a/custom.d.ts b/custom.d.ts
index 69f38596d4..16c3b07459 100644
--- a/custom.d.ts
+++ b/custom.d.ts
@@ -1,3 +1,8 @@
+declare module '*.css' {
+ const content: Record<string, string>;
+ export default content;
+}
+
declare module '*.svg' {
const content: any;
export default content;
diff --git a/react/features/whiteboard/components/web/Whiteboard.tsx b/react/features/whiteboard/components/web/Whiteboard.tsx
index f9bf14f762..b1423fa1b7 100644
--- a/react/features/whiteboard/components/web/Whiteboard.tsx
+++ b/react/features/whiteboard/components/web/Whiteboard.tsx
@@ -1,10 +1,8 @@
-import { ExcalidrawApp } from '@jitsi/excalidraw';
import clsx from 'clsx';
import i18next from 'i18next';
-import React, { useCallback, useEffect, useRef } from 'react';
+import React, { Suspense, useCallback, useEffect, useRef } from 'react';
import { WithTranslation } from 'react-i18next';
import { useSelector, useStore } from 'react-redux';
-import '@jitsi/excalidraw/index.css';
// @ts-expect-error
import Filmstrip from '../../../../../modules/UI/videolayout/Filmstrip';
@@ -24,6 +22,15 @@ import {
isWhiteboardVisible
} from '../../functions';
+const LazyExcalidrawApp = React.lazy(async () => {
+ const [ { ExcalidrawApp } ] = await Promise.all([
+ import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw'),
+ import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw/index.css')
+ ]);
+
+ return { default: ExcalidrawApp };
+});
+
/**
* Space taken by meeting elements like the subject and the watermark.
*/
@@ -163,19 +170,21 @@ const Whiteboard = (props: WithTranslation): JSX.Element => {
{ props.t('whiteboard.accessibilityLabel.heading') }
</span>
}
- <ExcalidrawApp
- collabDetails = { collabDetails }
- collabServerUrl = { collabServerUrl }
- excalidraw = {{
- isCollaborating: true,
- langCode: i18next.language,
- theme: 'light',
- UIOptions: WHITEBOARD_UI_OPTIONS
- }}
- getCollabAPI = { getCollabAPI }
- getExcalidrawAPI = { getExcalidrawAPI }
- meetingDetails = { meetingDetails }
- storageBackendUrl = { storageBackendUrl } />
+ <Suspense fallback = { null }>
+ <LazyExcalidrawApp
+ collabDetails = { collabDetails }
+ collabServerUrl = { collabServerUrl }
+ excalidraw = {{
+ isCollaborating: true,
+ langCode: i18next.language,
+ theme: 'light',
+ UIOptions: WHITEBOARD_UI_OPTIONS
+ }}
+ getCollabAPI = { getCollabAPI }
+ getExcalidrawAPI = { getExcalidrawAPI }
+ meetingDetails = { meetingDetails }
+ storageBackendUrl = { storageBackendUrl } />
+ </Suspense>
</div>
)}
</div>
diff --git a/react/features/whiteboard/components/web/WhiteboardApp.tsx b/react/features/whiteboard/components/web/WhiteboardApp.tsx
index 7a99a423a9..3937262950 100644
--- a/react/features/whiteboard/components/web/WhiteboardApp.tsx
+++ b/react/features/whiteboard/components/web/WhiteboardApp.tsx
@@ -1,4 +1,3 @@
-import { generateCollaborationLinkData } from '@jitsi/excalidraw';
import React, { ComponentType } from 'react';
import BaseApp from '../../../base/app/components/BaseApp';
@@ -33,6 +32,9 @@ export default class WhiteboardApp extends BaseApp<any> {
if (!roomId && !roomKey) {
try {
+ const { generateCollaborationLinkData } = await import(
+ /* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw'
+ );
const collabDetails = await generateCollaborationLinkData();
roomId = collabDetails.roomId;
diff --git a/react/features/whiteboard/components/web/WhiteboardWrapper.tsx b/react/features/whiteboard/components/web/WhiteboardWrapper.tsx
index ca1a24dc47..6688be9f4b 100644
--- a/react/features/whiteboard/components/web/WhiteboardWrapper.tsx
+++ b/react/features/whiteboard/components/web/WhiteboardWrapper.tsx
@@ -1,13 +1,20 @@
-import { ExcalidrawApp } from '@jitsi/excalidraw';
import i18next from 'i18next';
-import React, { useCallback, useRef } from 'react';
+import React, { Suspense, useCallback, useRef } from 'react';
import { useSelector } from 'react-redux';
-import '@jitsi/excalidraw/index.css';
import { IReduxState } from '../../../app/types';
import { WHITEBOARD_UI_OPTIONS } from '../../constants';
import { getStorageBackendUrl } from '../../functions';
+const LazyExcalidrawApp = React.lazy(async () => {
+ const [ { ExcalidrawApp } ] = await Promise.all([
+ import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw'),
+ import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw/index.css')
+ ]);
+
+ return { default: ExcalidrawApp };
+});
+
/**
* Whiteboard wrapper for mobile.
*
@@ -50,22 +57,22 @@ const WhiteboardWrapper = ({
return (
<div className = { className }>
<div className = 'excalidraw-wrapper'>
- <ExcalidrawApp
- collabDetails = { collabDetails }
- collabServerUrl = { collabServerUrl }
- excalidraw = {{
- isCollaborating: true,
- langCode: i18next.language,
- theme: 'light',
- UIOptions: WHITEBOARD_UI_OPTIONS
- }}
- getCollabAPI = { getCollabAPI }
- getExcalidrawAPI = { getExcalidrawAPI }
- jwt = { jwt }
- storageBackendUrl = { storageBackendUrl } />
+ <Suspense fallback = { null }>
+ <LazyExcalidrawApp
+ collabDetails = { collabDetails }
+ collabServerUrl = { collabServerUrl }
+ excalidraw = {{
+ isCollaborating: true,
+ langCode: i18next.language,
+ theme: 'light',
+ UIOptions: WHITEBOARD_UI_OPTIONS
+ }}
+ getCollabAPI = { getCollabAPI }
+ getExcalidrawAPI = { getExcalidrawAPI }
+ jwt = { jwt }
+ storageBackendUrl = { storageBackendUrl } />
+ </Suspense>
</div>
-
-
</div>
);
};
diff --git a/react/features/whiteboard/middleware.web.ts b/react/features/whiteboard/middleware.web.ts
index f2a4734718..44c44a5e46 100644
--- a/react/features/whiteboard/middleware.web.ts
+++ b/react/features/whiteboard/middleware.web.ts
@@ -1,4 +1,3 @@
-import { generateCollaborationLinkData } from '@jitsi/excalidraw';
import { AnyAction } from 'redux';
import { IStore } from '../app/types';
@@ -142,6 +141,7 @@ function raiseWhiteboardNotification(status: WhiteboardStatus) {
*/
async function setNewWhiteboardOpen(store: IStore) {
const { dispatch, getState } = store;
+ const { generateCollaborationLinkData } = await import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw');
const collabLinkData = await generateCollaborationLinkData();
const state = getState();
const conference = getCurrentConference(state);
diff --git a/webpack.config.js b/webpack.config.js
index 859585168c..abeb8dead9 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -345,7 +345,7 @@ module.exports = (_env, argv) => {
})
],
- performance: getPerformanceHints(perfHintOptions, 6 * 1024 * 1024) },
+ performance: getPerformanceHints(perfHintOptions, 5 * 1024 * 1024) },
{ ...config,
entry: {
'alwaysontop': './react/features/always-on-top/index.tsx'