Skip to content

Commit a910cd3

Browse files
committed
tree shaking
1 parent d50cf0d commit a910cd3

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

src/spreadsheet.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,41 @@ import "@univerjs/docs-ui/lib/index.css";
2222
import "@univerjs/sheets-ui/lib/index.css";
2323
import "@univerjs/sheets-formula/lib/index.css";
2424

25-
const univer_core = import("@univerjs/core");
26-
const design = import("@univerjs/design");
27-
const render_engine = import("@univerjs/engine-render");
28-
const ui_plugin = import("@univerjs/ui");
29-
const sheets_plugin = import("@univerjs/sheets");
30-
const sheets_ui_plugin = import("@univerjs/sheets-ui");
31-
const engine_formula = import("@univerjs/engine-formula");
32-
const sheets_numfmt = import("@univerjs/sheets-numfmt");
33-
const sheets_formula = import("@univerjs/sheets-formula");
34-
const facade = import("@univerjs/facade");
25+
const univer_core = import("@univerjs/core").then(
26+
({ Univer, LocaleType, Tools }) => ({ Univer, LocaleType, Tools }),
27+
);
28+
const design = import("@univerjs/design").then(({ defaultTheme }) => ({
29+
defaultTheme,
30+
}));
31+
const render_engine = import("@univerjs/engine-render").then(
32+
({ UniverRenderEnginePlugin }) => UniverRenderEnginePlugin,
33+
);
34+
const ui_plugin = import("@univerjs/ui").then(
35+
({ UniverUIPlugin }) => UniverUIPlugin,
36+
);
37+
const sheets_plugin = import("@univerjs/sheets").then(
38+
({ UniverSheetsPlugin }) => UniverSheetsPlugin,
39+
);
40+
const sheets_ui_plugin = import("@univerjs/sheets-ui").then(
41+
({ UniverSheetsUIPlugin }) => UniverSheetsUIPlugin,
42+
);
43+
const engine_formula = import("@univerjs/engine-formula").then(
44+
({ UniverFormulaEnginePlugin }) => UniverFormulaEnginePlugin,
45+
);
46+
const sheets_numfmt = import("@univerjs/sheets-numfmt").then(
47+
({ UniverSheetsNumfmtPlugin }) => UniverSheetsNumfmtPlugin,
48+
);
49+
const sheets_formula = import("@univerjs/sheets-formula").then(
50+
({ UniverSheetsFormulaPlugin }) => UniverSheetsFormulaPlugin,
51+
);
52+
const facade = import("@univerjs/facade").then(({ FUniver }) => ({ FUniver }));
3553
const zod = import("zod");
36-
const docs_plugin = import("@univerjs/docs");
37-
const docs_ui_plugin = import("@univerjs/docs-ui");
54+
const docs_plugin = import("@univerjs/docs").then(
55+
({ UniverDocsPlugin }) => UniverDocsPlugin,
56+
);
57+
const docs_ui_plugin = import("@univerjs/docs-ui").then(
58+
({ UniverDocsUIPlugin }) => UniverDocsUIPlugin,
59+
);
3860

3961
const DesignEnUS = import(
4062
"node_modules/@univerjs/design/lib/locale/en-US.json"
@@ -105,21 +127,21 @@ async function setupUniver(container: HTMLElement) {
105127
},
106128
});
107129

108-
univer.registerPlugin((await render_engine).UniverRenderEnginePlugin);
130+
univer.registerPlugin((await render_engine));
109131
container.className = "sqlpage_spreadsheet";
110-
univer.registerPlugin((await ui_plugin).UniverUIPlugin, { container });
111-
univer.registerPlugin((await sheets_plugin).UniverSheetsPlugin);
112-
univer.registerPlugin((await sheets_ui_plugin).UniverSheetsUIPlugin);
113-
univer.registerPlugin((await docs_plugin).UniverDocsPlugin);
114-
univer.registerPlugin((await docs_ui_plugin).UniverDocsUIPlugin);
132+
univer.registerPlugin((await ui_plugin), { container });
133+
univer.registerPlugin((await sheets_plugin));
134+
univer.registerPlugin((await sheets_ui_plugin));
135+
univer.registerPlugin((await docs_plugin));
136+
univer.registerPlugin((await docs_ui_plugin));
115137

116138
return univer;
117139
}
118140

119141
async function loadOptionalPlugins(univer: Univer) {
120-
univer.registerPlugin((await engine_formula).UniverFormulaEnginePlugin);
121-
univer.registerPlugin((await sheets_numfmt).UniverSheetsNumfmtPlugin);
122-
univer.registerPlugin((await sheets_formula).UniverSheetsFormulaPlugin);
142+
univer.registerPlugin((await engine_formula));
143+
univer.registerPlugin((await sheets_numfmt));
144+
univer.registerPlugin((await sheets_formula));
123145
}
124146

125147
function setupErrorModal(resp_modal: HTMLElement) {

0 commit comments

Comments
 (0)