React 17 + TypeScript 4 + Webpack 5
I can't find a boilerplate for these new major versions, so I made one!
TypeScript
-
typescript
: v 4.0 -
tsconfig.json
is the config file for TypeScript -
Note on
baseUrl
andpaths
: if I import any dependencies, it seems that I need to set"moduleResolution": "Node"
, which requires me to addbaseUrl
andpaths
to make resolution successful.
Webpack
-
webpack
: configs are commented -
ts-loader
: to load TypeScript with Webpack, we needts-loader
-
webpack-merge
: to merge webpack config files -
webpack-dev-server
,webpack-cli
are used to serve a development server
React
-
react
-
react-dom
: necessary for react to be used for the web -
To make react have type declarations for TypeScript
npm install @types/react @types/react-dom
-
import * as React from 'react
in all tsx file to make Typescript happy.
Prettier
- Actually great stuff, it formats your code nicely automatically.
Testing
- OMGOMGOMG
jest
is good testing package, but ... lots of configts-jest
is necessary to makejest
work withts
enzyme
renders thedom
, possibly I can removereact-test-renderer
react-test-renderer
was added for snapshot testing- Need to make a setup script for enzyme, why sway?
- the baseUrl + paths are supposed to be mapped with the helper function
pathsToModuleNameMapper
fromts-jest
, did not work
Redux
@reduxjs/toolkit
reduces the boilerplate so much, built something similar before.
Linter
- TBA