You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using TypeScript, Babel is not required, but React Hot Loader will not work without it.
101
+
When using TypeScript, Babel is not required, but React Hot Loader will not work (properly) without it.
102
102
Just add `babel-loader` into your Webpack configuration, with React Hot Loader plugin.
103
103
104
+
There is 2 different ways to do it.
105
+
106
+
##### Add babel AFTER typescript.
107
+
104
108
```js
105
109
{
106
110
test:/\.tsx?$/,
@@ -117,7 +121,7 @@ Just add `babel-loader` into your Webpack configuration, with React Hot Loader p
117
121
}
118
122
```
119
123
120
-
You **also have to modify your `tsconfig.json`**:
124
+
In this case you have to modify your `tsconfig.json`, and compile to ES6 mode, as long React-Hot-Loader babel plugin could not understand ES5 code.
121
125
122
126
```json
123
127
// tsconfig.json
@@ -127,7 +131,29 @@ You **also have to modify your `tsconfig.json`**:
127
131
}
128
132
```
129
133
130
-
Yet again - module = es6 **will not work**.
134
+
##### Add babel BEFORE typescript (preferred)
135
+
136
+
```js
137
+
{
138
+
test:/\.tsx?$/,
139
+
use: [
140
+
'ts-loader', // (or awesome-typescript-loader)
141
+
{
142
+
loader:'babel-loader',
143
+
options: {
144
+
plugins: [
145
+
'@babel/plugin-syntax-typescript',
146
+
'@babel/plugin-syntax-decorators',
147
+
'@babel/plugin-syntax-jsx',
148
+
'react-hot-loader/babel',
149
+
],
150
+
},
151
+
}
152
+
],
153
+
}
154
+
```
155
+
156
+
In this case you can compile to ES5. More about [typescript and react-hot-loader](https://github.com/gaearon/react-hot-loader/issues/884)
131
157
132
158
We also have a [full example running TypeScript + React Hot Loader](https://github.com/gaearon/react-hot-loader/tree/master/examples/typescript).
133
159
@@ -458,8 +484,6 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
0 commit comments