Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX:lowcode 编译适配多包模式报错问题 #3085

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions modules/material-parser/src/parse/ts/generateDTS.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import * as path from 'path';
import { writeFileSync, pathExistsSync, ensureDirSync, copySync } from 'fs-extra';
import { writeFileSync, pathExistsSync } from 'fs-extra';
import { loadFile } from '../../utils';

import { debug } from '../../core';

const log = debug.extend('parse:ts:generate_dts');

function getTypeDir(workDir: string, dsl: string) {
const typePkgName = `@types/${dsl}`;
let typeDir = path.join(workDir, 'node_modules', typePkgName);

/** 适配 workspace 的情况,如果当前目录没有对应文件,从 workspace 依赖中寻找 */
if (!pathExistsSync(typeDir)) {
typeDir = path.join(workDir, '../../node_modules', typePkgName);
}
return typeDir;
}

/**
* Generate alias dts file by removing some needless interfaces.
* Replace original file at present, which will cause type pollution, looking for better solution
Expand All @@ -22,7 +33,7 @@ export default function generateDTS({
originalTypePath: string;
newTypePath: string;
} {
const typeDir = path.join(workDir, 'node_modules', `@types/${dslType}`);
const typeDir = getTypeDir(workDir, dslType);
const typePath = path.join(typeDir, 'index.d.ts');
const fileContent = loadFile(typePath);
// const materialParserTypeDir = path.join(workDir, `node_modules/material-parser-types/${type}`);
Expand Down
5 changes: 3 additions & 2 deletions packages/react-simulator-renderer/src/renderer-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ class Renderer extends Component<{
if (
!viewProps.dataSource &&
leaf?.isContainer() &&
(children == null || (Array.isArray(children) && !children.length)) &&
(
= null || (Array.isArray(children) && !children.length)) &&
(!viewProps.style || Object.keys(viewProps.style).length === 0)
) {
let defaultPlaceholder = intl('Drag and drop components or templates here');
Expand All @@ -219,7 +220,7 @@ class Renderer extends Component<{
defaultPlaceholder = intl('Locked elements and child elements cannot be edited');
}
children = (
<div className={cn('lc-container-placeholder', { 'lc-container-locked': !!lockedNode })} style={viewProps.placeholderStyle}>
<div key={`${__id}_placeholder`} className={cn('lc-container-placeholder', { 'lc-container-locked': !!lockedNode })} style={viewProps.placeholderStyle}>
{viewProps.placeholder || defaultPlaceholder}
</div>
);
Expand Down