package.json——从vue的package.json来详细说明package.json内容

2024-08-15 11:22:30 浏览数 (1)

前言

Vue2.7.14源码阅读的补充内容,~c package.json c~ 文件是项目的清单。 它可以做很多完全互不相关的事情。 例如,它是用于工具的配置中心。 它也是 npm 和 yarn 存储所有已安装软件包的名称和版本的地方;

内容

代码语言:javascript复制
{
  "name": "vue",                                                                         // 项目名称
  "version": "2.7.14",                                                                   // 项目版本号             
  "packageManager": "pnpm@7.1.0",                                                        // 包管理器
  "description": "Reactive, component-oriented view layer for modern web interfaces.",   // 项目描述
  "main": "dist/vue.runtime.common.js",                                                  // 应用程序入口文件
  "module": "dist/vue.runtime.esm.js",                                                   // 指定ES模块的入口文件
  "unpkg": "dist/vue.js",                                                                // CDN服务重定向
  "jsdelivr": "dist/vue.js",                                                             // CDN服务重定向
  "typings": "types/index.d.ts",                                                         // ts类型定义的入口文件
  "files": [                                                                             // 指定发布内容控制npm包大小
    "src",
    "dist/*.js",
    "dist/*.mjs",
    "types/*.d.ts",
    "compiler-sfc",
    "packages/compiler-sfc"
  ],
  "exports": {                                                                           // 配置不同环境下对应的模块入口文件                                                            
    ".": {
      "import": {
        "node": "./dist/vue.runtime.mjs",
        "default": "./dist/vue.runtime.esm.js"
      },
      "require": "./dist/vue.runtime.common.js",
      "types": "./types/index.d.ts"
    },
    "./compiler-sfc": {
      "import": "./compiler-sfc/index.mjs",
      "require": "./compiler-sfc/index.js"
    },
    "./dist/*": "./dist/*",
    "./types/*": "./types/*",
    "./package.json": "./package.json"
  },
  "sideEffects": false,                                                                 // 副作用配置 
  "scripts": {                                                                          // 脚本命令
    "dev": "rollup -w -c scripts/config.js --environment TARGET:full-dev",
    "dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:runtime-cjs-dev",
    "dev:esm": "rollup -w -c scripts/config.js --environment TARGET:runtime-esm",
    "dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:server-renderer",
    "dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:compiler ",
    "build": "node scripts/build.js",
    "build:ssr": "npm run build -- runtime-cjs,server-renderer",
    "build:types": "rimraf temp && tsc --declaration --emitDeclarationOnly --outDir temp && api-extractor run && api-extractor run -c packages/compiler-sfc/api-extractor.json",
    "test": "npm run ts-check && npm run test:types && npm run test:unit && npm run test:e2e && npm run test:ssr && npm run test:sfc",
    "test:unit": "vitest run test/unit",
    "test:ssr": "npm run build:ssr && vitest run server-renderer",
    "test:sfc": "vitest run compiler-sfc",
    "test:e2e": "npm run build -- full-prod,server-renderer-basic && vitest run test/e2e",
    "test:transition": "karma start test/transition/karma.conf.js",
    "test:types": "npm run build:types && tsc -p ./types/tsconfig.json",
    "format": "prettier --write --parser typescript "(src|test|packages|types)/**/*.ts"",
    "ts-check": "tsc -p tsconfig.json --noEmit",
    "ts-check:test": "tsc -p test/tsconfig.json --noEmit",
    "bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
    "release": "node scripts/release.js",
    "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
  },
  "gitHooks": {                                                                        //git hooks
    "pre-commit": "lint-staged",
    "commit-msg": "node scripts/verify-commit-msg.js"
  },
  "lint-staged": {                                                                    // 对提交到暂存区进行操作
    "*.js": [
      "prettier --write"
    ],
    "*.ts": [
      "prettier --parser=typescript --write"
    ]
  },
  "repository": {                                                                   // 项目仓库地址
    "type": "git",
    "url": "git https://github.com/vuejs/vue.git"
  },
  "keywords": [                                                                    // 项目关键字
    "vue"
  ],
  "author": "Evan You",                                                           // 作者信息
  "license": "MIT",                                                               // 开源协议
  "bugs": {                                                                       // bug反馈地址
    "url": "https://github.com/vuejs/vue/issues"
  },
  "homepage": "https://github.com/vuejs/vue#readme",                             // 项目主页
  "dependencies": {                                                              // 运行依赖
    "@vue/compiler-sfc": "workspace:*",
    "csstype": "^3.1.0"
  },
  "devDependencies": {                                                          // 开发依赖
    "@babel/parser": "^7.18.4",
    "@microsoft/api-extractor": "^7.25.0",
    "@rollup/plugin-alias": "^3.1.9",
    "@rollup/plugin-commonjs": "^22.0.0",
    "@rollup/plugin-node-resolve": "^13.3.0",
    "@rollup/plugin-replace": "^4.0.0",
    "@types/he": "^1.1.2",
    "@types/node": "^17.0.41",
    "chalk": "^4.1.2",
    "conventional-changelog-cli": "^2.2.2",
    "cross-spawn": "^7.0.3",
    "enquirer": "^2.3.6",
    "esbuild": "^0.14.43",
    "execa": "^4.1.0",
    "he": "^1.2.0",
    "jasmine-core": "^4.2.0",
    "jsdom": "^19.0.0",
    "karma": "^6.3.20",
    "karma-chrome-launcher": "^3.1.1",
    "karma-cli": "^2.0.0",
    "karma-esbuild": "^2.2.4",
    "karma-jasmine": "^5.0.1",
    "lint-staged": "^12.5.0",
    "lodash": "^4.17.21",
    "marked": "^4.0.16",
    "minimist": "^1.2.6",
    "postcss": "^8.4.14",
    "prettier": "^2.6.2",
    "puppeteer": "^14.3.0",
    "rimraf": "^3.0.2",
    "rollup": "^2.79.1",
    "rollup-plugin-typescript2": "^0.32.0",
    "semver": "^7.3.7",
    "shelljs": "^0.8.5",
    "terser": "^5.14.0",
    "todomvc-app-css": "^2.4.2",
    "ts-node": "^10.8.1",
    "tslib": "^2.4.0",
    "typescript": "^4.8.4",
    "vitest": "^0.12.10",
    "yorkie": "^2.0.0"
  }
}

0 人点赞