1. NPM packages require Babel translation

Configure in WebPack

{
        test: /\.(js|jsx)$/,
        include: [
          path.resolve(__dirname, '../node_modules/test'),
          path.resolve(__dirname, '../src'),
        ],
        use: {
          loader: 'babel-loader',
          options: {
            cacheDirectory: true,
            cacheCompression: true,
            compact: true,
          },
        },
      },
Copy the code

Note: the name of Babel must be babel.config.json, not.babelrc