angular-cli: ng lint 10x slower than direct tslint

OS?

OS X Sierra

Versions.

@angular/cli: 1.0.0-beta.31
node: 6.9.1
os: darwin x64
@angular/cli: 1.0.0-beta.31
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/compiler-cli: 2.4.7

Repro steps.

Using a reasonably large repo with these package.json scripts:

"lint": "ng lint",
"tslint": "tslint \"src/**/*.ts\"",

I get the following runtimes:

iDevBook01:console jr$ time npm run tslint

> meshstack-console@0.0.0 tslint /Users/jr/dev/console/console
> tslint "src/**/*.ts"

no-unused-variable is deprecated. Use the tsc compiler options --noUnusedParameters and --noUnusedLocals instead.

real	0m16.808s
user	0m17.005s
sys	0m0.748s

iDevBook01:console jr$ time npm run lint

> meshstack-console@0.0.0 lint /Users/jr/dev/console/console
> ng lint

no-unused-variable is deprecated. Use the tsc compiler options --noUnusedParameters and --noUnusedLocals instead.
All files pass linting.

real	1m49.394s
user	1m49.213s
sys	0m1.437s

The log given by the failure.

I have no idea why ng lint should take so absurdly long compared to vanilla tslint. I’m using the standard tslint.json generated by ng init and "codelyzer": "^2.0.0" (also tried with 2.0.0-beta.4, no change).

Mention any other details that might be useful.

Any idea where the difference comes from? Any input I can provide to debug this?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@filipesilva if you have the time to try, you can always experiment with a project like the one I’m working on (https://gitlab.com/linagora/petals-cockpit, run ng lint from the frontend directory) and compare with the tslint timings. There is a big difference:

$ time (tslint --project src/tsconfig.app.json --exclude "**/node_modules/**" && tslint --project e2e/tsconfig.e2e.json && tslint --project src/tsconfig.spec.json)
( tslint --project src/tsconfig.app.json --exclude "**/node_modules/**" &&   )  13,80s user 0,47s system 122% cpu 11,604 total
$ time ng lint
All files pass linting.
ng lint  26,58s user 0,30s system 106% cpu 25,280 total

@victornoel generally it’s discouraged to ship TypeScript with third party libraries because it would require the consumer to replicate the complete build environment of the library. Not only typings, but potentially a specific version of ngc as well.

Publishing plain JavaScript with typings and meta data allows the consuming application to remain agnostic of the library’s build environment.

@filipesilva thanks for detailed explanation 😃