sentry icon indicating copy to clipboard operation
sentry copied to clipboard

build: replace webpack with rspack

Open scttcper opened this issue 1 year ago • 3 comments

Building off the work done in #61475 I think the plan would be to use this as a dev-ui replacement until we're more confident and can setup the getsentry repo as well (if you aren't familiar we have another repo with billing pages etc).

2024 rspack 1.0 update

Things i spent maybe 10 minutes debugging:

  • [x] ContextReplacementPlugin errors in both dev-ui and build
  • [x] Still need to add back forked typescript for dev mode (we don't run it on build, tsc is its own step)
  • [ ] The emotion plugin seems a little funky in 'dev-only' mode and i put it on always to get it working

Summary

This pull-request removes babel and Webpack in favor of Rspack and SWC. This change comes with a significant performance boost and improves our productivity. Currently, it takes 14 seconds to build Sentry. Prior to this PR, it took 58 seconds.

Before

We are using Babel and Webpack for building our frontend application. It took almost 58 seconds on my M2 machine to run yarn build-production command.

webpack 5.87.0 compiled with 1 warning in 56351 ms
✨  Done in 57.91s.

After

We removed 14 dependencies and added 3 new dependencies. Depending on Babel and Jest, we can remove more. Currently it takes 14 seconds to build, minify both JS and CSS files.

Rspack compiled successfully in 12.90 s
✨  Done in 14.00s.

TODOs:

  • [ ] In order to not break the Vercel previews we need the following change of Rspack.
    • https://github.com/web-infra-dev/rspack/issues/4977
  • [ ] Rspack doesn't support lazy compilation, but it is in their roadmap.
  • [ ] Research why we need build-js-loader.ts script since it brings an unnecessary dependency: terser
  • [ ] Research the relation of Babel and Jest and remove unnecessary configs from babel.config.
  • [ ] Make tsc child process DX a little bit better.
  • [ ] Fix error from downsample npm library in production build
    • https://github.com/web-infra-dev/rspack/issues/4980

Thanks @hardfist for helping with this PR!

scttcper avatar Sep 06 '24 16:09 scttcper

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

github-actions[bot] avatar Sep 06 '24 16:09 github-actions[bot]

~~Just realized its working for me locally because i fixed platformicons locally will need to publish a fix to the svg paths there~~

scttcper avatar Sep 06 '24 16:09 scttcper

:x: 1 Tests Failed:

Tests completed Failed Passed Skipped
10290 1 10289 9
View the full list of 1 :snowflake: flaky tests
Sentry Application Details Editing an existing public Sentry App with a scope error handles client secret rotation

Flake rate in main: 18.18% (Passed 9 times, Failed 2 times)

Stack Traces | 0.405s run time
TestingLibraryElementError: Unable to find an element with the text: This will be the only time your client secret is visible!. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
...
    at Object.getElementError (.../sentry/sentry/node_modules/@.../dom/dist/config.js:37:19)
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:76:38
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:52:17
    at .../sentry/sentry/node_modules/@.../dom/dist/query-helpers.js:95:19
    at Object.<anonymous> (.../settings/organizationDeveloperSettings/sentryApplicationDetails.spec.tsx:591:42)

To view more test analytics, go to the Test Analytics Dashboard 📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

codecov[bot] avatar Sep 26 '24 03:09 codecov[bot]