Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor: make more plugins lazy loaded (#5087)

Wenzhao Hu0a78b4df13f3
diff --git a/examples/src/sheets/lazy.ts b/examples/src/sheets/lazy.ts
index 88bdbc0fac..9d309e25d7 100644
--- a/examples/src/sheets/lazy.ts
+++ b/examples/src/sheets/lazy.ts
@@ -15,13 +15,27 @@
*/
import type { Plugin, PluginCtor } from '@univerjs/core';
+import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
+import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui';
import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';
import { UniverSheetsDataValidationUIPlugin } from '@univerjs/sheets-data-validation-ui';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
import { UniverSheetsFilterUIPlugin } from '@univerjs/sheets-filter-ui';
+import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';
+import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui';
+import { UniverSheetTableUIPlugin } from '@univerjs/sheets-table-ui';
+import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui';
+import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> {
return [
+ [UniverDocsDrawingUIPlugin],
+ [UniverDocsMentionUIPlugin],
+ [UniverSheetsNumfmtUIPlugin],
+ [UniverThreadCommentUIPlugin],
+ [UniverSheetsThreadCommentUIPlugin],
+ [UniverSheetTableUIPlugin],
+ [UniverSheetsFormulaUIPlugin],
[UniverSheetsDataValidationUIPlugin],
[UniverSheetsConditionalFormattingUIPlugin],
[UniverSheetsFilterUIPlugin, { useRemoteFilterValuesGenerator: false }],
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index c3631375bc..3a4ba40dec 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -19,8 +19,6 @@ import { FUniver } from '@univerjs/core/facade';
import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { defaultTheme } from '@univerjs/design';
import { UniverDocsPlugin } from '@univerjs/docs';
-import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
-import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
@@ -32,19 +30,14 @@ import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-condit
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
-import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';
import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
-import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui';
import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';
import { UniverSheetsBindingSourcePlugin } from '@univerjs/sheets-source-binding';
import { UniverSheetTablePlugin } from '@univerjs/sheets-table';
-import { UniverSheetTableUIPlugin } from '@univerjs/sheets-table-ui';
import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
-import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui';
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';
-import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
import { UniverUIPlugin } from '@univerjs/ui';
import { enUS, faIR, frFR, ruRU, viVN, zhCN, zhTW } from '../locales';
@@ -117,8 +110,6 @@ function createNewInstance() {
container: 'app',
});
univer.registerPlugin(UniverDocsUIPlugin);
- univer.registerPlugin(UniverDocsDrawingUIPlugin);
- univer.registerPlugin(UniverDocsMentionUIPlugin);
univer.registerPlugin(UniverSheetsPlugin, { notExecuteFormula: true });
univer.registerPlugin(UniverSheetsUIPlugin);
@@ -128,22 +119,17 @@ function createNewInstance() {
});
univer.registerPlugin(UniverSheetsZenEditorPlugin);
univer.registerPlugin(UniverFormulaEnginePlugin, { notExecuteFormula: true });
- univer.registerPlugin(UniverSheetsNumfmtUIPlugin);
univer.registerPlugin(UniverSheetsFormulaPlugin, { notExecuteFormula: true });
- univer.registerPlugin(UniverSheetsFormulaUIPlugin);
univer.registerPlugin(UniverSheetsDataValidationPlugin);
univer.registerPlugin(UniverSheetsConditionalFormattingPlugin);
univer.registerPlugin(UniverSheetsFilterPlugin);
univer.registerPlugin(UniverSheetsSortPlugin);
univer.registerPlugin(UniverSheetsHyperLinkPlugin);
- univer.registerPlugin(UniverThreadCommentUIPlugin);
univer.registerPlugin(UniverSheetsThreadCommentPlugin);
- univer.registerPlugin(UniverSheetsThreadCommentUIPlugin);
univer.registerPlugin(UniverSheetsBindingSourcePlugin);
univer.registerPlugin(UniverSheetsCustomMenuPlugin);
univer.registerPlugin(UniverSheetTablePlugin);
- univer.registerPlugin(UniverSheetTableUIPlugin);
univer.registerPlugin(UniverNetworkPlugin);
univer.registerPlugin(ImportCSVButtonPlugin);