Jhernandez has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/371010 )
Change subject: WIP: Chore: Add ES5 transpilation for client files
......................................................................
WIP: Chore: Add ES5 transpilation for client files
Using typescript as the compiler, add ts-loader so that webpack
transpiles files to ES5.
* Base tsconfig.json in the root of the project
* Specific client details extending the root config in
src/client/tsconfig.json
TODO:
* Fix linting & formatting.
Change-Id: If76bd06a768e75a82e1d54e45be8177e2decf20b
---
M package-lock.json
M package.json
R src/client/index.ts
A src/client/tsconfig.json
A tsconfig.json
M webpack.config.js
6 files changed, 107 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/10/371010/1
diff --git a/package-lock.json b/package-lock.json
index 2d71c41..da73b19 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -550,6 +550,21 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true
},
+ "color-convert": {
+ "version": "1.9.0",
+ "resolved":
"https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz",
+ "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved":
"https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
"comment-parser": {
"version": "0.4.0",
"resolved":
"https://registry.npmjs.org/comment-parser/-/comment-parser-0.4.0.tgz",
@@ -5011,6 +5026,49 @@
"integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=",
"dev": true
},
+ "ts-loader": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-2.3.2.tgz",
+ "integrity":
"sha512-KcQvWwla5nviCMX1511iKVsLfrx97Hbah6l5awE1HNL6eiyAzb3gSO8b5yasB6fK/qGukLpu9czWcd/AGGFy/g==",
+ "dev": true,
+ "requires": {
+ "chalk": "2.1.0",
+ "enhanced-resolve": "3.4.1",
+ "loader-utils": "1.1.0",
+ "semver": "5.4.1"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "3.2.0",
+ "resolved":
"https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
+ "integrity":
"sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
+ "dev": true,
+ "requires": {
+ "color-convert": "1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz",
+ "integrity":
"sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "3.2.0",
+ "escape-string-regexp": "1.0.5",
+ "supports-color": "4.2.1"
+ }
+ },
+ "supports-color": {
+ "version": "4.2.1",
+ "resolved":
"https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz",
+ "integrity":
"sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==",
+ "dev": true,
+ "requires": {
+ "has-flag": "2.0.0"
+ }
+ }
+ }
+ },
"tty-browserify": {
"version": "0.0.0",
"resolved":
"https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
@@ -5047,6 +5105,12 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
+ "typescript": {
+ "version": "2.4.2",
+ "resolved":
"https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz",
+ "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=",
+ "dev": true
+ },
"uglify-js": {
"version": "2.8.29",
"resolved":
"https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
diff --git a/package.json b/package.json
index 9faa5b5..b8eb578 100644
--- a/package.json
+++ b/package.json
@@ -56,6 +56,8 @@
"npm-run-all": "^4.0.2",
"prettier": "^1.5.3",
"sinon": "^3.0.0",
+ "ts-loader": "^2.3.2",
+ "typescript": "^2.4.2",
"webpack": "^3.4.1"
}
}
diff --git a/src/client/index.js b/src/client/index.ts
similarity index 100%
rename from src/client/index.js
rename to src/client/index.ts
diff --git a/src/client/tsconfig.json b/src/client/tsconfig.json
new file mode 100644
index 0000000..2820b53
--- /dev/null
+++ b/src/client/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "target": "ES5",
+ "module": "ES2015"
+ }
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..f67dbd8
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "jsx": "react",
+ "jsxFactory": "h",
+ "sourceMap": true,
+
+ "strict": true,
+
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true
+ }
+}
diff --git a/webpack.config.js b/webpack.config.js
index df59ce5..6baf533 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,3 +1,5 @@
+/* eslint-env node */
+
const path = require("path");
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
@@ -14,7 +16,7 @@
target: "web",
entry: {
- index: "./src/client/index.js"
+ index: "./src/client/index"
},
output: {
@@ -26,6 +28,23 @@
filename: "[name].[chunkhash].js"
},
+ resolve: {
+ // Add `.ts` and `.tsx` as a resolvable extension.
+ extensions: [".ts", ".tsx", ".js"]
+ },
+
+ module: {
+ rules: [
+ {
+ test: /\.tsx?$/,
+ loader: "ts-loader",
+ options: {
+ configFileName: "./src/client/tsconfig.json"
+ }
+ }
+ ]
+ },
+
devtool: isProd ? "source-map" : "cheap-module-eval-source-map",
plugins: [
--
To view, visit https://gerrit.wikimedia.org/r/371010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If76bd06a768e75a82e1d54e45be8177e2decf20b
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits