Reduce size of client js bundles (#15264)

* add packages

* Only include the needed parts of BootstrapVue

* remove yargs from client

* treeshake validator library

* formatting

* fix import
This commit is contained in:
Phillip Thelen
2024-08-06 19:53:44 +02:00
committed by GitHub
parent 6b02af69f2
commit 1be169a105
14 changed files with 884 additions and 25 deletions

View File

@@ -76,6 +76,9 @@ const webpackPlugins = [
if ((context.includes('sinon') || resource.includes('sinon') || context.includes('nise')) && nconf.get('TIME_TRAVEL_ENABLED') !== 'true') {
return true;
}
if (context.includes('yargs')) {
return true;
}
return false;
},
}),
@@ -91,6 +94,28 @@ module.exports = {
dependency: { not: ['url'] },
type: 'asset/source',
},
{
test: /\.js$/,
// Exclude transpiling `node_modules`, except `bootstrap-vue/src`
exclude: /node_modules\/(?!bootstrap-vue\/src\/)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.js$/,
// Exclude transpiling `node_modules`, except `bootstrap-vue/src`
exclude: /node_modules\/(?!validator)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
},
resolve: {
@@ -102,6 +127,10 @@ module.exports = {
stream: false,
timers: require.resolve('timers-browserify'),
},
alias: {
// Alias for using source of BootstrapVue
'bootstrap-vue$': 'bootstrap-vue/src/index.js',
},
},
plugins: webpackPlugins,
},