Webpack error: configuration.module.rules[0] has an unknown property 'query'

Webpack error: configuration.module.rules[0] has an unknown property 'query'

我正在学习本教程:https://www.youtube.com/watch?v=iWUR04B42Hc,我知道它的内容已经过时,但我认为已经将它正确地翻译成新版本的 Webpack,但是它出现此错误:configuration.module.rules[0] has an unknown property 'query'.

完全错误:

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.module.rules[0] has an unknown property 'query'. These properties are valid:
   object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
   -> A rule description with conditions and effects for modules.

我的webpack.config.js

const path = require('path');

module.exports = {
    entry: {
        app: './source/app.js'
    },
    output: {
        path: path.resolve(__dirname, 'build'),
        filename: 'app.bundle.js'
    },
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.js?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['@babel/preset-env']
                }
            }
        ]
    }
}

你知道我的代码有什么问题吗?

错误信息很清楚,rule配置中没有query选项,你应该使用options.presets。请参阅 usage Webpack v5

module: {
  rules: [
    {
      test: /\.m?js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env']
        }
      }
    }
  ]
}