Skip to content
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

speed up development env with swc-loader and hmr #3458

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

christianvogt
Copy link
Contributor

@christianvogt christianvogt commented Nov 8, 2024

With this change, startup of dev server is faster and provides hot module reloading without full page refresh.

  • Replace ts-loader with swc-loader but only for dev mode.
  • Add webpack plugin ReactRefreshWebpackPlugin for fast hot module reloading.
  • Add webpack plugin ForkTsCheckerWebpackPlugin to fork type checking to a separate thread.
  • Add webpack plugin https://github.com/stephencookdev/speed-measure-webpack-plugin for measuring startup times.
    • Use only for measuring start up times. This will break react refresh plugin and cause hot reloading to fail.

To measure startup times use: MEASURE=true npm run start:dev:ext.

Start up times for frontend npm run start:dev:ext

swc-loader:
General output time took 33.89 secs
General output time took 31.31 secs
General output time took 31.66 secs

ts-loader:
General output time took 46.79 secs
General output time took 45.35 secs
General output time took 41.036 secs

Prior to any changes:

General output time took 1 min, 27.1 secs
General output time took 1 min, 25.41 secs
General output time took 1 min, 27.89 secs

@christianvogt christianvogt changed the title speed up development env with swc-loader and hmr [WIP] speed up development env with swc-loader and hmr Nov 8, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Nov 8, 2024
Copy link

codecov bot commented Nov 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.64%. Comparing base (429d339) to head (6318620).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3458      +/-   ##
==========================================
- Coverage   85.66%   85.64%   -0.03%     
==========================================
  Files        1347     1347              
  Lines       30680    30670      -10     
  Branches     8550     8550              
==========================================
- Hits        26282    26266      -16     
- Misses       4398     4404       +6     

see 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 429d339...6318620. Read the comment docs.

@christianvogt christianvogt changed the title [WIP] speed up development env with swc-loader and hmr speed up development env with swc-loader and hmr Nov 9, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Nov 9, 2024
@jeff-phillips-18
Copy link
Contributor

Start up is faster
Updates after a code change is a lot faster.

I haven't seen any issues.

/lgtm

(now if only we could get it to stop faster on a cntrl-c)

Copy link
Member

@DaoDaoNoCode DaoDaoNoCode left a comment

Choose a reason for hiding this comment

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

Tested, hot reload is amazing. Loading is a lot faster.
/lgtm

Copy link
Contributor

@mturley mturley left a comment

Choose a reason for hiding this comment

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

This looks amazing, can't wait to get it merged and use it.

@christianvogt I did notice one weird thing - when I pass MEASURE=true, hot reloading isn't working and in fact the server appears to break after a change. After making a code change it never reloads, and then if I reload the page I get a blank white screen with this console error:

Screenshot 2024-11-12 at 4 16 27 PM

Without MEASURE set, everything works great. Do we care about that? If we do want to fix it maybe that can be a followup PR.

@christianvogt
Copy link
Contributor Author

@mturley yes i guess I forgot to mention that. React refresh doesn't work with speed-measure-webpack-plugin :(

@mturley
Copy link
Contributor

mturley commented Nov 12, 2024

Ah got it. No worries then, I don't see a problem with merging.

Copy link
Contributor

@mturley mturley left a comment

Choose a reason for hiding this comment

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

Real good stuff.

Copy link
Contributor

openshift-ci bot commented Nov 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DaoDaoNoCode, mturley

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 6f439e5 into opendatahub-io:main Nov 12, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants