Skip to content

Commit

Permalink
build: add optional support for esbuild
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Jul 28, 2023
1 parent e121cfc commit 3c25580
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ function createPatcherAliases(packageName) {
}
}

const merge = mergeWithRules({
let webpackRendererConfig = mergeWithRules({
module: {
rules: {
test: 'match',
use: 'merge',
},
},
})

/** @type {import('webpack').Configuration} */
module.exports = merge(commonTalkWebpackConfig, {
})(commonTalkWebpackConfig, {
output: {
assetModuleFilename: '[name][ext]?v=[contenthash]',
},
Expand Down Expand Up @@ -143,3 +140,34 @@ module.exports = merge(commonTalkWebpackConfig, {
}),
],
})

if (require.resolve('esbuild-loader', { paths: [TALK_PATH] })) {
console.log('Using esbuild-loader')
// With Electron we can use the most modern features
// But with web client - we cannot
// Replace target to support Top-level await
webpackRendererConfig = mergeWithRules({
module: {
rules: {
test: 'match',
loader: 'replace',
options: 'replace',
},
},
})(webpackRendererConfig, {
module: {
rules: [
{
test: /\.js$/,
loader: 'esbuild-loader',
options: {
loader: 'js',
target: 'es2022',
},
},
],
},
})
}

module.exports = webpackRendererConfig

0 comments on commit 3c25580

Please sign in to comment.