fix(webpack): use modern target for esbuild

This commit is contained in:
pooya parsa 2020-10-30 12:55:17 +01:00
parent 8a1cb84518
commit ae32ca42fa

View File

@ -4,6 +4,11 @@ import { WebpackConfigContext } from '../utils/config'
export function esbuild (ctx: WebpackConfigContext) { export function esbuild (ctx: WebpackConfigContext) {
const { config } = ctx const { config } = ctx
// https://esbuild.github.io/getting-started/#bundling-for-the-browser
// https://gs.statcounter.com/browser-version-market-share
// https://nodejs.org/en/
const target = ctx.isServer ? 'node14' : 'chrome85'
config.optimization.minimizer.push(new ESBuildMinifyPlugin()) config.optimization.minimizer.push(new ESBuildMinifyPlugin())
config.plugins.push(new ESBuildPlugin()) config.plugins.push(new ESBuildPlugin())
@ -25,7 +30,7 @@ export function esbuild (ctx: WebpackConfigContext) {
}, },
options: { options: {
loader: 'ts', loader: 'ts',
target: 'es2015' target
} }
}, },
{ {
@ -33,7 +38,7 @@ export function esbuild (ctx: WebpackConfigContext) {
loader: 'esbuild-loader', loader: 'esbuild-loader',
options: { options: {
loader: 'tsx', loader: 'tsx',
target: 'es2015' target
} }
} }
) )