记录一下步骤
- 下载源码
https://github.com/vuejs/vue/tree/dev
- 安装依赖
使用 npm 会报错,使用 yarn 不会
1 2
| npm i -g yarn yarn install
|
- 添加 sourcemap
package.json 中添加 –sourcemap
1 2 3 4 5
| { "scripts": { "dev": "rollup -w -c scripts/config.js --sourcemap --environment TARGET:web-full-dev" } }
|
- 启动开发环境
如果报类似错误,就 yarn add 装一下包
Cannot find module ‘@vue/consolidate/package.json’
目录结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| ├── benchmarks 性能、基准测试 ├── dist 构建打包的输出目录 ├── examples 案例目录 ├── flow flow 语法的类型声明 ├── packages 一些额外的包,比如:负责服务端渲染的包 vue-server-renderer、配合 vue-loader 使用的的 vue-template-compiler,还有 weex 相关的 │ ├── vue-server-renderer │ ├── vue-template-compiler │ ├── weex-template-compiler │ └── weex-vue-framework ├── scripts 所有的配置文件的存放位置,比如 rollup 的配置文件 ├── src vue 源码目录 │ ├── compiler 编译器 │ ├── core 运行时的核心包 │ │ ├── components 全局组件,比如 keep-alive │ │ ├── config.js 一些默认配置项 │ │ ├── global-api 全局 API,比如熟悉的:Vue.use()、Vue.component() 等 │ │ ├── instance Vue 实例相关的,比如 Vue 构造函数就在这个目录下 │ │ ├── observer 响应式原理 │ │ ├── util 工具方法 │ │ └── vdom 虚拟 DOM 相关,比如熟悉的 patch 算法就在这儿 │ ├── platforms 平台相关的编译器代码 │ │ ├── web │ │ └── weex │ ├── server 服务端渲染相关 ├── test 测试目录 ├── types TS 类型声明
|
参考
https://juejin.cn/user/1028798616461326/posts