zoukankan      html  css  js  c++  java
  • Vue2最低支持Node版本调查

    背景

    确定Vue2最低支持的Node版本,可以在CI环境中,确定Node的一些信息, 是否适合后端环境共享同一个Node版本呢。

    Vue2项目

    https://github.com/vuejs/vue/blob/dev/package.json

    调研了Vue 2.6.11版本的package.json

    其中Vue2使用Node是在编译事态使用,即是 webpack 使用。

    从这个文件中,我们发现 Vue2使用 webpack4.28.4

        "webpack": "~4.28.4",
    {
      "name": "vue",
      "version": "2.6.11",
      "description": "Reactive, component-oriented view layer for modern web interfaces.",
      "main": "dist/vue.runtime.common.js",
      "module": "dist/vue.runtime.esm.js",
      "unpkg": "dist/vue.js",
      "jsdelivr": "dist/vue.js",
      "typings": "types/index.d.ts",
      "files": [
        "src",
        "dist/*.js",
        "types/*.d.ts"
      ],
      "sideEffects": false,
      "scripts": {
        "dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev",
        "dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-cjs-dev",
        "dev:esm": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-esm",
        "dev:test": "karma start test/unit/karma.dev.config.js",
        "dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:web-server-renderer",
        "dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:web-compiler ",
        "dev:weex": "rollup -w -c scripts/config.js --environment TARGET:weex-framework",
        "dev:weex:factory": "rollup -w -c scripts/config.js --environment TARGET:weex-factory",
        "dev:weex:compiler": "rollup -w -c scripts/config.js --environment TARGET:weex-compiler ",
        "build": "node scripts/build.js",
        "build:ssr": "npm run build -- web-runtime-cjs,web-server-renderer",
        "build:weex": "npm run build -- weex",
        "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",
        "test:unit": "karma start test/unit/karma.unit.config.js",
        "test:cover": "karma start test/unit/karma.cover.config.js",
        "test:e2e": "npm run build -- web-full-prod,web-server-basic-renderer && node test/e2e/runner.js",
        "test:weex": "npm run build:weex && jasmine JASMINE_CONFIG_PATH=test/weex/jasmine.js",
        "test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.js",
        "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
        "test:types": "tsc -p ./types/test/tsconfig.json",
        "lint": "eslint src scripts test",
        "flow": "flow check",
        "sauce": "karma start test/unit/karma.sauce.config.js",
        "bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
        "release": "bash scripts/release.sh",
        "release:weex": "bash scripts/release-weex.sh",
        "release:note": "node scripts/gen-release-note.js",
        "commit": "git-cz"
      },
      "gitHooks": {
        "pre-commit": "lint-staged",
        "commit-msg": "node scripts/verify-commit-msg.js"
      },
      "lint-staged": {
        "*.js": [
          "eslint --fix",
          "git add"
        ]
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/vuejs/vue.git"
      },
      "keywords": [
        "vue"
      ],
      "author": "Evan You",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/vuejs/vue/issues"
      },
      "homepage": "https://github.com/vuejs/vue#readme",
      "devDependencies": {
        "@babel/core": "^7.0.0",
        "@babel/plugin-proposal-class-properties": "^7.1.0",
        "@babel/plugin-syntax-dynamic-import": "^7.0.0",
        "@babel/plugin-syntax-jsx": "^7.0.0",
        "@babel/plugin-transform-flow-strip-types": "^7.0.0",
        "@babel/preset-env": "^7.0.0",
        "@babel/register": "^7.0.0",
        "@types/node": "^12.12.0",
        "@types/webpack": "^4.4.22",
        "acorn": "^5.2.1",
        "babel-eslint": "^10.0.1",
        "babel-helper-vue-jsx-merge-props": "^2.0.3",
        "babel-loader": "^8.0.4",
        "babel-plugin-istanbul": "^5.1.0",
        "babel-plugin-transform-vue-jsx": "^4.0.1",
        "babel-preset-flow-vue": "^1.0.0",
        "buble": "^0.19.3",
        "chalk": "^2.3.0",
        "chromedriver": "^2.45.0",
        "codecov": "^3.0.0",
        "commitizen": "^2.9.6",
        "conventional-changelog": "^1.1.3",
        "cross-spawn": "^6.0.5",
        "cz-conventional-changelog": "^2.0.0",
        "de-indent": "^1.0.2",
        "es6-promise": "^4.1.0",
        "escodegen": "^1.8.1",
        "eslint": "^5.7.0",
        "eslint-plugin-flowtype": "^2.34.0",
        "eslint-plugin-jasmine": "^2.8.4",
        "file-loader": "^3.0.1",
        "flow-bin": "^0.61.0",
        "hash-sum": "^1.0.2",
        "he": "^1.1.1",
        "http-server": "^0.11.1",
        "jasmine": "^2.99.0",
        "jasmine-core": "^2.99.0",
        "karma": "^3.1.1",
        "karma-chrome-launcher": "^2.1.1",
        "karma-coverage": "^1.1.1",
        "karma-firefox-launcher": "^1.0.1",
        "karma-jasmine": "^1.1.0",
        "karma-mocha-reporter": "^2.2.3",
        "karma-phantomjs-launcher": "^1.0.4",
        "karma-safari-launcher": "^1.0.0",
        "karma-sauce-launcher": "^2.0.2",
        "karma-sourcemap-loader": "^0.3.7",
        "karma-webpack": "^4.0.0-rc.2",
        "lint-staged": "^8.0.0",
        "lodash": "^4.17.4",
        "lodash.template": "^4.4.0",
        "lodash.uniq": "^4.5.0",
        "lru-cache": "^5.1.1",
        "nightwatch": "^0.9.16",
        "nightwatch-helpers": "^1.2.0",
        "phantomjs-prebuilt": "^2.1.14",
        "puppeteer": "^1.11.0",
        "resolve": "^1.3.3",
        "rollup": "^1.0.0",
        "rollup-plugin-alias": "^1.3.1",
        "rollup-plugin-buble": "^0.19.6",
        "rollup-plugin-commonjs": "^9.2.0",
        "rollup-plugin-flow-no-whitespace": "^1.0.0",
        "rollup-plugin-node-resolve": "^4.0.0",
        "rollup-plugin-replace": "^2.0.0",
        "selenium-server": "^2.53.1",
        "serialize-javascript": "^2.1.2",
        "shelljs": "^0.8.1",
        "terser": "^3.10.2",
        "typescript": "^3.6.4",
        "webpack": "~4.28.4",
        "weex-js-runtime": "^0.23.6",
        "weex-styler": "^0.3.0",
        "yorkie": "^2.0.0"
      },
      "config": {
        "commitizen": {
          "path": "./node_modules/cz-conventional-changelog"
        }
      }
    }

    Webpack

    https://github.com/webpack/webpack/releases?after=v5.0.0-alpha.10

    从其发布的列表中,找到对应的4.28.4版本

    https://github.com/webpack/webpack/archive/v4.28.4.zip

    下载后查看其中的package.json文件

    从中查到,其基于node版本是6.11.5

      "engines": {
        "node": ">=6.11.5"
      },

    {
      "name": "webpack",
      "version": "4.28.4",
      "author": "Tobias Koppers @sokra",
      "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
      "license": "MIT",
      "dependencies": {
        "@webassemblyjs/ast": "1.7.11",
        "@webassemblyjs/helper-module-context": "1.7.11",
        "@webassemblyjs/wasm-edit": "1.7.11",
        "@webassemblyjs/wasm-parser": "1.7.11",
        "acorn": "^5.6.2",
        "acorn-dynamic-import": "^3.0.0",
        "ajv": "^6.1.0",
        "ajv-keywords": "^3.1.0",
        "chrome-trace-event": "^1.0.0",
        "enhanced-resolve": "^4.1.0",
        "eslint-scope": "^4.0.0",
        "json-parse-better-errors": "^1.0.2",
        "loader-runner": "^2.3.0",
        "loader-utils": "^1.1.0",
        "memory-fs": "~0.4.1",
        "micromatch": "^3.1.8",
        "mkdirp": "~0.5.0",
        "neo-async": "^2.5.0",
        "node-libs-browser": "^2.0.0",
        "schema-utils": "^0.4.4",
        "tapable": "^1.1.0",
        "terser-webpack-plugin": "^1.1.0",
        "watchpack": "^1.5.0",
        "webpack-sources": "^1.3.0"
      },
      "devDependencies": {
        "@types/node": "^9.6.4",
        "@types/tapable": "^1.0.1",
        "@types/webpack-sources": "^0.1.4",
        "benchmark": "^2.1.1",
        "bundle-loader": "~0.5.0",
        "codacy-coverage": "^2.0.1",
        "coffee-loader": "^0.9.0",
        "coffeescript": "^1.10.0",
        "coveralls": "^3.0.2",
        "css-loader": "^0.28.3",
        "es6-promise-polyfill": "^1.1.1",
        "eslint": "^5.8.0",
        "eslint-config-prettier": "^3.1.0",
        "eslint-plugin-jest": "^21.26.2",
        "eslint-plugin-node": "^8.0.0",
        "eslint-plugin-prettier": "^3.0.0",
        "express": "~4.13.1",
        "file-loader": "^1.1.6",
        "glob": "^7.1.3",
        "husky": "^1.1.3",
        "i18n-webpack-plugin": "^1.0.0",
        "istanbul": "^0.4.5",
        "jade": "^1.11.0",
        "jade-loader": "~0.8.0",
        "jest": "24.0.0-alpha.1",
        "jest-junit": "^5.2.0",
        "json-loader": "^0.5.7",
        "json-schema-to-typescript": "^6.0.1",
        "less": "^2.5.1",
        "less-loader": "^4.0.3",
        "lint-staged": "^8.0.4",
        "lodash": "^4.17.4",
        "prettier": "^1.14.3",
        "pug": "^2.0.3",
        "pug-loader": "^2.4.0",
        "raw-loader": "~0.5.0",
        "react": "^15.2.1",
        "react-dom": "^15.2.1",
        "rimraf": "^2.6.2",
        "script-loader": "~0.7.0",
        "simple-git": "^1.65.0",
        "style-loader": "^0.19.1",
        "typescript": "^3.0.0-rc",
        "url-loader": "^0.6.2",
        "val-loader": "^1.0.2",
        "vm-browserify": "~0.0.0",
        "wast-loader": "^1.5.5",
        "webpack-dev-middleware": "^1.9.0",
        "worker-loader": "^1.1.1",
        "xxhashjs": "^0.2.1"
      },
      "engines": {
        "node": ">=6.11.5"
      },
      "repository": {
        "type": "git",
        "url": "https://github.com/webpack/webpack.git"
      },
      "homepage": "https://github.com/webpack/webpack",
      "main": "lib/webpack.js",
      "web": "lib/webpack.web.js",
      "bin": "./bin/webpack.js",
      "files": [
        "lib/",
        "bin/",
        "buildin/",
        "declarations/",
        "hot/",
        "web_modules/",
        "schemas/",
        "SECURITY.md"
      ],
      "scripts": {
        "setup": "node ./setup/setup.js",
        "test": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest",
        "test:update-snapshots": "yarn jest -u",
        "test:integration": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.test.js"",
        "test:basic": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/{TestCasesNormal,StatsTestCases,ConfigTestCases}.test.js"",
        "test:unit": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.unittest.js"",
        "travis:integration": "yarn cover:init && yarn cover:integration --ci $JEST",
        "travis:basic": "yarn test:basic --ci $JEST",
        "travis:lint-unit": "yarn lint && yarn cover:init && yarn cover:unit --ci $JEST",
        "travis:benchmark": "yarn benchmark --ci",
        "appveyor:integration": "yarn cover:init && yarn cover:integration --ci %JEST%",
        "appveyor:unit": "yarn cover:init && yarn cover:unit --ci %JEST%",
        "appveyor:benchmark": "yarn benchmark --ci",
        "build:examples": "cd examples && node buildAll.js",
        "pretest": "yarn lint",
        "prelint": "yarn setup",
        "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
        "code-lint": "eslint --cache "{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js" "test/*.js" "test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js" "examples/**/webpack.config.js"",
        "type-lint": "tsc --pretty",
        "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
        "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
        "fix": "yarn code-lint --fix && yarn special-lint-fix",
        "pretty": "prettier --loglevel warn --write "*.{ts,js,json,yml,yaml}" "{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}" "test/*.js" "test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js" "examples/**/webpack.config.js"",
        "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.lint.js" --no-verbose",
        "benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.benchmark.js" --runInBand",
        "cover": "yarn cover:init && yarn cover:all && yarn cover:report",
        "cover:init": "rimraf coverage",
        "cover:all": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --coverage",
        "cover:integration": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.test.js" --coverage",
        "cover:unit": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch "<rootDir>/test/*.unittest.js" --coverage",
        "cover:report": "istanbul report"
      },
      "husky": {
        "hooks": {
          "pre-commit": "lint-staged"
        }
      },
      "lint-staged": {
        "*.js|{lib,setup,bin,hot,buildin,tooling,schemas}/**/*.js|test/*.js|{test,examples}/**/webpack.config.js}": [
          "eslint --cache"
        ]
      },
      "jest": {
        "forceExit": true,
        "setupFilesAfterEnv": [
          "<rootDir>/test/setupTestFramework.js"
        ],
        "testMatch": [
          "<rootDir>/test/*.test.js",
          "<rootDir>/test/*.unittest.js"
        ],
        "watchPathIgnorePatterns": [
          "<rootDir>/.git",
          "<rootDir>/node_modules",
          "<rootDir>/test/js",
          "<rootDir>/test/browsertest/js",
          "<rootDir>/test/fixtures/temp-cache-fixture",
          "<rootDir>/test/fixtures/temp-",
          "<rootDir>/benchmark",
          "<rootDir>/examples/*/dist",
          "<rootDir>/coverage",
          "<rootDir>/.eslintcache"
        ],
        "modulePathIgnorePatterns": [
          "<rootDir>/.git",
          "<rootDir>/node_modules/webpack/node_modules",
          "<rootDir>/test/js",
          "<rootDir>/test/browsertest/js",
          "<rootDir>/test/fixtures/temp-cache-fixture",
          "<rootDir>/test/fixtures/temp-",
          "<rootDir>/benchmark",
          "<rootDir>/examples/*/dist",
          "<rootDir>/coverage",
          "<rootDir>/.eslintcache"
        ],
        "transformIgnorePatterns": [
          "<rootDir>"
        ],
        "coverageDirectory": "<rootDir>/coverage",
        "coveragePathIgnorePatterns": [
          "\.runtime\.js$",
          "<rootDir>/test",
          "<rootDir>/schemas",
          "<rootDir>/node_modules"
        ],
        "testEnvironment": "node",
        "coverageReporters": [
          "json"
        ]
      }
    }

    结论

    Vue2编译基于的node版本必须大于 6.11.5

    Nodejs 版本5 对 ES6的支持度只有 57% complete46% complete

    但是在版本6.4.0 提升到 95% complete91% complete

    到版本 6.5.0 提升到 99% complete99%

    这也说明 webpack最低支持 6.11的原因。

    From: http://www.alloyteam.com/2016/07/nodejs-native-support-of-the-es6-features/

  • 相关阅读:
    Java 反射机制
    Hibernate学习
    js学习
    如何在jsp中引入bootstrap
    bootstrap学习一
    第二章、初级篇
    定风波
    Java反射机制
    数据库的优化方法
    MySQL常用的查询语句回顾
  • 原文地址:https://www.cnblogs.com/lightsong/p/12354324.html
Copyright © 2011-2022 走看看