typescript - Angular2 'recompile' 慢。 Visual Studio 2015。任务运行程序。 typescript

标签 typescript visual-studio-2015 angular task-runner-explorer

问题:在 Web 浏览器刷新并显示更改之前,对我的 Angular2 项目 Typescript 文件进行任何更改(包括仅添加空格)需要将近 3 分钟的时间来“重新编译”。这会减慢整体发展速度。

Background:
    Using Visual Studio 2015 running on Amazon WorkSpace with 2 cores and 8GB of memory. 
    Using Task Runner Explorer (start from package.json).
    Created a dummy project with source code from
        angular.io (Heros project).
        todomvc.com (ToDo list).
        and dummy Test component.


This is a tiny project, but still takes almost 3 minutes to 'recompile'. Below is the Task Runner log showing that it takes almost 3 minutes to 'recompile' even though i only added a single space to heroes.component.ts file.
By comparison, I have an asp.net project on the same machine (vb.net) with hundreds of files and it compiles in seconds.

I tried disabling Trend Micro real time virus scanner but that didn't seem to have any effect.

Question: Is this normal behavior?! How can I get this running fast?

[0] 13:11:07 - File change detected. Starting incremental compilation...
[1] [BS] File changed: app\dashboard.component.js
[1] [BS] File changed: app\hero-detail.component.js
[1] [BS] File changed: app\todo.store.js
[1] [BS] File changed: app\todo.component.js
[0] 13:11:17 - Compilation complete. Watching for file changes.
[1] [BS] File changed: app\test.component.js
[1] [BS] File changed: app\app.component.js
[1] [BS] File changed: app\main.js
[1] 16.02.29 13:11:07 304 GET /index.html
[1] 16.02.29 13:11:10 304 GET /styles.css
[1] 16.02.29 13:11:14 304 GET /app/main.ts
[1] [BS] File changed: app\hero.js
[1] [BS] File changed: app\mock-heroes.js
[1] [BS] File changed: app\hero.service.js
[1] [BS] File changed: app\dashboard.component.js
[1] [BS] File changed: app\hero-detail.component.js
[1] [BS] File changed: app\heroes.component.js
[1] 16.02.29 13:11:20 304 GET /app/app.component.ts
[1] [BS] File changed: app\todo.component.js
[1] [BS] File changed: app\todo.store.js
[1] [BS] File changed: app\test.component.js
[1] [BS] File changed: app\app.component.js
[1] [BS] File changed: app\main.js
[1] 16.02.29 13:11:23 304 GET /app/hero.service.ts
[1] 16.02.29 13:11:23 304 GET /app/dashboard.component.ts
[1] 16.02.29 13:11:24 304 GET /app/hero-detail.component.ts
[1] 16.02.29 13:11:24 304 GET /app/todo.component.ts
[1] 16.02.29 13:11:24 304 GET /app/todo.store.ts
[1] 16.02.29 13:11:26 304 GET /index.html
[1] 16.02.29 13:11:27 304 GET /app/test.component.ts
[1] 16.02.29 13:11:27 304 GET /app/mock-heroes.ts
[1] 16.02.29 13:11:29 304 GET /styles.css
[1] 16.02.29 13:11:33 304 GET /app/main.ts
[1] 16.02.29 13:11:38 304 GET /app/app.component.ts
[1] 16.02.29 13:12:25 304 GET /app/hero.service.ts
[1] 16.02.29 13:12:25 304 GET /app/dashboard.component.ts
[1] 16.02.29 13:12:27 304 GET /app/hero-detail.component.ts
[1] 16.02.29 13:12:27 304 GET /app/todo.component.ts
[1] 16.02.29 13:12:43 304 GET /app/todo.store.ts
[1] 16.02.29 13:12:44 200 GET /app/heroes.component.ts
[1] 16.02.29 13:12:45 200 GET /app/test.component.ts
[1] 16.02.29 13:12:46 200 GET /app/mock-heroes.ts
[1] 16.02.29 13:13:11 304 GET /app/app.component.css
[1] 16.02.29 13:13:45 304 GET /app/dashboard.component.html
[1] 16.02.29 13:13:58 304 GET /app/dashboard.component.css

最佳答案

仔细检查您是否已在项目中正确设置“排除”目录。我的猜测是 Visual Studio 正在尝试转换所有内容。

您的 Typescript 目录中应该有一个 tsconfig.json 文件。它应该看起来像这样:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": false,
    "target": "es5",
    "module": "commonjs",
    "outDir": "../wwwroot/app/",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

另外,请注意 outDir 是被排除的目录之一。

关于typescript - Angular2 'recompile' 慢。 Visual Studio 2015。任务运行程序。 typescript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35709080/

相关文章:

angular - 如何使用路由参数作为服务方法的参数?

typescript - 通过类型定义非空列表

c++ - 在 Linux 中创建的包含 make 文件的 Visual Studio 2015 中编译 C++ 项目

angular - 如何在Angular的自定义控件组件中触摸内部控件?

angular - 如何使用 angular 和 typescript 从 .graphql 文件加载查询

c++ - 使用 stackoverflow 错误初始化数组

c++ - 从 MSVC2015 更新 2 移植到 GCC 5.3 - SFINAE 错误

android - 服务通知 channel 无效 : Notification

Angular 2 : Watch an external variable outside of angular

css - ng-select Angular2面板透明