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实现流程 #497

Open
Henry-Diasa opened this issue Aug 24, 2023 · 0 comments
Open

vite实现流程 #497

Henry-Diasa opened this issue Aug 24, 2023 · 0 comments

Comments

@Henry-Diasa
Copy link
Owner

1)通过koa开启一个服务,获取请求的静态文件内容
2)通过es-module-lexer 解析 ast 拿到 import 的内容
3)判断 import 导入模块是否为三方模块,是的话,返回node_module下的模块, 如 import vue 返回 import './@modules/vue'
4)如果是.vue文件,vite 拦截对应的请求,读取.vue 文件内容进行编译,通过compileTemplate 编译模板,将template转化为render函数
5)通过 babel parse 对 js 进行编译,最终返回编译后的 js 文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant