7

在我升级我的项目 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"]
}

网络包配置:

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
 }

包.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"
}
4

3 回答 3

9

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

版本 15.xx 似乎很好,但我无法在不破坏所有内容的情况下将我的项目更新到 15.xx。(我猜你会有同样的问题)

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

编辑:

目前,您可以使用我创建的 14.2.2 的分叉版本来消除该消息。不确定它是否与您的构建兼容。

尝试替换:

"vue-loader": "13.7.2",

"vue-loader": "https://github.com/graux/vue-loader#a0d6b77",
于 2019-01-24T17:33:02.520 回答
0

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

于 2019-01-25T12:47:00.690 回答
-1

或者只是添加vue-loader": "^11.0.0package.json的工作

于 2019-06-06T20:08:07.403 回答