-
Notifications
You must be signed in to change notification settings - Fork 2
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
DSEGOG-341 Migrate from CRA to Vite #421
Conversation
7985007
to
acb5a81
Compare
9e25f4e
to
34d3ad2
Compare
8dbfdc1
to
86fb22e
Compare
f295281
to
f5e6450
Compare
d42fccc
to
a01142c
Compare
7c29057
to
fd74309
Compare
c29e391
to
d1f672a
Compare
0ec9fc2
to
bcd7452
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #421 +/- ##
===========================================
+ Coverage 95.35% 97.34% +1.99%
===========================================
Files 83 86 +3
Lines 3830 10583 +6753
Branches 1092 1649 +557
===========================================
+ Hits 3652 10302 +6650
- Misses 172 277 +105
+ Partials 6 4 -2 ☔ View full report in Codecov by Sentry. |
13cf5e9
to
f30b107
Compare
f30b107
to
683e819
Compare
b83aefc
to
dc92290
Compare
1d32886
to
d960d45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is looking good aside from some minor comments of mine. Dev mode works great, as does tests. However, when running yarn preview:dev:build
- I can't load OG in the SG react 18 branch. I'm getting an Uncaught SyntaxError: import declarations may only appear at top level of a module
error, and it's pointing to a React import. Might be me doing something wrong but thought I'd raise it!
src/plotting/plotSettings/plotSettingsController.component.test.tsx
Outdated
Show resolved
Hide resolved
Will address the other comments in the morning. Just spent a while debugging this with Joshua and finally got to the cause. Its the same issue you noticed on IMS, only there it was intermittent - almost every other build it did came out with imports in the main.js that shouldn't have been there breaking the build, only it seems that in the past few months an update has caused it to become a permanent issue not an intermittent one. I now believe as I was not specifying a format in the build, it used a default of |
@joelvdavies I believe the issue with the es build is we're not expecting an es module when loading the plugin from SciGateway - you need special handling to be able to handle es modules (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html) If we really wanted es modules, it's probably worth waiting until everything is migrated over to Vite, and then overhauling the SG plugin loading system to be able to handle es modules (either in replacement of handling non-modules, or be able to load either using a feature switch in the plugin config?) Either way, switching to UMD solves the immediate problem 👍 |
288e650
to
d20ee8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the changes to the build, I'm happy that everything works (i.e. dev, loading production build in SG, e2e tests, unit tests) - at least for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM tested dev, loading production build in SG, e2e tests, unit tests and e2e tests
Description
Migrates from CRA to Vite. Following on from ral-facilities/inventory-management-system#348 and ral-facilities/scigateway#1380.
Notes
tsconfig
from IMS (The config here was copied to IMS in the first place)VITE_APP_OPERATIONSGATEWAY_BUILD_DIRECTORY
toVITE_APP_OPERATIONS_GATEWAY_BUILD_DIRECTORY
REACT_APP_E2E_TESTING
withVITE_APP_INCLUDE_MSW
andVITE_APP_BUILD_STANDALONE
(Same as IMS so could use the same config and allows more explicit differentiation of e2e tests with and without the api)/sessions/:id
doesn't have a duplicate check in the backend when it probably should (also on a related note the post's should really use 201's but the backend currently uses 200s.)setupTests.tsx
totestUtils.tsx
and moved MSW setup to a separate newsetupTests.ts
imported in the vitest config - to avoid repeated execution during imports)jest-canvas-mock
withvitest-canvas-mock
applyDatePickerWorkaround
andcleanupDatePickerWorkaround
from unit tests - I added this in datagateway for MUI v5 when we enzyme and it was copied over here, but doesn't seem like its needed anymore (and broke here anyway)cypress-failed-log
as its 2 years old and I don't believe it does anything anymore or otherwise the import is broken as it cannot use requireyarn tsc
in the build process uses thetsconfig.build.json
. While the mock handlers could be excluded from this, it will then also break any e2e tests relying on this build - the fix would be to have another tsconfig for this case, and adding another build command that is only used in this case. Given it should already be removed from the bundle at the end, I thought this was simpler.yarn lint
is not the same as on IMS - we include tests in the checks with tsc to resolve further typescript issues, but there are many here that have been ignored and I thought it best to leave to a further eslint v9 PR if addressed as a resultTesting instructions
Add a set up instructions describing how the reviewer should test the code
Agile board tracking
Closes DSEGOG-341