Angular 2 Ahead-of-Time Compiler with gulp-typescript

前端 未结 3 1621
清歌不尽
清歌不尽 2021-02-03 11:45

Angular 2 rc 6 written in Typescript 2.0.2

I\'m trying to learn Ahead-of-Time compilation as outlined here. It seems simple enough:

3条回答
  •  一生所求
    2021-02-03 12:23

    I was trying to get this to work as well and William Gilmour's answer helped a lot.

    I extended it a little to run a local ngc installation (like the angular 2 example that runs the one in node_modules/.bin), and which works both on Linux and Windows systems:

    var exec = require('child_process').exec;
    var os = require('os');
    
    gulp.task('build-ts', function (cb) {
    
        var cmd = os.platform() === 'win32' ? 
            'node_modules\\.bin\\ngc' : './node_modules/.bin/ngc';
    
        exec(cmd, function (err, stdout, stderr) {
            console.log(stdout);
            console.log(stderr);
            cb(err);
        });
    });
    

提交回复
热议问题