From 0d788e0aec93de2f769bb8fa918ca44e967da38b Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sat, 23 Nov 2019 21:08:30 +0100 Subject: [PATCH] Add typescript dependency & tsconfig.json Signed-off-by: David Mehren --- package.json | 11 ++++++++--- tsconfig.json | 12 ++++++++++++ webpack.common.js | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tsconfig.json diff --git a/package.json b/package.json index 7f78d14ff..4736b8aaf 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,18 @@ "name": "CodiMD", "version": "1.6.0", "description": "Realtime collaborative markdown notes on all platforms.", - "main": "app.js", + "main": "lib/app.js", "license": "AGPL-3.0", "scripts": { "test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha-suite", - "eslint": "node_modules/.bin/eslint --max-warnings 0 lib public test app.js", + "eslint": "node_modules/.bin/eslint --max-warnings 0 lib public test", "jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done", "mocha-suite": "NODE_ENV=test CMD_DB_URL=\"sqlite::memory:\" mocha --exit", "standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1", "dev": "webpack --config webpack.dev.js --progress --colors --watch", "heroku-prebuild": "bin/heroku", "build": "webpack --config webpack.prod.js --progress --colors --bail", - "start": "sequelize db:migrate && node app.js" + "start": "tsc && sequelize db:migrate && node built/app.js" }, "dependencies": { "@passport-next/passport-openid": "^1.0.0", @@ -167,6 +167,9 @@ "url": "https://github.com/codimd/server.git" }, "devDependencies": { + "@types/express": "4.17.0", + "@types/node": "^12.12.12", + "awesome-typescript-loader": "^5.2.1", "babel-cli": "^6.26.0", "babel-core": "^6.26.3", "babel-loader": "^7.1.4", @@ -196,6 +199,8 @@ "script-loader": "^0.7.2", "string-loader": "^0.0.1", "style-loader": "^1.0.0", + "tslint": "^5.20.1", + "typescript": "^3.7.2", "url-loader": "^2.3.0", "webpack": "^4.41.2", "webpack-cli": "^3.3.10", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..e69515925 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "outDir": "./built", + "allowJs": true, + "target": "es5", + "module": "commonjs", + "esModuleInterop": true + }, + "include": [ + "./lib/**/*" + ] +} diff --git a/webpack.common.js b/webpack.common.js index dd2280de3..e9a7aba04 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -357,7 +357,7 @@ module.exports = { resolve: { modules: ['node_modules'], - extensions: ['.js'], + extensions: ['.js', '.ts', '.tsx'], alias: { codemirror: path.join(__dirname, 'node_modules/codemirror/codemirror.min.js'), inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), @@ -388,6 +388,9 @@ module.exports = { module: { rules: [{ + test: /\.tsx?$/, + use: [{ loader: 'awesome-typescript-loader' }] + }, { test: /\.js$/, use: [{ loader: 'babel-loader' }], exclude: [/node_modules/, /public\/vendor/]