vue3源碼學習
vue3源碼。
TypeScript
。98% 以上使用 TypeScript 編寫
模塊:
- reactivity
- runtime-core
- runtime-dom
- runtime-test
- server-renderer
- compiler-core
- compiler-dom
- shared
調試搭建
- clone 代碼
git clone https://github.com/vuejs/vue-next.git
- 文件
tsconfig.json
。更改屬性sourceMap: true
。 - 文件
rollup.config.js
。函數createConfig
中的return
前添加一句話output.sourcemap = true
- 執行命令
npm run dev
。會生成packages/vue/dist/vue.global.js
文件。 - 新建
example
文件夾,添加index.html 文件。引入剛剛生成的文件。
- 用瀏覽器打開HTML文件。結果
7. 可以單獨打包packages下的某一個模塊
npm run dev reactivity
# 仿照第5步,新建html文件,script引入
<script src="../packages/reactivity/dist/reactivity.global.js"></script>