Explorar el Código

typescriptize

Yuki Takei hace 4 años
padre
commit
e79aec06b4

+ 9 - 2
packages/app/config/webpack.common.js

@@ -72,10 +72,13 @@ module.exports = (options) => {
         '@alias/logger': path.resolve(__dirname, '../src/utils/logger'),
       },
     },
+    node: {
+      fs: 'empty',
+    },
     module: {
       rules: options.module.rules.concat([
         {
-          test: /.jsx?$/,
+          test: /.(jsx?|tsx?)$/,
           exclude: {
             test: path.resolve(__dirname, '../node_modules'),
             exclude: [ // include as a result
@@ -85,7 +88,11 @@ module.exports = (options) => {
             ],
           },
           use: [{
-            loader: 'babel-loader?cacheDirectory',
+            loader: 'ts-loader',
+            options: {
+              transpileOnly: true,
+              configFile: path.resolve(__dirname, '../tsconfig.build.json'),
+            },
           }],
         },
         {

+ 4 - 1
packages/app/package.json

@@ -115,7 +115,8 @@
   },
   "// comments for defDependencies": {
     "@handsontable/react": "v3 requires handsontable >= 7.0.0.",
-    "handsontable": "v7.0.0 or above is no loger MIT lisence."
+    "handsontable": "v7.0.0 or above is no loger MIT lisence.",
+    "ts-loader": "v9 is not compatible with webpack@5"
   },
   "devDependencies": {
     "@alienfast/i18next-loader": "^1.0.16",
@@ -132,6 +133,7 @@
     "@types/express": "^4.17.11",
     "@types/multer": "^1.4.5",
     "@types/node": "^14.14.35",
+    "@types/react-dom": "^17.0.9",
     "@typescript-eslint/eslint-plugin": "^4.28.5",
     "@typescript-eslint/parser": "^4.28.5",
     "autoprefixer": "^9.0.0",
@@ -222,6 +224,7 @@
     "throttle-debounce": "^2.0.0",
     "toastr": "^2.1.2",
     "ts-jest": "^26.5.4",
+    "ts-loader": "^8.3.0",
     "ts-node": "^9.1.1",
     "ts-node-dev": "^1.1.6",
     "tsc-alias": "^1.2.9",

+ 17 - 0
packages/app/tsconfig.build.json

@@ -0,0 +1,17 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "esnext",
+    "alwaysStrict": true,
+    "jsx": "react",
+    "noFallthroughCasesInSwitch": true,
+    "noUnusedLocals": true,
+    "noUnusedParameters": true,
+    "skipLibCheck": true,
+    "strict": true
+  },
+  "exclude": [
+    "node_modules",
+    "**/*.test.ts"
+  ]
+}