Procházet zdrojové kódy

Add tslib to TS compiler

- using tslib reduces bundle sizes
- add compiler option for easier default imports of CJS modules
- remove double entry of fork-ts-checker-plugin
- speed up hot reload by using exprimental ts-loader API
David Kaltschmidt před 7 roky
rodič
revize
84e431d377
4 změnil soubory, kde provedl 65 přidání a 42 odebrání
  1. 8 8
      package.json
  2. 9 1
      scripts/webpack/webpack.hot.js
  3. 42 31
      tsconfig.json
  4. 6 2
      yarn.lock

+ 8 - 8
package.json

@@ -34,7 +34,7 @@
     "expose-loader": "^0.7.3",
     "extract-text-webpack-plugin": "^4.0.0-beta.0",
     "file-loader": "^1.1.11",
-    "fork-ts-checker-webpack-plugin": "^0.4.1",
+    "fork-ts-checker-webpack-plugin": "^0.4.2",
     "gaze": "^1.1.2",
     "glob": "~7.0.0",
     "grunt": "1.0.1",
@@ -71,12 +71,14 @@
     "karma-webpack": "^3.0.0",
     "lint-staged": "^6.0.0",
     "load-grunt-tasks": "3.5.2",
+    "mini-css-extract-plugin": "^0.4.0",
     "mobx-react-devtools": "^4.2.15",
     "mocha": "^4.0.1",
     "ng-annotate-loader": "^0.6.1",
     "ng-annotate-webpack-plugin": "^0.2.1-pre",
     "ngtemplate-loader": "^2.0.1",
     "npm": "^5.4.2",
+    "optimize-css-assets-webpack-plugin": "^4.0.2",
     "phantomjs-prebuilt": "^2.1.15",
     "postcss-browser-reporter": "^0.5.0",
     "postcss-loader": "^2.0.6",
@@ -90,15 +92,16 @@
     "style-loader": "^0.21.0",
     "systemjs": "0.20.19",
     "systemjs-plugin-css": "^0.1.36",
-    "ts-loader": "^4.3.0",
     "ts-jest": "^22.4.6",
+    "ts-loader": "^4.3.0",
+    "tslib": "^1.9.3",
     "tslint": "^5.8.0",
     "tslint-loader": "^3.5.3",
     "typescript": "^2.6.2",
+    "uglifyjs-webpack-plugin": "^1.2.7",
     "webpack": "^4.8.0",
     "webpack-bundle-analyzer": "^2.9.0",
     "webpack-cleanup-plugin": "^0.5.1",
-    "fork-ts-checker-webpack-plugin": "^0.4.2",
     "webpack-cli": "^2.1.4",
     "webpack-dev-server": "^3.1.0",
     "webpack-merge": "^4.1.0",
@@ -155,14 +158,12 @@
     "immutable": "^3.8.2",
     "jquery": "^3.2.1",
     "lodash": "^4.17.10",
-    "mini-css-extract-plugin": "^0.4.0",
     "mobx": "^3.4.1",
     "mobx-react": "^4.3.5",
     "mobx-state-tree": "^1.3.1",
     "moment": "^2.22.2",
     "mousetrap": "^1.6.0",
     "mousetrap-global-bind": "^1.1.0",
-    "optimize-css-assets-webpack-plugin": "^4.0.2",
     "prismjs": "^1.6.0",
     "prop-types": "^15.6.0",
     "react": "^16.2.0",
@@ -181,10 +182,9 @@
     "slate-react": "^0.12.4",
     "tether": "^1.4.0",
     "tether-drop": "https://github.com/torkelo/drop/tarball/master",
-    "tinycolor2": "^1.4.1",
-    "uglifyjs-webpack-plugin": "^1.2.7"
+    "tinycolor2": "^1.4.1"
   },
   "resolutions": {
     "caniuse-db": "1.0.30000772"
   }
-}
+}

+ 9 - 1
scripts/webpack/webpack.hot.js

@@ -20,6 +20,7 @@ module.exports = merge(common, {
     path: path.resolve(__dirname, '../../public/build'),
     filename: '[name].[hash].js',
     publicPath: "/public/build/",
+    pathinfo: false,
   },
 
   resolve: {
@@ -37,6 +38,12 @@ module.exports = merge(common, {
     }
   },
 
+  optimization: {
+    removeAvailableModules: false,
+    removeEmptyChunks: false,
+    splitChunks: false,
+  },
+
   module: {
     rules: [
       {
@@ -56,7 +63,8 @@ module.exports = merge(common, {
         {
           loader: 'ts-loader',
           options: {
-            transpileOnly: true
+            transpileOnly: true,
+            experimentalWatchApi: true
           },
         }],
       },

+ 42 - 31
tsconfig.json

@@ -1,32 +1,43 @@
 {
-    "compilerOptions": {
-      "moduleResolution": "node",
-      "outDir": "public/dist",
-      "target": "es5",
-      "lib": ["es6", "dom"],
-      "rootDir": "public/",
-      "jsx": "react",
-      "module": "esnext",
-      "declaration": false,
-      "allowSyntheticDefaultImports": true,
-      "inlineSourceMap": false,
-      "sourceMap": true,
-      "noEmitOnError": false,
-      "emitDecoratorMetadata": false,
-      "experimentalDecorators": true,
-      "noImplicitReturns": true,
-      "noImplicitThis": false,
-      "noImplicitUseStrict":false,
-      "noImplicitAny": false,
-      "noUnusedLocals": true,
-      "baseUrl": "public",
-      "paths": {
-        "app": ["app"]
-      }
-    },
-    "include": [
-      "public/app/**/*.ts",
-      "public/app/**/*.tsx",
-      "public/test/**/*.ts"
-    ]
-}
+  "compilerOptions": {
+    "moduleResolution": "node",
+    "outDir": "public/dist",
+    "target": "es5",
+    "lib": [
+      "es6",
+      "dom"
+    ],
+    "rootDir": "public/",
+    "jsx": "react",
+    "module": "esnext",
+    "declaration": false,
+    "allowSyntheticDefaultImports": true,
+    "esModuleInterop": true,
+    "forceConsistentCasingInFileNames": true,
+    "importHelpers": true, // importing helper functions from tslib
+    "noEmitHelpers": true, // disable emitting inline helper functions
+    "removeComments": false, // comments are needed by angular injections
+    "inlineSourceMap": false,
+    "sourceMap": true,
+    "noEmitOnError": false,
+    "emitDecoratorMetadata": false,
+    "experimentalDecorators": true,
+    "noImplicitReturns": true,
+    "noImplicitThis": false,
+    "noImplicitUseStrict": false,
+    "noImplicitAny": false,
+    "noUnusedLocals": true,
+    "baseUrl": "public",
+    "pretty": true,
+    "paths": {
+      "app": [
+        "app"
+      ]
+    }
+  },
+  "include": [
+    "public/app/**/*.ts",
+    "public/app/**/*.tsx",
+    "public/test/**/*.ts"
+  ]
+}

+ 6 - 2
yarn.lock

@@ -3101,7 +3101,7 @@ d3-request@1.0.6:
     d3-dsv "1"
     xmlhttprequest "1"
 
-d3-scale-chromatic@^1.1.1:
+d3-scale-chromatic@^1.3.0:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/d3-scale-chromatic/-/d3-scale-chromatic-1.3.0.tgz#7ee38ffcaa7ad55cfed83a6a668aac5570c653c4"
   dependencies:
@@ -7974,7 +7974,7 @@ mocha@^4.0.1:
     mkdirp "0.5.1"
     supports-color "4.4.0"
 
-moment@^2.18.1:
+moment@^2.22.2:
   version "2.22.2"
   resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
 
@@ -12029,6 +12029,10 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
   version "1.9.2"
   resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.2.tgz#8be0cc9a1f6dc7727c38deb16c2ebd1a2892988e"
 
+tslib@^1.9.3:
+  version "1.9.3"
+  resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
+
 tslint-loader@^3.5.3:
   version "3.6.0"
   resolved "https://registry.yarnpkg.com/tslint-loader/-/tslint-loader-3.6.0.tgz#12ed4d5ef57d68be25cd12692fb2108b66469d76"