Skip to content

build: replace webpack with rspack #61475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

build: replace webpack with rspack #61475

wants to merge 1 commit into from

Conversation

anonrig
Copy link
Contributor

@anonrig anonrig commented Dec 8, 2023

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:

Thanks @hardfist for helping with this PR!

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 8, 2023
rspack.config.ts Outdated
: []),
// ...(SHOULD_FORK_TS
// ? [
// new ForkTsCheckerWebpackPlugin({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fork TS is very slow, will be the bottleneck of rspack build speeds. If you can run tsc as a separate command, it will keep the builds very fast.

@hardfist
Copy link

hardfist commented Dec 9, 2023

@anonrig do you know how to setup devenv for outside contributors, I'm not sure how should i setup the environment, I can't launch the server so I can't verify whether the migration runs successfully
image

@anonrig
Copy link
Contributor Author

anonrig commented Dec 9, 2023

@Hardist You don't need devenv for the frontend app. Cloning, installing dependencies and running "yarn dev-ui" is sufficient for running the frontend.

The public documentation is available at https://develop.sentry.dev/environment/

@hardfist
Copy link

hardfist commented Dec 9, 2023

@Hardist You don't need devenv for the frontend app. Cloning, installing dependencies and running "yarn dev-ui" is sufficient for running the frontend.

The public documentation is available at https://develop.sentry.dev/environment/

no need for homepage but seems needed for login page,but i will verify homepage first

@anonrig
Copy link
Contributor Author

anonrig commented Dec 9, 2023

no need for homepage but seems needed for login page,but i will verify homepage first

You can use mkert command in package.json with cookie sync chrome extension. https://chrome.google.com/webstore/detail/sentry-cookie-sync/kchlmkcdfohlmobgojmipoppgpedhijh

Copy link
Contributor

🚨 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.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.14%. Comparing base (8b86730) to head (6e51e59).
Report is 11156 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #61475   +/-   ##
=======================================
  Coverage   81.14%   81.14%           
=======================================
  Files        5191     5192    +1     
  Lines      228290   228333   +43     
  Branches    38279    38280    +1     
=======================================
+ Hits       185239   185284   +45     
  Misses      37433    37433           
+ Partials     5618     5616    -2     

see 22 files with indirect coverage changes

@@ -42,55 +42,55 @@ section.org-login {
background-size: cover;

&.google {
background-image: url(~sentry-logos/logo-google.svg);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change this for rspack, you can use alias to workaround this, but it's better to change since ~ is deprecated in latest less-loader both for webpack and rspack

},
{
test: /\.css/,
use: ['style-loader', 'css-loader'],
type: 'css',
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why sentry use style-loader to handle css and use minicssExtractPlugin to handle less before?

@@ -376,13 +293,13 @@ const appConfig: Configuration = {
* Without this, webpack will still output all of the unused locale files despite
* the application never loading any of them.
*/
new webpack.ContextReplacementPlugin(
new ContextReplacementPlugin(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure Rspack supports webpack.ContextReplacementPlugin now

},

// This only runs in production mode
// Grabbed this example from https://github.com/webpack-contrib/css-minimizer-webpack-plugin
minimizer: ['...', new CssMinimizerPlugin()],
minimizer: [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually no needed and enabled by default in production mode

@getsantry
Copy link
Contributor

getsantry bot commented Jan 2, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jan 2, 2024
@scttcper scttcper removed the Stale label Jan 2, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Jan 24, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jan 24, 2024
@scttcper scttcper removed the Stale label Jan 24, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Feb 15, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Feb 15, 2024
@anonrig anonrig removed the Stale label Feb 15, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Mar 8, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Mar 8, 2024
@ScriptedAlchemy
Copy link

bump

@getsantry
Copy link
Contributor

getsantry bot commented Mar 30, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Mar 30, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Mar 30, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@scttcper
Copy link
Member

scttcper commented Sep 6, 2024

@ScriptedAlchemy @hardfist thanks for your time looking at this. I've opened #77077 to startup the investigation with rspack v1. Congrats on the launch btw

@scttcper scttcper closed this Sep 6, 2024
@hardfist
Copy link

hardfist commented Sep 9, 2024

@scttcper thanks, if you met any problems, please ping me

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants