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

front: migrate to vite #3211

Merged
merged 5 commits into from
Feb 22, 2023
Merged

front: migrate to vite #3211

merged 5 commits into from
Feb 22, 2023

Conversation

multun
Copy link
Contributor

@multun multun commented Feb 18, 2023

This change switch from react-create-app to vite:

  • 60 seconds for production builds
  • 10 seconds for starting a development server1

Close #3215

Use swc for dev builds

Swc is an faster alternative to babel. Babel is still used for production builds.
Please refer to the documentation of @vitejs/plugin-react-swc

Migrate to storybook 7 beta

Storybook 6 does not load vite.config.js. This is a huge issue,
as all vite configuration would have to be replicated into storybook.

Instead of writting hacks to backport this feature into storybook 6,
switch to the 7 beta, which loads and configures everything by itself.

Migrate tests to vitest

We cannot really use jest as it is tied to webpack.
Vitest is a drop-in replacement for jest, which works with vite.

I've added happy-dom as one of the tests starts up keycloak,
which breaks without dom access. Jest emulates the dom by default.

Footnotes

  1. development builds use swc, a faster alternative to babel

@multun multun added help wanted area:front Work on Standard OSRD Interface modules labels Feb 18, 2023
@multun multun force-pushed the migrate-to-vite branch 4 times, most recently from 57d03fe to 64a6e5b Compare February 20, 2023 17:24
@multun multun marked this pull request as ready for review February 20, 2023 17:24
@multun multun requested review from a team and flomonster as code owners February 20, 2023 17:24
@codecov
Copy link

codecov bot commented Feb 20, 2023

Codecov Report

Merging #3211 (7b31018) into dev (62637c9) will increase coverage by 23.67%.
The diff coverage is 100.00%.

@@              Coverage Diff              @@
##                dev    #3211       +/-   ##
=============================================
+ Coverage     43.18%   66.86%   +23.67%     
  Complexity     1874     1874               
=============================================
  Files           713      396      -317     
  Lines         20734    19094     -1640     
  Branches       2581     1487     -1094     
=============================================
+ Hits           8955    12768     +3813     
+ Misses        11296     5650     -5646     
- Partials        483      676      +193     
Flag Coverage Δ
front 52.37% <100.00%> (+47.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...TrainSchedule/AddTrainSchedule/trainNameHelper.jsx 25.00% <ø> (ø)
...ageTrainSchedule/Itinerary/ModalPathJSONDetail.jsx 14.86% <ø> (ø)
...ents/SimulationResults/simulationResultsConsts.jsx 100.00% <ø> (ø)
...nts/SimulationResults/simulationResultsHelpers.jsx 39.13% <ø> (ø)
...c/common/BootstrapSNCF/ModalSNCF/ModalBodySNCF.jsx 80.00% <ø> (ø)
...common/BootstrapSNCF/ModalSNCF/ModalFooterSNCF.jsx 76.92% <ø> (ø)
...c/common/BootstrapSNCF/ModalSNCF/ModalProvider.jsx 14.43% <ø> (ø)
front/src/common/Loader.jsx 66.66% <ø> (ø)
front/src/config/config.js 100.00% <100.00%> (ø)
front/src/utils/physics.ts 62.50% <0.00%> (-37.50%) ⬇️
... and 366 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

front/src/env.ts Outdated Show resolved Hide resolved
Swc is an faster alternative to babel. Babel is still used for production builds.
Please refer to the documentation of @vitejs/plugin-react-swc
Storybook 6 does not load vite.config.js. This is a huge issue,
as all vite configuration would have to be replicated into storybook.

Instead of writting hacks to backport this feature into storybook 6,
switch to the 7 beta, which loads and configures everything by itself.
We cannot really use jest as it is tied to webpack.
Vitest is a drop-in replacement for jest, which works with vite.

I've added happy-dom as one of the tests starts up keycloak,
which breaks without dom access. Jest emulates the dom by default.
@multun multun merged commit 39c7ba0 into dev Feb 22, 2023
@multun multun deleted the migrate-to-vite branch February 22, 2023 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

front: Migrate to Vite
3 participants