ts-react-hot-transformer
v0.1.11
Published
<p align="center"> <a href="https://www.npmjs.org/package/ts-react-hot-transformer"><img src="https://img.shields.io/npm/v/ts-react-hot-transformer.svg?style=flat" alt="npm"></a> <a href="https://www.npmjs.com/package/ts-react-hot-transformer"><img sr
Downloads
8
Maintainers
Readme
ts-react-hot-transformer
react hot transformer for ts,and no babel
- Standalone : no babel, only configuration
ts-loader
Table of Contents
Installation
npm install --save-dev ts-react-hot-transformer react-hot-loader
Usage
With ts-loader
- Add
ts-react-hot-transformer
to yourts-loader
options:
// webpack.config.js
const tsReactHotTransformer = require('ts-react-hot-transformer')
module.exports = {
// ...
module: {
rules: [
{
test: /\.(jsx|tsx|js|ts)$/,
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [ tsReactHotTransformer() ]
}),
},
exclude: /node_modules/
}
]
},
// ...
}
- Mark your root component as hot-exported:
// App.js
import { hot } from 'react-hot-loader/root'
const App = () => <div>Hello World!</div>
export default hot(App)
webpack-dev-server --hot
Code Splitting
It is the same React-Dom, with the same version, to hot patch.
There is 2 ways to install it:
- Use
@hot-loader/react-dom
installed instead ofreact-dom
yarn add @hot-loader/react-dom
- Use webpack aliases
// webpack.conf
...
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom'
}
}
...