Skip to content

Commit 5e3506e

Browse files
authored
Merge pull request #18906 from mozilla/optimize-sentry-bundle
task(settings): Optimize sentry bundle and add webpack analyzer
2 parents 7e02dd7 + 31602d7 commit 5e3506e

3 files changed

Lines changed: 185 additions & 1 deletion

File tree

packages/fxa-settings/config/webpack.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const ForkTsCheckerWebpackPlugin =
2626
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
2727
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
2828
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
29+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
30+
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin/webpack5');
2931

3032
const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
3133

@@ -781,6 +783,27 @@ module.exports = function (webpackEnv) {
781783
},
782784
},
783785
}),
786+
sentryWebpackPlugin({
787+
// These settings should allow better source map resolution for errors / debugging.
788+
// The auth token is used during packing to upload sources to the sentry for later use.
789+
org: 'mozilla',
790+
project: 'fxa-content',
791+
authToken: process.env.SENTRY_SOURCE_MAP_AUTH_TOKEN,
792+
bundleSizeOptimizations: {
793+
excludeDebugStatements: true,
794+
excludeTracing: false, // Used for perf metrics!
795+
excludeReplayCanvas: true,
796+
excludeReplayShadowDom: true,
797+
excludeReplayIframe: true,
798+
excludeReplayWorker: true,
799+
},
800+
}),
801+
new BundleAnalyzerPlugin({
802+
analyzerMode: 'static',
803+
generateStatsFile: true,
804+
reportFilename: 'bundle-report.html',
805+
openAnalyzer: false,
806+
}),
784807
].filter(Boolean),
785808
// Turn off performance processing because we utilize
786809
// our own hints via the FileSizeReporter

packages/fxa-settings/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
},
196196
"devDependencies": {
197197
"@babel/types": "7.25.8",
198+
"@sentry/webpack-plugin": "^3.5.0",
198199
"@storybook/addon-actions": "8.0.0",
199200
"@storybook/addon-essentials": "7.6.15",
200201
"@storybook/addon-interactions": "7.6.16",
@@ -222,6 +223,7 @@
222223
"@types/ua-parser-js": "^0.7.36",
223224
"@types/uuid": "^10",
224225
"@types/webpack": "5.28.5",
226+
"@types/webpack-bundle-analyzer": "^4",
225227
"babel-loader": "^9.1.3",
226228
"babel-plugin-named-exports-order": "^0.0.2",
227229
"babel-plugin-transform-typescript-metadata": "^0.3.2",
@@ -251,7 +253,8 @@
251253
"ts-jest": "^29.2.3",
252254
"type-fest": "^4.38.0",
253255
"typescript": "5.5.3",
254-
"webpack": "^5.97.0"
256+
"webpack": "^5.97.0",
257+
"webpack-bundle-analyzer": "^4.10.2"
255258
},
256259
"nx": {
257260
"implicitDependencies": [

yarn.lock

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11941,6 +11941,13 @@ __metadata:
1194111941
languageName: node
1194211942
linkType: hard
1194311943

11944+
"@sentry/babel-plugin-component-annotate@npm:3.5.0":
11945+
version: 3.5.0
11946+
resolution: "@sentry/babel-plugin-component-annotate@npm:3.5.0"
11947+
checksum: c5dd3c572e4ca83db859bf3d8ba976393361631f30eb977bc00a572d9981ccaae84f42cce5bf85bc425544245ad22923a66fe96bc2355d339e12ea3aa72d3b82
11948+
languageName: node
11949+
linkType: hard
11950+
1194411951
"@sentry/browser@npm:8.42.0":
1194511952
version: 8.42.0
1194611953
resolution: "@sentry/browser@npm:8.42.0"
@@ -11970,34 +11977,85 @@ __metadata:
1197011977
languageName: node
1197111978
linkType: hard
1197211979

11980+
"@sentry/bundler-plugin-core@npm:3.5.0":
11981+
version: 3.5.0
11982+
resolution: "@sentry/bundler-plugin-core@npm:3.5.0"
11983+
dependencies:
11984+
"@babel/core": ^7.18.5
11985+
"@sentry/babel-plugin-component-annotate": 3.5.0
11986+
"@sentry/cli": 2.42.2
11987+
dotenv: ^16.3.1
11988+
find-up: ^5.0.0
11989+
glob: ^9.3.2
11990+
magic-string: 0.30.8
11991+
unplugin: 1.0.1
11992+
checksum: a1fb59a1e062f5f1e0bd7b93d2f15cb7143c8ae476640e367a33e71e1312e23d3d8807b274fc3b3b55938af3787b4dd623fd78dc040959170055022e44c6ba88
11993+
languageName: node
11994+
linkType: hard
11995+
11996+
"@sentry/cli-darwin@npm:2.42.2":
11997+
version: 2.42.2
11998+
resolution: "@sentry/cli-darwin@npm:2.42.2"
11999+
conditions: os=darwin
12000+
languageName: node
12001+
linkType: hard
12002+
1197312003
"@sentry/cli-darwin@npm:2.44.0":
1197412004
version: 2.44.0
1197512005
resolution: "@sentry/cli-darwin@npm:2.44.0"
1197612006
conditions: os=darwin
1197712007
languageName: node
1197812008
linkType: hard
1197912009

12010+
"@sentry/cli-linux-arm64@npm:2.42.2":
12011+
version: 2.42.2
12012+
resolution: "@sentry/cli-linux-arm64@npm:2.42.2"
12013+
conditions: (os=linux | os=freebsd) & cpu=arm64
12014+
languageName: node
12015+
linkType: hard
12016+
1198012017
"@sentry/cli-linux-arm64@npm:2.44.0":
1198112018
version: 2.44.0
1198212019
resolution: "@sentry/cli-linux-arm64@npm:2.44.0"
1198312020
conditions: (os=linux | os=freebsd) & cpu=arm64
1198412021
languageName: node
1198512022
linkType: hard
1198612023

12024+
"@sentry/cli-linux-arm@npm:2.42.2":
12025+
version: 2.42.2
12026+
resolution: "@sentry/cli-linux-arm@npm:2.42.2"
12027+
conditions: (os=linux | os=freebsd) & cpu=arm
12028+
languageName: node
12029+
linkType: hard
12030+
1198712031
"@sentry/cli-linux-arm@npm:2.44.0":
1198812032
version: 2.44.0
1198912033
resolution: "@sentry/cli-linux-arm@npm:2.44.0"
1199012034
conditions: (os=linux | os=freebsd) & cpu=arm
1199112035
languageName: node
1199212036
linkType: hard
1199312037

12038+
"@sentry/cli-linux-i686@npm:2.42.2":
12039+
version: 2.42.2
12040+
resolution: "@sentry/cli-linux-i686@npm:2.42.2"
12041+
conditions: (os=linux | os=freebsd) & (cpu=x86 | cpu=ia32)
12042+
languageName: node
12043+
linkType: hard
12044+
1199412045
"@sentry/cli-linux-i686@npm:2.44.0":
1199512046
version: 2.44.0
1199612047
resolution: "@sentry/cli-linux-i686@npm:2.44.0"
1199712048
conditions: (os=linux | os=freebsd) & (cpu=x86 | cpu=ia32)
1199812049
languageName: node
1199912050
linkType: hard
1200012051

12052+
"@sentry/cli-linux-x64@npm:2.42.2":
12053+
version: 2.42.2
12054+
resolution: "@sentry/cli-linux-x64@npm:2.42.2"
12055+
conditions: (os=linux | os=freebsd) & cpu=x64
12056+
languageName: node
12057+
linkType: hard
12058+
1200112059
"@sentry/cli-linux-x64@npm:2.44.0":
1200212060
version: 2.44.0
1200312061
resolution: "@sentry/cli-linux-x64@npm:2.44.0"
@@ -12012,20 +12070,71 @@ __metadata:
1201212070
languageName: node
1201312071
linkType: hard
1201412072

12073+
"@sentry/cli-win32-i686@npm:2.42.2":
12074+
version: 2.42.2
12075+
resolution: "@sentry/cli-win32-i686@npm:2.42.2"
12076+
conditions: os=win32 & (cpu=x86 | cpu=ia32)
12077+
languageName: node
12078+
linkType: hard
12079+
1201512080
"@sentry/cli-win32-i686@npm:2.44.0":
1201612081
version: 2.44.0
1201712082
resolution: "@sentry/cli-win32-i686@npm:2.44.0"
1201812083
conditions: os=win32 & (cpu=x86 | cpu=ia32)
1201912084
languageName: node
1202012085
linkType: hard
1202112086

12087+
"@sentry/cli-win32-x64@npm:2.42.2":
12088+
version: 2.42.2
12089+
resolution: "@sentry/cli-win32-x64@npm:2.42.2"
12090+
conditions: os=win32 & cpu=x64
12091+
languageName: node
12092+
linkType: hard
12093+
1202212094
"@sentry/cli-win32-x64@npm:2.44.0":
1202312095
version: 2.44.0
1202412096
resolution: "@sentry/cli-win32-x64@npm:2.44.0"
1202512097
conditions: os=win32 & cpu=x64
1202612098
languageName: node
1202712099
linkType: hard
1202812100

12101+
"@sentry/cli@npm:2.42.2":
12102+
version: 2.42.2
12103+
resolution: "@sentry/cli@npm:2.42.2"
12104+
dependencies:
12105+
"@sentry/cli-darwin": 2.42.2
12106+
"@sentry/cli-linux-arm": 2.42.2
12107+
"@sentry/cli-linux-arm64": 2.42.2
12108+
"@sentry/cli-linux-i686": 2.42.2
12109+
"@sentry/cli-linux-x64": 2.42.2
12110+
"@sentry/cli-win32-i686": 2.42.2
12111+
"@sentry/cli-win32-x64": 2.42.2
12112+
https-proxy-agent: ^5.0.0
12113+
node-fetch: ^2.6.7
12114+
progress: ^2.0.3
12115+
proxy-from-env: ^1.1.0
12116+
which: ^2.0.2
12117+
dependenciesMeta:
12118+
"@sentry/cli-darwin":
12119+
optional: true
12120+
"@sentry/cli-linux-arm":
12121+
optional: true
12122+
"@sentry/cli-linux-arm64":
12123+
optional: true
12124+
"@sentry/cli-linux-i686":
12125+
optional: true
12126+
"@sentry/cli-linux-x64":
12127+
optional: true
12128+
"@sentry/cli-win32-i686":
12129+
optional: true
12130+
"@sentry/cli-win32-x64":
12131+
optional: true
12132+
bin:
12133+
sentry-cli: bin/sentry-cli
12134+
checksum: a22e4ff4a8c1891cc89028871f64f05eb4376033dba2f1ffdf0b946e4e6493a99807d640ea9580623e1c75ba181c295c93a51d00148ad45bb9343e68c2e42f90
12135+
languageName: node
12136+
linkType: hard
12137+
1202912138
"@sentry/cli@npm:^2.36.1":
1203012139
version: 2.44.0
1203112140
resolution: "@sentry/cli@npm:2.44.0"
@@ -12205,6 +12314,19 @@ __metadata:
1220512314
languageName: node
1220612315
linkType: hard
1220712316

12317+
"@sentry/webpack-plugin@npm:^3.5.0":
12318+
version: 3.5.0
12319+
resolution: "@sentry/webpack-plugin@npm:3.5.0"
12320+
dependencies:
12321+
"@sentry/bundler-plugin-core": 3.5.0
12322+
unplugin: 1.0.1
12323+
uuid: ^9.0.0
12324+
peerDependencies:
12325+
webpack: ">=4.40.0"
12326+
checksum: 8dcdd33405d09369a4a6988ee45d04cdda800669ade090c52bb84150b1ecd8b9639bb7724b99c783969cebc36fe46c8e75c34693bad42c6fab13ce07a30395b3
12327+
languageName: node
12328+
linkType: hard
12329+
1220812330
"@sideway/address@npm:^4.1.5":
1220912331
version: 4.1.5
1221012332
resolution: "@sideway/address@npm:4.1.5"
@@ -19617,6 +19739,17 @@ __metadata:
1961719739
languageName: node
1961819740
linkType: hard
1961919741

19742+
"@types/webpack-bundle-analyzer@npm:^4":
19743+
version: 4.7.0
19744+
resolution: "@types/webpack-bundle-analyzer@npm:4.7.0"
19745+
dependencies:
19746+
"@types/node": "*"
19747+
tapable: ^2.2.0
19748+
webpack: ^5
19749+
checksum: d50ef42ae98c4ca0ca1afa2433f27996292e4052f038e9f3cb38c3fd6931c365b5b21ac46b7f8af2ecd48ab17447c96033774b3985b82ed3818fe647ec9191bd
19750+
languageName: node
19751+
linkType: hard
19752+
1962019753
"@types/webpack-sources@npm:*":
1962119754
version: 3.2.3
1962219755
resolution: "@types/webpack-sources@npm:3.2.3"
@@ -32745,6 +32878,7 @@ __metadata:
3274532878
"@pmmmwh/react-refresh-webpack-plugin": ^0.5.3
3274632879
"@reach/router": ^1.3.4
3274732880
"@react-pdf/renderer": 3.2.1
32881+
"@sentry/webpack-plugin": ^3.5.0
3274832882
"@storybook/addon-actions": 8.0.0
3274932883
"@storybook/addon-essentials": 7.6.15
3275032884
"@storybook/addon-interactions": 7.6.16
@@ -32775,6 +32909,7 @@ __metadata:
3277532909
"@types/ua-parser-js": ^0.7.36
3277632910
"@types/uuid": ^10
3277732911
"@types/webpack": 5.28.5
32912+
"@types/webpack-bundle-analyzer": ^4
3277832913
babel-jest: ^29.7.0
3277932914
babel-loader: ^9.1.3
3278032915
babel-plugin-named-exports-order: ^0.0.2
@@ -32857,6 +32992,7 @@ __metadata:
3285732992
ua-parser-js: 1.0.35
3285832993
uuid: ^10.0.0
3285932994
webpack: ^5.97.0
32995+
webpack-bundle-analyzer: ^4.10.2
3286032996
webpack-dev-server: ^4.6.0
3286132997
webpack-manifest-plugin: ^5.0.0
3286232998
workbox-webpack-plugin: ^7.1.0
@@ -55889,6 +56025,28 @@ __metadata:
5588956025
languageName: node
5589056026
linkType: hard
5589156027

56028+
"webpack-bundle-analyzer@npm:^4.10.2":
56029+
version: 4.10.2
56030+
resolution: "webpack-bundle-analyzer@npm:4.10.2"
56031+
dependencies:
56032+
"@discoveryjs/json-ext": 0.5.7
56033+
acorn: ^8.0.4
56034+
acorn-walk: ^8.0.0
56035+
commander: ^7.2.0
56036+
debounce: ^1.2.1
56037+
escape-string-regexp: ^4.0.0
56038+
gzip-size: ^6.0.0
56039+
html-escaper: ^2.0.2
56040+
opener: ^1.5.2
56041+
picocolors: ^1.0.0
56042+
sirv: ^2.0.3
56043+
ws: ^7.3.1
56044+
bin:
56045+
webpack-bundle-analyzer: lib/bin/analyzer.js
56046+
checksum: 4f0275e7d87bb6203a618ca5d2d4953943979d986fa2b91be1bf1ad0bcd22bec13398803273d11699f9fbcf106896311208a72d63fe5f8a47b687a226e598dc1
56047+
languageName: node
56048+
linkType: hard
56049+
5589256050
"webpack-cli@npm:^6.0.1":
5589356051
version: 6.0.1
5589456052
resolution: "webpack-cli@npm:6.0.1"

0 commit comments

Comments
 (0)