TypeScript-Kompilierung extrem langsam> 12s

Setzen Sie dies nur da draußen, um zu sehen, ob jemand anderes dieses Problem hat ...

Ich habe eine eckige 2-App mit Typoskript unter Verwendung von Webpack als Build-Tool erstellt. Alles funktioniert einwandfrei. Ich habe jedoch festgestellt, dass die Typoskript-Kompilierung sehr langsam ist. Ich bin gerade bei 12 Sekunden ist alles auf den Typoskript-Kompilierungsprozess zurückzuführen ....

Ich habe ts-loader oder awesome-typescript-loader mit einem ähnlichen Ergebnis verwendet. Wenn ich diesen Loader auskommentiere, sinkt meine Build-Zeit auf ungefähr 1 Sek. ....

Nach einigem Nachforschen scheint es, als ob es "normal" wäre, "langsame" Zeiten beim Kompilieren von Typoskripten zu haben, aber 12 Sekunden sind das normale ??

Altere Beiträge wiesen darauf hin, dass dies möglicherweise auf einen Knotenversionskonflikt zurückzuführen ist. Derzeit wird Version 4.4.2 ausgeführt.

Wie weiter unten steht mein Webpack-Code, falls jemand etwas falsch findet. Der kommentierte Code im Abschnitt "Uglify" ist auf einen "Bug" auf der eckigen 2-Seite zurückzuführen.

const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');

const NpmInstallPlugin = require('npm-install-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TARGET = process.env.npm_lifecycle_event;

const PATHS = {
  app: path.join(__dirname, 'app'),
  dist: path.join(__dirname, 'dist')
};

const common = {
  entry: {
    vendor: ['./app/vendor.ts'],
    main: ['./app/boot.component.ts']
  },
  output: {
    filename: '[name].[hash].bundle.js',
    path: PATHS.dist
  },
  resolve: {
    extensions: ['', '.js', '.ts']
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Qarrot Performance',
      template: 'index.template.ejs',
      commonStyles: [
        '/public/styles/vendor/normalize.css',
        '/public/styles/main.css'
      ],
      commonScripts: [],
      baseHref: '/',
      unsupportedBrowser: true,
      mobile: true,
      appMountId: 'app'
    }),
  ],
  module: {
    loaders: [
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        loaders: ['ts-loader']
      },
      {
        test: /\.scss$/,
        loader: 'raw-loader!sass-loader'
      },
      {
        test: /\.html$/,
        loader: "html"
      }
    ]
  }
}

// Dev Settings
if(TARGET === 'start' || !TARGET) {
  module.exports = merge(common, {
    devtool: 'eval-source-map',
    devServer: {
      contentBase: PATHS.build,
      historyApiFallback: true,
      hot: true,
      inline: true,
      progress: true,
      stats: 'errors-only',
    },
    plugins: [
      new webpack.HotModuleReplacementPlugin(),
      new NpmInstallPlugin({
        save: true
      })
    ]
  });
}

// Prod Settings
if(TARGET === 'build') {
  module.exports = merge(common, {
    devtool: 'cheap-module-source-map',
    plugins: [
      // new webpack.optimize.UglifyJsPlugin({
      //   beautify: false,
      //   mangle: false,
      //   compress : { screw_ie8 : true },
      //   comments: false
      // }),
      new webpack.optimize.DedupePlugin(),
      new webpack.DefinePlugin({
        'process.env.NODE_ENV': '"production"'
      }),
      new CopyWebpackPlugin([
            { from: 'public', to: 'public' }
      ]),
      new webpack.optimize.CommonsChunkPlugin({
        names: ['vendor', 'manifest']
      }),
    ]
  });
}

Ich bin auch auf einem Mac mit Angular 2 Beta.15 und Webpack-Version 1.12, unten ist meine tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "compileOnSave": false,
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage