You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/10/10 02:05:32 UTC
(incubator-answer) 02/04: chore(ui): Dynamically import plugins
This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch refactor/plugin
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit a0e387de9cdb641ef637ba0c4a1cd2ac0e9f465c
Author: robin <ro...@rnode.me>
AuthorDate: Tue Oct 8 16:52:36 2024 +0800
chore(ui): Dynamically import plugins
---
ui/scripts/plugin.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.js
index d554df8f..a3f09df5 100644
--- a/ui/scripts/plugin.js
+++ b/ui/scripts/plugin.js
@@ -63,7 +63,8 @@ function addPluginToIndexTs(packageName) {
const indexTsContent = fs.readFileSync(indexTsPath, 'utf-8');
const lines = indexTsContent.split('\n');
const ComponentName = pascalize(packageName);
- const importLine = `export { default as ${ComponentName} } from '${packageName}';`;
+
+ const importLine = `export const load${ComponentName} = () => import('${packageName}').then(module => module.default);`;
if (!lines.includes(importLine)) {
lines.push(importLine);
}