create-react-app-hack icon indicating copy to clipboard operation
create-react-app-hack copied to clipboard

Step 1 — Switch from React to Preact

Open sampi opened this issue 6 years ago • 0 comments

It's time to get hacking!

The main idea here is that we alias react* modules with their preact* equivalents and pull in preact-compat to make sure the API stays the same. This is done both for Node and webpack.

For testing, it's a bit trickier, we pull in preact-render-to-json and put it on the global scope to be available in all tests. Due to babel-preset-react, we need to remove __self and __source from the output JSON to be able to reliably use snapshot testing in jest.

File sizes:

File name Before gzip After gzip
build/static/js/main.d722544c.js 38.22 kB 13.12 kB

Source Map Analyzer output: screen shot 2018-04-22 at 13 06 35

sampi avatar Apr 22 '18 11:04 sampi