alibaba / alibaba/lowcode-engine

出码模块无法处理自定义的插槽

Open
#1,143 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

## **Describe the bug (required)** / **详细描述 bug(必填)**
自定义一个Solution,包含一些非ProjectBuilder 类定义的插槽,出码时自定义的插槽无法被调用

A clear and concise description of what the bug is. / 请提供清晰且精确的 bug 描述
有问题的代码 ProjectBuilder 类 generateProject 方法:
```typescript
// globalStyle
if (parseResult.project && builders.globalStyle) {
const { files } = await builders.globalStyle.generateModule(parseResult.project);

buildResult.push({
path: this.template.slots.globalStyle.path,
files,
});
}

// htmlEntry
if (parseResult.project && builders.htmlEntry) {
const { files } = await builders.htmlEntry.generateModule(parseResult.project);

buildResult.push({
path: this.template.slots.htmlEntry.path,
files,
});
}

// packageJSON
if (parseResult.project && builders.packageJSON) {
const { files } = await builders.packageJSON.generateModule(parseResult.project);

buildResult.push({
path: this.template.slots.packageJSON.path,
files,
});
}

// TODO: 更多 slots 的处理??是不是可以考虑把 template 中所有的 slots 都处理下?

// Post Process
```
这里的`TODO`其实已经发现了没有处理的 slots,是不是补一下全遍历?

另外针对于不同插件`generateModule`入参不尽相同这块感觉有些违背接口设计原则:

```
// entry
if (parseResult.project && builders.entry) {
const { files } = await builders.entry.generateModule(parseResult.project);

buildResult.push({
path: this.template.slots.entry.path,
files,
});
}

// appConfig
if (builders.appConfig) {
const { files } = await builders.appConfig.generateModule(parseResult);

buildResult.push({
path: this.template.slots.appConfig.path,
files,
});
}
```

---

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

自定义解决方案,自定义非系统默认的插槽,IProjectBuilder实现使用引擎提供的 ProjectBuilder (非自定义的实现)。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the ProjectBuilder class and its generateProject method, especially the template.slots and builders handling shown in the issue. Reproduce the case with a custom Solution containing a non-default slot, then inspect how generateModule inputs differ for entry and appConfig. Done means custom slots are handled during code generation and the relevant builder interface behavior is consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.