babel 文檔css
babel的簡單扼要的介紹,推薦html
本次升級涉及到的內容vue
webpack 1.x | babel-loader <= 6.x webpack 2.x | babel-loader >= 7.x (recommended) (^6.2.10 will also work, but with deprecation warnings) webpack 3.x | babel-loader >= 7.1」
這裏抱着錯誤是由於 babel 的版本衝突。node
可能是由於你的 babel 依賴包不兼容。react
能夠查看你的 package.json 的依賴列表webpack
即有 babel 7.0 版本的( @babel/core , @babel/preset-react )git
也可命令查看 bebel-cli 的版本 ( babel -V )es6
也有 babel 6.0 版本的 ( babel-core@6.26.0 , babel-cli@6.26.0 , babel-preset-react@6.24.1 )github
若是在你的 package.json 依賴包中既有 babel 7.0 版本,又有 babel 6.0 版本,就會報這個錯誤web
兩個版本是不兼容的
將全部有關 babel 的包都升級爲 7.0 版本
"babel-core": "^6.22.1", "babel-eslint": "^7.1.1", "babel-loader": "^6.2.10", "babel-plugin-transform-runtime": "^6.22.0", "babel-polyfill": "6.26.0", "babel-preset-env": "^1.2.1", "babel-preset-stage-2": "^6.22.0", "babel-register": "^6.22.0",
"@babel/cli": "^7.5.5", "@babel/core": "^7.5.5", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-runtime": "^7.5.5", // 新增 "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.5", "@babel/register": "^7.5.5", "@babel/runtime": "^7.5.5", // 新增 "babel-core": "^7.0.0-bridge.0", // "babel-eslint": "^7.2.3", "babel-loader": "^8.0.0",
主要的區別是,babel7的升級,
{ "presets": [ ["env", { "modules": false }], // 刪除的代碼 "stage-2" // 刪除的代碼 ], "plugins": ["transform-runtime"], // 刪除的代碼 "comments": false, // 刪除的代碼 "env": { "test": { "presets": ["env", "stage-2"], // 修改的代碼 "plugins": [ "istanbul" ] } }
{ "presets": [ "@babel/preset-env", // 升級後的插件 ], "plugins": [ "@babel/plugin-transform-runtime", // 升級後的插件 "@babel/plugin-syntax-dynamic-import" // 升級後的插件 ], "env": { "test": { "presets": ["env"], // 修改的代碼 "plugins": [ "istanbul" ] } }
... test: /\.js$/, exclude: /node_modules(?!\/quill-image-drop-module|quill-image-resize-module)/, loader: 'babel-loader', include: [resolve('src'), resolve('test')] options: { // 新增內容 presets: ['@babel/preset-env'] }
npm add @babel/runtime
"babel-core": "7.0.0-bridge.0"
"devDependencies": { "@babel/cli": "^7.5.5", "@babel/core": "^7.5.5", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-runtime": "^7.5.5", "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.5", "@babel/register": "^7.5.5", "@babel/runtime": "^7.5.5", "ajv": "^6.10.2", "autoprefixer": "^6.7.2", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^7.2.3", "babel-loader": "^8.0.0", "bpmn-js-properties-panel": "^0.32.1", "chalk": "^1.1.3", "connect-history-api-fallback": "^1.3.0", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.26.1", "es6-promise-polyfill": "1.2.0", "eslint": "^3.14.1", "eslint-config-standard": "^6.2.1", "eslint-friendly-formatter": "^2.0.7", "eslint-loader": "^1.6.1", "eslint-plugin-html": "^2.0.0", "eslint-plugin-promise": "^3.4.0", "eslint-plugin-standard": "^2.0.1", "eventsource-polyfill": "^0.9.6", "express": "^4.14.1", "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^0.10.1", "friendly-errors-webpack-plugin": "^1.1.3", "function-bind": "^1.1.0", "html-webpack-plugin": "^2.28.0", "http-proxy-middleware": "^0.19.1", "less-loader": "4.1.0", "mini-css-extract-plugin": "^0.8.0", "opn": "^4.0.2", "optimize-css-assets-webpack-plugin": "^1.3.0", "ora": "^1.1.0", "preload-webpack-plugin": "^2.3.0", "rimraf": "^2.6.0", "script-loader": "^0.7.2", "semver": "^5.3.0", "stylus-loader": "^3.0.1", "url-loader": "^0.5.7", "vue-loader": "11.1.4", "vue-router": "2.8.0", "vue-style-loader": "^2.0.0", "vue-template-compiler": "2.5.16", "webpack": "^3.8.1", "webpack-bundle-analyzer": "^2.2.1", "webpack-dev-middleware": "^1.10.0", "webpack-hot-middleware": "^2.16.1", "webpack-merge": "^2.6.1" },