amis-editor在Vite下无法支持amis组件从amis-ui库中dynamic require
- Dominant language
- TypeScript
- Stars
- 18.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
#### 描述问题:
amis-editor在Vite下无法支持amis组件从amis-ui库中dynamic require
问题同 [此issues](https://github.com/baidu/amis/issues/5255)
#### 截图或视频:

#### 如何复现(请务必完整填写下面内容):
1. amis-editor版本5.1.9-beta.0
2. amis版本2.2.0
3. amis-core版本2.2.0
4. amis-ui版本2.2.0
5. 初始化Editor即可出现报错,注:是通过vite运行才会报错
```
import { Editor } from 'amis-editor'
...
```
6. 问题追溯
amis提供了cjs和esm两个版本,cjs版本中使用dynamic require从amis-ui懒加载组件,esm版本中使用dynamic import懒加载组件。
但amis-editor只有cjs版本。amis-editor通过cjs引用了amis,而导致amis也被使用了cjs版本,在Vite下就报错了。
7. 期望
amis对amis-ui组件懒加载改为同步加载或amis-editor提供esm版本
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with amis-editor 5.1.9-beta.0, amis 2.2.0, and Vite using the Editor initialization shown. Compare the CJS and ESM entry points and their dynamic require/import handling for amis-ui. Done means Editor initializes under Vite without this error, either through synchronous loading or an ESM amis-editor build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100