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

vite v5.0.0-beta.10版本使用问题 #2

Closed
xiaoxian521 opened this issue Oct 18, 2023 · 3 comments
Closed

vite v5.0.0-beta.10版本使用问题 #2

xiaoxian521 opened this issue Oct 18, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@xiaoxian521
Copy link

嘿,很nice的项目,不强绑定mockjs对于目前生态发展来说太重要了,mockjs已经过时了,使用中遇到如下问题,还希望作者有空看看

  1. 类型报错,如下图
image
  1. response里的body返回的是字符串,可以返回标准对象跟vite-plugin-mock返回格式保持一致吗
image
  1. 修改mock文件后,编辑器控制台报错信息如下:
image
@condorheroblog
Copy link
Owner

  1. 针对第一个问题,我猜测可能是由于 tsconfig.json 的配置问题所引起的。你可以尝试参考这个解决方案:Cannot find type declaration file in TypeScript
  2. 解析请求体为 JSON 是一个不错的优化,因为 JSON 更加常见,这样请求体的类型就可以定义为 body: Record<string, any> | string,我权衡下吧。
  3. 最好避免使用 CommonJS (CJS) 文件。在我的测试中,我经常遇到 bundle-require 加载 CJS 文件时出现的错误。因此,默认情况下,我没有对 CJS 文件提供支持。

谢谢你的反馈🙏

@condorheroblog condorheroblog added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 18, 2023
@condorheroblog condorheroblog self-assigned this Oct 20, 2023
@condorheroblog
Copy link
Owner

v0.0.3 is released.

@xiaoxian521
Copy link
Author

嘿,最新版已经满足整体需求,还有些小优化需求,作者如果有空的话,帮看看 ❤️

mock文件故意写错代码,编辑器控制台会报红色的错误信息,如下图

image

可以选择使用类似下面的报错,让用户不觉得那么显眼

image

当然更好的是,当用户把错误的代码修改正常,vite-plugin-fake-server提供个类似clearScreen配置项,配置后可以自动把之前输出的错误信息清除就完美啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants