Skip to content

Commit

Permalink
ci: Update size-limit to ensure bundle size optimization (#13571)
Browse files Browse the repository at this point in the history
I wanted to add a new entry for size limit with sentry browser with max.
tree shaking. While doing this, I noticed that bundle size did not
shrink as much as I would have expected it. After playing around some, I
noticed that it was not actually shaking out the constant changes, for
whatever reason. Probably some size-limit internal default config.

Now, i actually add terser to ensure it fully minimizes & tree shakes
stuff for us.
  • Loading branch information
mydea authored Sep 4, 2024
1 parent 5c05bd8 commit ec7d9e3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 186 deletions.
37 changes: 37 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ module.exports = [
gzip: true,
limit: '24 KB',
},
{
name: '@sentry/browser - with treeshaking flags',
path: 'packages/browser/build/npm/esm/index.js',
import: createImport('init'),
gzip: true,
limit: '24 KB',
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

config.plugins.push(
new webpack.DefinePlugin({
__SENTRY_DEBUG__: false,
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
__RRWEB_EXCLUDE_IFRAME__: true,
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
}),
);

config.optimization.minimize = true;
config.optimization.minimizer = [new TerserPlugin()];

return config;
},
},
{
name: '@sentry/browser (incl. Tracing)',
path: 'packages/browser/build/npm/esm/index.js',
Expand All @@ -32,6 +57,8 @@ module.exports = [
limit: '68 KB',
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

config.plugins.push(
new webpack.DefinePlugin({
__SENTRY_DEBUG__: false,
Expand All @@ -40,6 +67,10 @@ module.exports = [
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
}),
);

config.optimization.minimize = true;
config.optimization.minimizer = [new TerserPlugin()];

return config;
},
},
Expand Down Expand Up @@ -222,11 +253,17 @@ module.exports = [
ignore: [...builtinModules, ...nodePrefixedBuiltinModules],
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

config.plugins.push(
new webpack.DefinePlugin({
__SENTRY_TRACING__: false,
}),
);

config.optimization.minimize = true;
config.optimization.minimizer = [new TerserPlugin()];

return config;
},
},
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"babel-loader": "^8.2.2",
"html-webpack-plugin": "^5.5.0",
"pako": "^2.1.0",
"webpack": "^5.90.3"
"webpack": "^5.94.0"
},
"devDependencies": {
"@types/glob": "8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/bundle-analyzer-scenarios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"private": true,
"dependencies": {
"html-webpack-plugin": "^5.6.0",
"webpack": "^5.92.1",
"webpack": "^5.94.0",
"webpack-bundle-analyzer": "^4.10.2"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"qunit": "~2.19.2",
"qunit-dom": "~2.0.0",
"sinon": "15.2.0",
"webpack": "~5.90.3"
"webpack": "~5.94.0"
},
"engines": {
"node": ">=14.18"
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
"peerDependencies": {
"next": "^13.2.0 || ^14.0 || ^15.0.0-rc.0",
"webpack": ">= 5.0.0"
"webpack": "5.94.0"
},
"peerDependenciesMeta": {
"webpack": {
Expand Down
Loading

0 comments on commit ec7d9e3

Please sign in to comment.