2016-05-04 5 views
7

ちょうど他の誰かがこの問題を持っているかどうかを確認するためにそこにこれを入れて...私は私のビルドツールとしてのWebPACKを使用してtypescriptですと角度2アプリケーションを構築してきた活字体のコンパイル非常に遅い> 12S

、すべてがうまく機能しかし、私はtypescriptコンパイルがsuper super slowであることに気がつきました。私は今12秒です。....そして、そのすべてはtypescriptコンパイルプロセスによるものです。

私はts- loader、またはawesome-typescript-loaderと同様の結果を返します。このローダーをコメントアウトすると、ビルド時間は約1秒に減少します。

研究では、タイプスクリプトをコンパイルするときに「通常の」時間が「遅い」ように見えますが、通常の12秒ですか?

オールド・ポストは、それが原因ノードのバージョンの競合にあるかもしれない示唆、私は現在...

をv4.4.2を実行している任意の方法を以下の私のWebPACKコードは、誰もが何か間違って...コメントコードをスポット場合であり、 Uglifyセクションで

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'] 
     }), 
    ] 
    }); 
} 

私は角2 beta.15とWebPACKのバージョン1.12を実行し、Mac上でも午前...角度2側にいくつかの「バグ」が原因で、以下の私の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" 
    ] 
} 

答えて

-1

あなたに共有してくださいtsconfig.json。ほとんどの場合、noEmitOnErrortrueに設定されています。つまり、コンパイラはがコードベース全体の型チェックを強制的に行うことを意味します。

falseに設定してください。

+0

あなたの提案に感謝します。私は私のtsconfigで質問を更新しました...私はそのオプションセットを持っていませんでしたが、私はそれを追加しても大きな影響はありませんでした... –

2

私はawesome-typescript-loaderに固執します。キャッシングオプションとトランスカリオプションのみ:

"awesomeTypescriptLoaderOptions": { 
    "useCache": true, 
    "transpileOnly": true 
} 

これらの両方でコンパイル時間が大幅に改善されました。