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

升级到4.x版本后,md中注释报错 #113

Closed
pisyell opened this issue Feb 3, 2023 · 5 comments
Closed

升级到4.x版本后,md中注释报错 #113

pisyell opened this issue Feb 3, 2023 · 5 comments

Comments

@pisyell
Copy link

pisyell commented Feb 3, 2023

使用的官网提供的demo,只修改了 src文件夹 和 package.json文件
demo
image

@pisyell
Copy link
Author

pisyell commented Feb 3, 2023

原先有大约50个组件,当我删除大量的组件,只保留了几个测试,就能正常访问页面了,但是感觉速度还是会有几百毫秒的延迟,所以,哪一个环节出了问题?

@csr632
Copy link
Member

csr632 commented Feb 5, 2023

截图看一下Chrome DevTool 的网络工具,看一下瓶颈在哪里
截屏2023-02-05 11 58 54

并且确认Console中是否有报错信息。

@pisyell
Copy link
Author

pisyell commented Feb 6, 2023

demo

  1. 当我删除了注释,程序就正常运行了

image

  1. 为什么不支持这种注释,之前3版本没任何问题

image

@pisyell pisyell changed the title 升级到4.x版本后,路由加载缓慢 升级到4.x版本后,md中注释报错 Feb 6, 2023
@csr632
Copy link
Member

csr632 commented Feb 7, 2023

有可能是v4版本升级到了mdx2.x导致的,我调查一下,谢谢反馈

@csr632
Copy link
Member

csr632 commented Feb 7, 2023

在mdx v2版本,它抛弃了对HTML注释语法的支持,文档推荐使用jsx的注释语法:

HTML syntax doesn’t work in MDX as it’s replaced by JSX. Instead of HTML comments, you can use JavaScript comments in braces: {/* comment! */}

关于mdx v2为什么要移除掉html注释语法的支持,作者在 mdx-js/mdx#1042 (comment) 解释了原因。作者希望mdx语法纯粹由md语法+JSX语法组成,引入HTML语法会增加心智负担。

虽然大部分markdown编辑器支持HTML语法,但是它其实不是markdown本身的语法。那些markdown编辑器支持它是因为过去markdown表达能力不足。mdx已经解决了表达能力不足的问题(通过JSX语法),因此没有必要再支持HTML语法。

mdx v2移除掉html注释语法确实带来了一些迁移成本,你可以通过正则搜索替换来快速修改:<!--(.*?)--> -> {/*$0*/}

已经在迁移文档中增加说明:9750ccd

@csr632 csr632 closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants