alibaba / lowcode-engine

An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系
https://lowcode-engine.cn
MIT License
14.58k stars 2.53k forks source link

@alifd/build-plugin-lowcode插件 如何传customPlugins问题 #2701

Closed mrliyaya closed 10 months ago

mrliyaya commented 10 months ago

Describe the bug (required) / 详细描述 bug(必填)

请问 customPlugins 如何正确传递,尝试了以下两种方法都未生效, 第一种:传递函数类型 {customPlugins: [()=> {}]} 第二种: 传递字符串类型 {customPlugins: ['./testPlugin.js']} A clear and concise description of what the bug is. / 请提供清晰且精确的 bug 描述 内部处理 customPlugins 用了 customPlugins: JSON.stringify(customPlugins), 传函数的话 会被过滤掉 image


To Reproduce (required) / 如何复现 bug?(必填,非常重要)

Steps to reproduce the behavior: / 详细复现步骤:


English version example:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

中文版示例:

  1. 打开 demo
  2. 点击标题;
  3. 在右侧修改标题内容为「修改后的标题」;
  4. 渲染画布标题组件没有更新显示为「修改后的标题」;

Expected behavior (required) / 预期行为(必填,非常重要)

A clear and concise description of what did you expect to happen. / 请清晰和精确的描述你预期的行为


Screenshots (optional) / bug 截图(可选)

Sceenshots for further information. (If applicable.) / 一些有用的截图将会帮助我们更好的明确以及定位问题


Environments (please complete the following information) (required): / 请提供如下信息(必填)

(this information can be collected via the manual plugin / 版本信息可通过低代码用户手册插件收集)

Additional context (optional) / 更多额外信息(可选)

Any other context of the problem here. / 可以追加更多的额外信息,帮助定位问题

liujuping commented 10 months ago

试一下:

{
  "plugins": [
    [
      "@alifd/build-plugin-lowcode",
      {
        "customPlugins": [
          ["./path/to/your-custom-plugin", { /* 你的插件选项 */ }]
        ]
      }
    ]
  ]
}
mrliyaya commented 10 months ago

试一下:

{
  "plugins": [
    [
      "@alifd/build-plugin-lowcode",
      {
        "customPlugins": [
          ["./path/to/your-custom-plugin", { /* 你的插件选项 */ }]
        ]
      }
    ]
  ]
}

尝试了下绝对路径这种写法,pluginContextMap 多了一项,plugins 没添加上


    ['/xxxxx/yyyy/lowcode-plugins/test.js', { pluginName: 'TestPlugin' }]
]```

![image](https://github.com/alibaba/lowcode-engine/assets/148785673/6fe42be5-8b0c-4333-b582-f7713034d1d8)
liujuping commented 10 months ago

先加上一些日志,看一下 plugin 是不是没有执行哈。

mrliyaya commented 10 months ago

我debug了下,发现以下问题

  1. build-plugin-lowcode 这个项目的 的public的模版通过<script src="<%= enginePresetJsUrl %>"></script>以cdn的方式引入,用户不传enginePresetJsUrl的时候,使用默认值,默认值是https://alifd.alicdn.com/npm/@alilc/lowcode-preset-plugin@0.1.2/dist/lowcode-preset-plugin.js,@alilc/lowcode-preset-plugin 这个包没有实现 customPlugins的功能
  2. @alifd/lowcode-preset-plugin 这个包实现了 customPlugins的功能,但是直接传入 https://alifd.alicdn.com/npm/@alifd/lowcode-preset-plugin@1.1.8/dist/editor-preset-plugin.js 会导致页面报如下错误 image
  3. 使用 window.AliLowCodeEngine.plugins.register(TestPlugin),因为执行时机问题,引擎已经初始化完成了,插件没初始化
eternalsky commented 10 months ago

customPlugins 我看了一下代码里还没有实现,只是留了一个口子,我们的插件文档上也没有这个属性对应的 API,你是从哪里看到这个配置上的呢~ https://www.npmjs.com/package/@alifd/build-plugin-lowcode

eternalsky commented 10 months ago

如果希望联调插件和组件的话,可以使用我们提供的注入调试的方式来进行调试会更加简单和便捷。