文章目录
首页
Javascript
Html
Css
Node.js
Electron
移动开发
工具类
服务端
浏览器相关
前端收藏
其他

vue源码阅读1--目录结构及package.json

2019年01月29日 发布 阅读(329) 作者:懒炖

vue源码哪里找?

1、安装vue之后在node_modules目录找到vue目录
2、github: https://github.com/vuejs/vue

下面内容仅个人理解,有错误或问题欢迎指正

vue目录解读

这里只注释了src目录

  1. |-- dist // 打包后的文件
  2. |-- src // 源码目录
  3. | |-- compiler // 模板编译
  4. | | |-- codegen // 渲染生成
  5. | | |-- directives // 指令
  6. | | └── parser // 模板解析
  7. | |-- core // 核心代码
  8. | | |-- components // 组件
  9. | | |-- global-api // 全局api
  10. | | |-- instance // 实例
  11. | | | └── render-helpers // 渲染助手
  12. | | |-- observer // 观察者(双向数据绑定)
  13. | | |-- util // 核心工具
  14. | | └── vdom // 虚拟DOM
  15. | | |-- helpers // 虚拟DOM助手
  16. | | └── modules // 虚拟DOM模块
  17. | |-- platforms // 平台
  18. | | |-- web // WEB端(PC或手机浏览器)
  19. | | | |-- compiler // web编译
  20. | | | |-- runtime // web运行时
  21. | | | |-- server // web服务器目录
  22. | | | └── util // 工具
  23. | | └── weex // 阿里开发高性能原生应用的框架
  24. | | |-- compiler // APP编译
  25. | | |-- runtime // APP运行时
  26. | | └── util // 工具
  27. | |-- server // 服务器端渲染(SSR=Server Side Render)
  28. | | |-- bundle-renderer // 打包渲染
  29. | | |-- optimizing-compiler // 优化编译器
  30. | | |-- template-renderer // 模板渲染
  31. | | └── webpack-plugin // webpack插件
  32. | |-- sfc // 解析SFC
  33. | | └── parser.js // 解板.vue文件
  34. | └── shared // 全局共享目录
  35. | |-- constants.js // 常量
  36. | └── util.js // 基础工具
  37. └── types // 静态类型

package.json

研究一个项目,我比较喜欢看看package.json,通过package.json我们可以看到这个项目用到了哪些工具,执行了哪些操作

从vue项目的package.json我们可以看到什么呢?

  • 项目使用了eslint+lint-staged检测代码规范、使用了flow静态类型检查
  • 使用了http-server作为静态服务器
  • 使用了karma+jasmine作为单元测试
  • 使用lodash
  • 使用了puppeteer+phantomjs来模拟浏览器
  • 使用rollupwebpack

可能还有其他,没深探,如果你想成为前端“大牛”,上面的东西,你是否需要去了解熟悉呢?

  1. {
  2. "name": "vue",
  3. "version": "2.6.0-beta.2",
  4. "description": "Reactive, component-oriented view layer for modern web interfaces.",
  5. "main": "dist/vue.runtime.common.js",
  6. "module": "dist/vue.runtime.esm.js",
  7. "unpkg": "dist/vue.js",
  8. "jsdelivr": "dist/vue.js",
  9. "typings": "types/index.d.ts",
  10. "files": [
  11. "src",
  12. "dist/*.js",
  13. "types/*.d.ts"
  14. ],
  15. "sideEffects": false,
  16. "scripts": {
  17. "dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev",
  18. "dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-cjs-dev",
  19. "dev:esm": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-esm",
  20. "dev:test": "karma start test/unit/karma.dev.config.js",
  21. "dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:web-server-renderer",
  22. "dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:web-compiler ",
  23. "dev:weex": "rollup -w -c scripts/config.js --environment TARGET:weex-framework",
  24. "dev:weex:factory": "rollup -w -c scripts/config.js --environment TARGET:weex-factory",
  25. "dev:weex:compiler": "rollup -w -c scripts/config.js --environment TARGET:weex-compiler ",
  26. "build": "node scripts/build.js",
  27. "build:ssr": "npm run build -- web-runtime-cjs,web-server-renderer",
  28. "build:weex": "npm run build -- weex",
  29. "test": "npm run lint && flow check && npm run test:types && npm run test:cover && npm run test:e2e -- --env phantomjs && npm run test:ssr && npm run test:weex",
  30. "test:unit": "karma start test/unit/karma.unit.config.js",
  31. "test:cover": "karma start test/unit/karma.cover.config.js",
  32. "test:e2e": "npm run build -- web-full-prod,web-server-basic-renderer && node test/e2e/runner.js",
  33. "test:weex": "npm run build:weex && jasmine JASMINE_CONFIG_PATH=test/weex/jasmine.js",
  34. "test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.js",
  35. "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
  36. "test:types": "tsc -p ./types/test/tsconfig.json",
  37. "lint": "eslint src scripts test",
  38. "flow": "flow check",
  39. "sauce": "karma start test/unit/karma.sauce.config.js",
  40. "bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
  41. "release": "bash scripts/release.sh",
  42. "release:weex": "bash scripts/release-weex.sh",
  43. "release:note": "node scripts/gen-release-note.js",
  44. "commit": "git-cz"
  45. },
  46. "gitHooks": {
  47. "pre-commit": "lint-staged",
  48. "commit-msg": "node scripts/verify-commit-msg.js"
  49. },
  50. "lint-staged": {
  51. "*.js": [
  52. "eslint --fix",
  53. "git add"
  54. ]
  55. },
  56. "repository": {
  57. "type": "git",
  58. "url": "git+https://github.com/vuejs/vue.git"
  59. },
  60. "keywords": [
  61. "vue"
  62. ],
  63. "author": "Evan You",
  64. "license": "MIT",
  65. "bugs": {
  66. "url": "https://github.com/vuejs/vue/issues"
  67. },
  68. "homepage": "https://github.com/vuejs/vue#readme",
  69. "devDependencies": {
  70. "@babel/core": "^7.0.0",
  71. "@babel/plugin-proposal-class-properties": "^7.1.0",
  72. "@babel/plugin-syntax-dynamic-import": "^7.0.0",
  73. "@babel/plugin-syntax-jsx": "^7.0.0",
  74. "@babel/plugin-transform-flow-strip-types": "^7.0.0",
  75. "@babel/preset-env": "^7.0.0",
  76. "@babel/register": "^7.0.0",
  77. "@types/node": "^10.12.18",
  78. "@types/webpack": "^4.4.22",
  79. "acorn": "^5.2.1",
  80. "babel-eslint": "^10.0.1",
  81. "babel-helper-vue-jsx-merge-props": "^2.0.3",
  82. "babel-loader": "^8.0.4",
  83. "babel-plugin-istanbul": "^5.1.0",
  84. "babel-plugin-transform-vue-jsx": "^4.0.1",
  85. "babel-preset-flow-vue": "^1.0.0",
  86. "buble": "^0.19.3",
  87. "chalk": "^2.3.0",
  88. "chromedriver": "^2.45.0",
  89. "codecov": "^3.0.0",
  90. "commitizen": "^2.9.6",
  91. "conventional-changelog": "^1.1.3",
  92. "cross-spawn": "^6.0.5",
  93. "cz-conventional-changelog": "^2.0.0",
  94. "de-indent": "^1.0.2",
  95. "es6-promise": "^4.1.0",
  96. "escodegen": "^1.8.1",
  97. "eslint": "^5.7.0",
  98. "eslint-plugin-flowtype": "^2.34.0",
  99. "eslint-plugin-jasmine": "^2.8.4",
  100. "file-loader": "^3.0.1",
  101. "flow-bin": "^0.61.0",
  102. "hash-sum": "^1.0.2",
  103. "he": "^1.1.1",
  104. "http-server": "^0.11.1",
  105. "jasmine": "^2.99.0",
  106. "jasmine-core": "^2.99.0",
  107. "karma": "^3.1.1",
  108. "karma-chrome-launcher": "^2.1.1",
  109. "karma-coverage": "^1.1.1",
  110. "karma-firefox-launcher": "^1.0.1",
  111. "karma-jasmine": "^1.1.0",
  112. "karma-mocha-reporter": "^2.2.3",
  113. "karma-phantomjs-launcher": "^1.0.4",
  114. "karma-safari-launcher": "^1.0.0",
  115. "karma-sauce-launcher": "^2.0.2",
  116. "karma-sourcemap-loader": "^0.3.7",
  117. "karma-webpack": "^4.0.0-rc.2",
  118. "lint-staged": "^8.0.0",
  119. "lodash": "^4.17.4",
  120. "lodash.template": "^4.4.0",
  121. "lodash.uniq": "^4.5.0",
  122. "lru-cache": "^5.1.1",
  123. "nightwatch": "^0.9.16",
  124. "nightwatch-helpers": "^1.2.0",
  125. "phantomjs-prebuilt": "^2.1.14",
  126. "puppeteer": "^1.11.0",
  127. "resolve": "^1.3.3",
  128. "rollup": "^1.0.0",
  129. "rollup-plugin-alias": "^1.3.1",
  130. "rollup-plugin-buble": "^0.19.6",
  131. "rollup-plugin-commonjs": "^9.2.0",
  132. "rollup-plugin-flow-no-whitespace": "^1.0.0",
  133. "rollup-plugin-node-resolve": "^4.0.0",
  134. "rollup-plugin-replace": "^2.0.0",
  135. "selenium-server": "^2.53.1",
  136. "serialize-javascript": "^1.3.0",
  137. "shelljs": "^0.8.1",
  138. "terser": "^3.10.2",
  139. "typescript": "^3.1.3",
  140. "webpack": "^4.22.0",
  141. "weex-js-runtime": "^0.23.6",
  142. "weex-styler": "^0.3.0",
  143. "yorkie": "^2.0.0"
  144. },
  145. "config": {
  146. "commitizen": {
  147. "path": "./node_modules/cz-conventional-changelog"
  148. }
  149. }
  150. }

参考

https://www.kancloud.cn/zmwtp/vue2/148826

版权声明:本站文章除特别声明外,均采用署名-非商业性使用-禁止演绎 4.0 国际 许可协议,如需转载,请注明出处

评论

  •