Build: Replace babel-loader with esbuild-loader (#57837)

* build(webpack): replace babel-loader with esbuild-loader

* build(webpack): add esbuild minifier to production builds

* Wip

* Removed ngInject and replaced with manual inject params

* chore: bump esbuild to 0.15.13

* Fixed angular issues

* build(frontend): update esbuild to 0.16.16

* chore(webpack): support browserslist for esbuild

* build(esbuild): unify versions of esbuild to 0.16.17 and esbuild-loader to 2.21.0

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Jack Westbrook
2023-01-23 12:15:05 +01:00
committed by GitHub
parent 59ef144e9e
commit 3a7623753b
46 changed files with 335 additions and 558 deletions

View File

@ -1,5 +1,7 @@
'use strict';
const browserslist = require('browserslist');
const { resolveToEsbuildTarget } = require('esbuild-plugin-browserslist');
const ESLintPlugin = require('eslint-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
@ -10,7 +12,7 @@ const { merge } = require('webpack-merge');
const HTMLWebpackCSSChunks = require('./plugins/HTMLWebpackCSSChunks');
const common = require('./webpack.common.js');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const esbuildTargets = resolveToEsbuildTarget(browserslist(), { printUnknownTargets: false });
module.exports = (env = {}) =>
merge(common, {
@ -34,10 +36,10 @@ module.exports = (env = {}) =>
{
test: /\.tsx?$/,
use: {
loader: 'babel-loader',
loader: 'esbuild-loader',
options: {
cacheDirectory: true,
cacheCompression: false,
loader: 'tsx',
target: esbuildTargets,
},
},
exclude: /node_modules/,
@ -114,8 +116,5 @@ module.exports = (env = {}) =>
NODE_ENV: JSON.stringify('development'),
},
}),
// new BundleAnalyzerPlugin({
// analyzerPort: 8889
// })
],
});