2016-04-15 106 views
0

我是新来的打字稿及Angular2但工作...角2打字稿System.Src transpiler与gulptask

我的设置如下:

而是在站点根目录的应用程序文件夹中我有一个src \ app文件夹,然后在我的大量任务中编辑我的打字稿,如下所示:

gulp.task('copy:libs', ['clean'], function() { 
return gulp.src([ 
     'node_modules/es6-shim/es6-shim.min.js', 
     'node_modules/systemjs/dist/system-polyfills.js', 
     'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js', 
     'node_modules/angular2/bundles/angular2-polyfills.js', 
     'node_modules/systemjs/dist/system.src.js', 
     'node_modules/rxjs/bundles/Rx.js', 
     'node_modules/angular2/bundles/angular2.dev.js' 
    ]) 
    .pipe(gulp.dest(destination + '/js')); 

});

与目的:

const destination = './UI/assets'; 

罚款到目前为止,但现在到了棘手的部分:

在我的目的地+/app文件夹我得到的编译JavaScript文件,但在我的index.html使用它们时文件:

<script> 
    System.config({ 
     paths: { 
      'app/*': '/UI/assets/app/*' 
     }, 
    packages: { 
     app: { 
     format: 'register', 
     defaultExtension: 'js' 
     } 
    } 
    }); 
    System.import('app/main.js') 
     .then(null, console.error.bind(console)); 
</script> 

但系统SRC令我app.component这是在打字稿注册像这样的404个内部main.js:

从'./app.component'导入{AppComponent};

如果我更改为编译的app.component.js文件内的./app.component.js这是工作,但我该如何解决这个正确的方法!?

我的tsconfig直接从angular 2开始复制。

我的systemjs模块应该如何配置才能工作?现在它找不到任何js文件..

回答

0

我解决了这个问题。这主要是我缺少的baseURL:

<script> 
     System.config({ 
      baseURL : '/node_modules' 
     }); 
     System.defaultJSExtensions = true; 

     System.import('app/main.js') 
      .then(null, console.error.bind(console)); 
    </script>