Skip to content

Migrate to rsbuild and swc #3131

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

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Migrate to rsbuild and swc #3131

wants to merge 34 commits into from

Conversation

RichDom2185
Copy link
Member


Description

CRA is dead. Switch to rsbuild (which uses rspack → drop-in for webpack → powers CRA), but written in Rust so much faster.

  • Switch to rsbuild for performance and maintenance
  • Upgrade jest from v27 to v29
  • Switch to swc parser (also happens to be written in rust lol) for jest for performance
  • Remove CRA and CRACO

Type of change

  • Code quality improvements

How to test

Everything should (and does) still work since it's effectively drop in.

Checklist

  • I have tested this code
  • I have updated the documentation

@RichDom2185 RichDom2185 requested a review from leeyi45 April 26, 2025 14:21
@RichDom2185 RichDom2185 self-assigned this Apr 26, 2025
@RichDom2185 RichDom2185 enabled auto-merge (squash) April 26, 2025 14:22
@RichDom2185 RichDom2185 disabled auto-merge April 26, 2025 14:23
@coveralls
Copy link

Pull Request Test Coverage Report for Build 14682142426

Details

  • 22 of 34 (64.71%) changed or added relevant lines in 5 files are covered.
  • 7931 unchanged lines in 469 files lost coverage.
  • Overall coverage increased (+14.0%) to 45.123%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rsbuild.config.ts 0 2 0.0%
jsdom-env.js 0 4 0.0%
jest.config.js 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
src/assets/BrickSvg.tsx 1 83.33%
src/commons/application/actions/CommonsActions.ts 1 91.67%
src/commons/application/reducers/CommonsReducer.ts 1 88.89%
src/commons/application/reducers/VscodeReducer.ts 1 88.89%
src/commons/application/tests/snapshots/Application.tsx.snap 1 0.0%
src/commons/assessment/AssessmentNotFound.tsx 1 85.71%
src/commons/collabEditing/CollabEditingActions.ts 1 92.86%
src/commons/controlBar/ControlBarCloseButton.tsx 1 92.86%
src/commons/controlBar/ControlBarStepLimit.tsx 1 75.0%
src/commons/controlBar/github/ControlBarGitHubButtons.tsx 1 83.02%
Totals Coverage Status
Change from base Build 14494411351: 14.0%
Covered Lines: 10126
Relevant Lines: 21044

💛 - Coveralls

@RichDom2185 RichDom2185 mentioned this pull request Apr 26, 2025
16 tasks
Copy link
Contributor

@sayomaki sayomaki left a comment

Choose a reason for hiding this comment

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

Did a preliminary quick review of the code changes, although I'm not too sure for the testing updates. As long as they are passing (which they appear to do so), I think it should not be too far off.

I have also yet to run the code locally, so here are just some questions and ideas from me after glancing over the changes, let me know what you think!

@@ -20,8 +21,7 @@
"format:tsx": "prettier --list-different \"src/**/*.{js,jsx,ts,tsx}\"",
"format:scss": "prettier --list-different --parser scss \"src/**/*.scss\"",
"format:ci": "yarn run format:tsx && yarn run format:scss",
"start": "cross-env DISABLE_ESLINT_PLUGIN=true BROWSER=none PORT=8000 craco start",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we consider having start alias dev for those users still used to the old way of launching? Or do you think that is not necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can just use start instead of dev

@@ -25,7 +25,8 @@
"test-coveralls": "./scripts/test-coveralls.sh",
"update-ui-snapshots": "jest --updateSnapshot",
"eslint": "eslint src",
"prepare": "husky"
"prepare": "husky",
"preview": "rsbuild preview"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can have this as the new yarn start command behaviour instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we shouldn't, because preview is to preview the production bundle (after running yarn build). We can just alias start to dev instead as per your comment above

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this file be named globals.d.ts or imports.d.ts instead? Since it will be required at quite a high level, env doesn't really make too much sense as this handles the import types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll make the changes later. Thanks!

@leeyi45
Copy link
Contributor

leeyi45 commented Apr 27, 2025

Previously with Webpack it would compile away the dynamic import used to import modules (because there was no way to webpack-ignore something in js-slang). Should I check if js-slang can be switched away from using the function constructor, or should we leave things as is?

@RichDom2185
Copy link
Member Author

Previously with Webpack it would compile away the dynamic import used to import modules (because there was no way to webpack-ignore something in js-slang). Should I check if js-slang can be switched away from using the function constructor, or should we leave things as is?

@leeyi45 I think I saw this comment somewhere, but wasn't too sure what it entailed in terms of testing.

I had tried running some module code in the playground and it seems to work, though I'm not sure if that is what you mean.

Would you mind checking as well? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up codebase post-migration to Vite/React19 Migrate to Vite
4 participants