




Terminal command to install the analyzer:
npm i @next/bundle-analyzer
bundleAnalyzer.js:
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
openAnalyzer: true,
})
module.exports = withBundleAnalyzer;




webpack: (config, { isServer, webpack }) => {
if (!isServer) { // <-- We check that webpack prepares the client side bundle
config.resolve.alias = {
...config.resolve.alias,
//We replace the original 'graphql-request' package with empty file
'graphql-request': path.resolve(__dirname, 'src/fake/graphql-request.js'),
'graphql': path.resolve(__dirname, 'src/fake/graphql.js'), // <-- Same for graphql
'axios': path.resolve(__dirname, 'src/fake/axios.js'), // <-- Same for axios
};
}
return config;
}
| sitecore-jss | graphql | axios | graphql-request | bundle size | decrease in X times | |
|---|---|---|---|---|---|---|
| Stat size | 287.2 KB | 113.11 KB | 48.95 KB | 42.66 KB | 82.48 KB | 3.48 |
| Parsed size | 106.31 KB | 39.44 KB | 17.49 KB | 17.35 KB | 32.03 KB | 3.32 |
| Gzipped size | 28.13 KB | 10.05 KB | 6.32 KB | 4.84 KB | 6.92 KB | 4.07 |
| Before | After | |
|---|---|---|
![]() | ![]() | |
| Total Size | 130.5 KB | 108.9 KB |
| Chunk Size | 75.7 KB | 54.9 KB |
