处理 babel 配置和插件

问题描述

我正在构建 react SSR(使用 express)应用程序并决定用测试覆盖一些代码。我从简单的 js(ES6 和没有 jsx)开始,没什么大不了的。但是在运行 npm test 之后,我有时会看到这样的输出

@babel/preset-env: `DEBUG` option

Using targets:
{}

Using modules transform: auto

Using plugins:
  proposal-numeric-separator {}
  proposal-logical-assignment-operators {}
    <another plugins (dozens of them)>
  transform-modules-commonjs {}
  proposal-dynamic-import {}

Using polyfills with `usage` option:

[/<path>/file.js] Added following core-js polyfills:
  es.number.constructor {}
  es.number.is-integer {}
  es.number.to-fixed {}

无论是否通过测试。它只是出现并且让我很恼火。我该如何处理这些消息?

在我的webpack.config.js

const js = {
  test: /\.(js|jsx)$/,exclude: /node_modules/,use: {
    loader: 'babel-loader',options: {
      presets: ['@babel/preset-env','@babel/preset-react'],plugins: ['@babel/plugin-proposal-class-properties']
    }
  },resolve: {
    modules: ['src','node_modules'],extensions: ['.jsx','.js'],unsafeCache: true,alias: {}
  }
};

.babelrc

{
  "presets": [
    [
      "@babel/preset-env",{
        "debug": true,"useBuiltIns": "usage","corejs": 3
      }
    ],"@babel/preset-react"
  ],"plugins": ["@babel/plugin-proposal-class-properties","@babel/plugin-transform-runtime"]
}

解决方法

好的,我通过在 .babelrc 中注释 "debug": true 行来修复它。我不认为每次更改测试用例时都需要在控制台中放置文字墙

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...