Switching to React 2 is easier than shoehorning ES6 fixes into React 1

Title is pretty self explanatory.

After a long battle, many many yarns later, it turned out that trying to get CK Editor to work in an older version of React Scripts, as an example, was far too much work. What’s more, there aren’t too many barriers in moving from React Scripts 1 to version 2. Some of the Routing syntax has changed but overall a build using forms, axios, mammoth, and a few other common repos, switched with minimal effort and no feature loss (or replacement.)

This came about when trying to build an older repo with the newest CK Editor, 5. The error shown right away is:

Failed to minify the code from this file:                                              [31/75]         <project_root>/node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js:5:2077 

The directions provided by CKEditor are to eject the app, which is lasting and a huge pain, so instead React App Rewired looked like an option. After more than a few attempts, including duplicating and ejecting a backup repo, no amount of config overriding looked to get the editor to build in React Scripts v1.

This took, admittedly, hours to try and hack around only to hit more JS that refused to compile.

Updating the dependencies to React 2.1.8 and, after a couple more yarn updates, the build went right through. Done. No hacks, no weird shoehorning of ES5 into a largely ES6 build.

Ejecting should be a very last ditch effort for trying to get any repo that may not support the latest scripts version and while overrides are absolutely helpful in tweaking settings, they can’t redirect a whole build. Also, don’t eject React (this has been well covered.)

Leave a Reply

Your email address will not be published. Required fields are marked *