fix(docs): lazy-load demo source in development - #168
Merged
Conversation
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
English template / 英文模板
🤔 本次变更属于 ...
🔗 相关 Issue
暂无关联 Issue。
💡 背景与方案
文档开发服务加载 demo 时,
vite:demo插件会在 serve 模式调用仅构建阶段支持的emitFile()和getFileName(),导致 Vite 持续输出插件兼容警告。同时,开发模块会内联完整源码与高亮 HTML,长时间浏览大量 demo 时会增加客户端和开发服务器内存占用。本次调整统一开发与生产的
loadSource(signal?)异步接口:__demo_source端点在展开代码时实时解析并返回源码,插件仅合并进行中的重复请求,完成后不保留解析结果。demo-source-*.json,保持源码按需加载和现有包体积优化。emitFile()和getFileName()仅在 build 模式调用。DemoModule、DemoSourceData与DemoExtraFile类型约束。验证结果:
vp test:46 个测试文件、463 项测试全部通过。vp check。vp build packages/docs构建成功,demo-source-*.json正常生成。📝 变更日志