tasking-manager icon indicating copy to clipboard operation
tasking-manager copied to clipboard

Update react scripts

Open tsmock opened this issue 2 years ago • 12 comments

This updates react-scripts from 4.0.3. to 5.0.1. Due to some issues with react-scripts, CRACO was added to work around an issue with svg images. CRACO did cause the main bundle size to increase significantly to 6 MB, and the main bundle size can reduced via lazy loading in the router (see #5914). There is more in-depth analysis in that PR on decreasing the initial size of all bundles needed for the initial render.

tsmock avatar Jun 12 '23 17:06 tsmock

Shouldn't the CRACO configuration file have been included in this PR?

HelNershingThapa avatar Jun 15 '23 05:06 HelNershingThapa

Yep. It looks like I messed up when I was cherry-picking the commit; I didn't run git add on the config file.

tsmock avatar Jun 15 '23 11:06 tsmock

Let's also include the fix https://github.com/hotosm/tasking-manager/pull/5721/commits/9ed1d0c6608723b4d8b7f2aa356a8be4eb47c76d for the testimonial image in this PR?

HelNershingThapa avatar Jun 16 '23 05:06 HelNershingThapa

@tsmock, would it be okay to merge the pull request and address the --stats flag in a subsequent update?

HelNershingThapa avatar Jul 05 '23 17:07 HelNershingThapa

Works for me. I'm currently checking to make certain that tests didn't get borked on my last rebase.

tsmock avatar Jul 05 '23 17:07 tsmock

I've removed the --stats and done a few (3) test runs. The tests have been passing.

tsmock avatar Jul 05 '23 18:07 tsmock

We might want to hold off on merging this -- I just fixed a bug in @placemarkio/geo-viewport w.r.t. webpack 5. The fix has been merged, but is not yet released.

If you run yarn build and get Module not found: Error: Default condition should be last one, that is the problem that is fixed in current geo-viewport main but is not yet released.

tsmock avatar Jul 05 '23 20:07 tsmock

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.1% 0.1% Duplication

sonarqubecloud[bot] avatar Jul 06 '23 12:07 sonarqubecloud[bot]

geo-viewport released a fixed version, and I've updated it in this PR.

tsmock avatar Jul 06 '23 15:07 tsmock

The tests pass successfully, but the CircleCI process Run yarn test exists before generating the build with Exited with code exit status 1.

HelNershingThapa avatar Jul 07 '23 09:07 HelNershingThapa

Looking at https://github.com/jestjs/jest/issues/9324, it seems like there might be a test that is doing something wrong that might be causing the failure. I'm currently in the process of bisecting the test files, and I'm probably going to have to do that multiple times.

EDIT: It looks like the Cannot log after tests are done. Did you forget to wait for something async in your test? messages are probably the reason.

tsmock avatar Jul 07 '23 11:07 tsmock

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Feb 20 '24 12:02 sonarqubecloud[bot]

Hi @tsmock what's the view of yours on transitioning to vite? Will it be a lot of work or something i don't know ? Just a query

varun2948 avatar Apr 15 '24 05:04 varun2948

Doing it manually will be a lot of work. I looked into it a bit awhile ago (sometime last year). I don't remember why I dropped it (it might have been not wanting to have to do another massive PR while I had one in progress).

In my investigations, I found that someone wrote a script to eject to vite (https://github.com/bhbs/viject), so that will take care of the bulk of the work.

Things to note:

  • We use flow in some locations. We can use flow comments and/or convert to something else (typescript, jsdoc, etc). I think I converted flow typing to flow comments in one of my PRs. I don't remember which one. It isn't that difficult, and still works with flow (we literally just have to wrap the flow typing with /* and */).
  • We'll probably want to take advantage of SSR sometime (note: despite standing for "server-side rendering", it can be used to prerender static content to reduce resource usage on the client side).
  • I think we'll have to/want to use a different library for routing. IIRC, vite has its own routing library. I might be thinking of a different project though.

tsmock avatar Apr 15 '24 13:04 tsmock

Hmmm the viject tools seems interesting, i will have a look into it soon. But yeah so for now are we be moving ahead with this PR ? and then onwards try to switch it to vite, as i think we will be using alot of vite in other product of HOT aswell so maybe something to be considered ? Vite has a plugin for routing i guess which recently changed it's name to Vike. At the moment for moving forward on the TM for vite or upgrading the react-scripts/craco what's your take , let me know further on this if its feasible or not?

varun2948 avatar Apr 15 '24 13:04 varun2948

This was largely copied from #5721 so that we could build/run on Node 18+ without NODE_OPTIONS=--openssl-legacy-provider, so if #5721 is merged, that would remove the need for this PR.

TBH, I was using craco to work around problems in react-scripts (which is effectively no longer maintained). This is by no means the optimal path.

What I would do is the following:

  • Merge #5721
  • Run viject
  • Fix problems
  • Merge once things work "well enough" -- I think it would be a PITA to constantly rebase, since one of the changes done by viject is renaming files. I believe viject will work with react-scripts + craco.

Either way, I would strongly advocate moving away from react-scripts. It doesn't matter if it is next.js (Vercel), remix (Shopify), gatsby (Netlify), or vite.

With that said, it sounds like other HOT projects are using vite. So that is probably the winner.

tsmock avatar Apr 15 '24 13:04 tsmock

Hmmm sounds good will let ramya know on this aswell.

varun2948 avatar Apr 15 '24 14:04 varun2948

Still relevant @varun2948 ?

ramyaragupathy avatar May 01 '24 03:05 ramyaragupathy

No, this PR is no longer relevant; the changes from this PR were in #5721.

tsmock avatar May 01 '24 13:05 tsmock