Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow compilation with allowJs #10157

Closed
normalser opened this issue Aug 4, 2016 · 6 comments
Closed

Very slow compilation with allowJs #10157

normalser opened this issue Aug 4, 2016 · 6 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@normalser
Copy link

normalser commented Aug 4, 2016

TypeScript Version: 2.1.0-dev.20160803

Trying to migrate medium size js project to ts so I am using allowJs: true in tsconfig.json and have mix of ts (10%) and js (90%) files already

Unfortunately compilation time with allowJs:true is 23 seconds while with allowJs:false is 3 seconds.

Problem seems to be that all js files follow the node_modules ("moduleResolution": "node" in tsconfig.json)

Is there any way to have moduleResolution:classic for JS part while node for TS or some other way to configure the project so that js files are not so deeply analyzed.

Here are the stats:

with allowJs:true

time tsc -p . --traceResolution | wc -l
  154171
tsc -p . --traceResolution  23.37s
time tsc -p . --traceResolution | grep node_modules | wc -l
  148740
tsc -p . --traceResolution  23.41s

with allowJs:false

time tsc -p . --traceResolution | wc -l
  1498
tsc -p . --traceResolution  3.03s
time tsc -p . --traceResolution | grep node_modules | wc -l
  1392
tsc -p . --traceResolution  3.02s
@robmcm
Copy link

robmcm commented Nov 24, 2016

On a similar note, would it be possible to have a different config for JS files? That way you could not only change "moduleResolution" but also properties like "allowUnreachableCode".

Ideally for JS that is being migrated I don't want any compiler linting. I have tried using two instances of TS webpack loaders to handle JS and TS separately, but with no luck.

@abobwhite
Copy link

I am using TypeScript with webpack and I can't even get the app to run locally with allowJS because it just takes so long. I am struggling with finding a way to slowly convert my project to TS to have both JS and TS at the same time. I was able to use babel with the JS separately for my app to run but the testing is all out of sorts and can't figure it out. I figured allowJS would be the golden ticket but so far, it's unusable.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 27, 2017

@abobwhite do you see the same behavior running outside of webpack (i.e. tsc --p tsconfig.json)? can you share the otuput of tsc --diagnostics --p ..?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 27, 2017

Also one common issue we see is excluded files. with --allowJs the compiler will grok your folder for .js files, that might include .js files you did not care about, tsc --listFiles should list the files the compiler is consuming.

@abobwhite
Copy link

Thanks @mhegazy Your comments helped point me in a slightly different direction. It turns out it was a ts-loader setting I needed. I needed to set transpileOnly to true on the processing of my .js files. All the type checking on the .js files was causing it to take 2-3 minutes.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Apr 27, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 22, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed May 22, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants