解析器“ babylon”已弃用错误-Webpack构建

时间:2019-01-22 10:57:42

标签: webpack babel eslint babel-loader eslintrc

升级项目JS软件包后,使用Webpack构建捆绑包时出现错误。它似乎在构建.vue文件时出现,并且可以出现在任何.vue文件构建中。我的package.json中没有“ babylon”,并且我有一个更新的@ babel / core版本(7.2.2)。

这是错误:

{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }

它似乎仅在构建.vue文件时出现。

这是我的配置:

.babelrc

{
  "presets": ["@babel/preset-env"],
  "plugins": ["@babel/plugin-transform-regenerator"]
}

Webpack配置:

module: {
rules: [
  {
    enforce: 'pre',
    test: /\.(js|vue)$/,
    loader: 'eslint-loader',
    exclude: /node_modules/
  },
  {
    test: /\.vue$/,
    loader: 'vue-loader',
    options: {
      loaders: {
        scss: 'vue-style-loader!css-loader!sass-loader',
        sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
      }
    }
  },
  {
    test: /\.js$/,
    exclude: /node_modules/,
    use: [ 'babel-loader' ]
  },
  {
    test: /\.sass$/,
    exclude: /node_modules/,
    use: ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        {
          loader: 'css-loader',
          options: {
            sourceMap: true
          }
        },
        {
          loader: 'postcss-loader',
          options: {
            sourceMap: true
          }
        },
        {
          loader: 'sass-loader',
          options: {
            sourceMap: true
          }
        }
      ]
    })
  }
]

}

.eslintrc.js

  extends: [
'eslint:recommended',
'plugin:vue/recommended',
'plugin:import/errors',
'plugin:import/warnings'
],
 settings: {
'import/resolver': {
  'node': {
    'extensions': [
      '.js',
      '.vue'
    ]
  }
 }
 },
  parserOptions: {
  parser: 'babel-eslint',
  ecmaVersion: 2018
 }

package.json

"dependencies": {
    "@fortawesome/fontawesome-free": "^5.1.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.10",
    "@fortawesome/free-solid-svg-icons": "^5.6.1",
    "@fortawesome/vue-fontawesome": "^0.1.3",
    "autoprefixer": "^9.4.6",
    "axios": "^0.18.0",
    "babel-eslint": "^10.0.1",
    "babel-polyfill": "^6.23.0",
    "backbone": "^1.3.3",
    "bulma": "^0.7.1",
    "bulma-calendar": "^5.0.3",
    "clean-webpack-plugin": "^1.0.1",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^3.0.0",
    "flickity": "^2.0.9",
    "flickity-imagesloaded": "^2.0.0",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "glob-all": "^3.1.0",
    "in-view": "^0.6.1",
    "jquery": "^3.2.1",
    "js-cookie": "^2.2.0",
    "lazysizes": "^4.0.2",
    "magnific-popup": "^1.1.0",
    "node-pre-gyp": "^0.12.0",
    "node-sass": "^4.7.2",
    "optimize-css-assets-webpack-plugin": "^3.0.0",
    "postcss-loader": "^3.0.0",
    "purify-css": "^1.2.5",
    "purifycss-webpack": "^0.7.0",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.18.2",
    "underscore": "^1.8.3",
    "vue": "2.5.22",
    "vue-affix": "^0.2.4",
    "vue-lazyload": "^1.2.6",
    "vue-loader": "13.7.2",
    "vue-template-compiler": "2.5.22",
    "vuex": "^3.0.1",
    "webpack": "^3.4.1",
    "webpack-bundle-analyzer": "^2.8.3",
    "webpack-bundle-tracker": "^0.2.0",
    "webpack-dev-server": "^2.6.1",
    "webpack-merge": "^4.1.0"
},
"devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-transform-regenerator": "^7.0.0",
    "@babel/preset-env": "^7.3.1",
    "babel-loader": "^8.0.5",
    "eslint": "^4.14.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-vue": "4.7.1"
}

3 个答案:

答案 0 :(得分:5)

问题来自vue-loader 13.x.x和14.x.x

版本15.x.x似乎不错,但是我不能在不破坏所有内容的情况下将项目更新到15.x.x。 (我想您会遇到同样的问题)

我将在项目仓库中记录一个问题,很幸运他们会发布修复程序。

编辑:

目前,您可以使用我创建的14.2.2的派生版本来消除此消息。不知道它是否与您的版本兼容。

尝试替换:

"vue-loader": "13.7.2",

使用

"vue-loader": "https://github.com/graux/vue-loader#a0d6b77",

答案 1 :(得分:0)

vue-loader存储库中的PR:https://github.com/vuejs/vue-loader/pull/1480

答案 2 :(得分:-1)

或者仅在您的vue-loader": "^11.0.0中添加package.json即可完成