Skip to content

Commit 7b89893

Browse files
committed
Upgrade to babel@7 and support TypeScript
See matrix-org/matrix-react-sdk#3292 Like react-sdk#3292, this fixes the couple source files which mix imports and module exports (they can't be mixed anymore).
1 parent 7660625 commit 7b89893

File tree

6 files changed

+1076
-742
lines changed

6 files changed

+1076
-742
lines changed

.babelrc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"presets": [
3-
"react",
4-
"es2015",
5-
"es2016"
3+
"@babel/preset-react",
4+
["@babel/preset-env", {
5+
"modules": false,
6+
"targets": {"browsers": ["last 2 versions"]}
7+
}],
8+
"@babel/preset-flow",
9+
"@babel/preset-typescript"
610
],
711
"plugins": [
8-
[
9-
"transform-builtin-extend",
10-
{
11-
"globals": ["Error"]
12-
}
13-
],
14-
"transform-class-properties",
15-
"transform-object-rest-spread",
16-
"transform-async-to-bluebird",
17-
"transform-runtime",
18-
"add-module-exports",
19-
"syntax-dynamic-import"
12+
"babel-plugin-add-module-exports",
13+
"@babel/plugin-proposal-numeric-separator",
14+
"@babel/plugin-proposal-class-properties",
15+
"@babel/plugin-proposal-object-rest-spread",
16+
"@babel/plugin-transform-flow-comments",
17+
"@babel/plugin-transform-async-to-generator",
18+
"@babel/plugin-transform-runtime",
19+
"@babel/plugin-syntax-dynamic-import"
2020
]
2121
}

package.json

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"diff-i18n": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && yarn i18n && node scripts/compare-file.js src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json",
3434
"build:res": "node scripts/copy-res.js",
3535
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js",
36-
"build:compile": "yarn reskindex && babel --source-maps -d lib src",
36+
"build:compile": "yarn reskindex && babel --source-maps -d lib src --extensions \".ts,.js\"",
3737
"build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production",
3838
"build:bundle:dev": "webpack --progress --bail --mode development",
3939
"build:electron": "yarn clean && yarn build && yarn install:electron && build -wml --ia32 --x64",
@@ -86,22 +86,25 @@
8686
"url": "^0.11.0"
8787
},
8888
"devDependencies": {
89+
"@babel/cli": "^7.5.5",
90+
"@babel/core": "^7.5.5",
91+
"@babel/plugin-proposal-class-properties": "^7.5.5",
92+
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
93+
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
94+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
95+
"@babel/plugin-transform-async-to-generator": "^7.5.0",
96+
"@babel/plugin-transform-flow-comments": "^7.5.5",
97+
"@babel/plugin-transform-runtime": "^7.5.5",
98+
"@babel/preset-env": "^7.5.5",
99+
"@babel/preset-flow": "^7.0.0",
100+
"@babel/preset-react": "^7.0.0",
101+
"@babel/preset-typescript": "^7.3.3",
89102
"autoprefixer": "^6.6.0",
90-
"babel-cli": "^6.26.0",
91-
"babel-core": "^6.26.3",
92103
"babel-eslint": "^8.1.1",
93-
"babel-loader": "^7.1.5",
94-
"babel-plugin-add-module-exports": "^0.2.1",
104+
"babel-loader": "^8.0.6",
105+
"babel-plugin-add-module-exports": "^1.0.2",
95106
"babel-plugin-syntax-dynamic-import": "^6.18.0",
96-
"babel-plugin-transform-async-to-bluebird": "^1.1.1",
97-
"babel-plugin-transform-builtin-extend": "^1.1.2",
98-
"babel-plugin-transform-class-properties": "^6.24.1",
99107
"babel-plugin-transform-object-rest-spread": "^6.26.0",
100-
"babel-plugin-transform-runtime": "^6.23.0",
101-
"babel-preset-es2015": "^6.24.1",
102-
"babel-preset-es2016": "^6.24.1",
103-
"babel-preset-es2017": "^6.24.1",
104-
"babel-preset-react": "^6.24.1",
105108
"babel-preset-stage-2": "^6.24.1",
106109
"chokidar": "^2.0.4",
107110
"concurrently": "^4.0.1",
@@ -148,6 +151,7 @@
148151
"react-addons-test-utils": "^15.6.0",
149152
"rimraf": "^2.4.3",
150153
"source-map-loader": "^0.2.4",
154+
"typescript": "^3.5.3",
151155
"webpack": "^4.23.1",
152156
"webpack-cli": "^3.1.2",
153157
"webpack-dev-server": "^3.1.11"

src/components/views/auth/VectorAuthFooter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import SdkConfig from 'matrix-react-sdk/lib/SdkConfig';
2222

2323
import { _t } from 'matrix-react-sdk/lib/languageHandler';
2424

25-
module.exports = React.createClass({
25+
export default React.createClass({
2626
displayName: 'VectorAuthFooter',
2727
statics: {
2828
replaces: 'AuthFooter',

src/components/views/auth/VectorCustomServerDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { _t } from 'matrix-react-sdk/lib/languageHandler';
2222
* This is identical to `CustomServerDialog` except for replacing "this app"
2323
* with "Riot".
2424
*/
25-
module.exports = React.createClass({
25+
export default React.createClass({
2626
displayName: 'VectorCustomServerDialog',
2727
statics: {
2828
replaces: 'CustomServerDialog',

tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"moduleResolution": "node",
5+
"allowJs": true,
6+
"noEmit": false,
7+
"strict": false,
8+
"isolatedModules": true,
9+
"esModuleInterop": true
10+
},
11+
"include": [
12+
"src/*.ts",
13+
"src/**/*.ts"
14+
]
15+
}

0 commit comments

Comments
 (0)