Comments (9)
Feel free to take inspiration from the work here. The difference is -as you have pointed out- in how incremental changes are handled. From my understanding, gulp-typescript always starts a fresh compile (createProgram) when something has changed - even a comment. In contrast, we implement the following strategy:
(1) when a file changes only reemit that file* (generate js
and d.ts
files)
(2) perform syntax and semantic checks for changed files only
(3) check if the 'shape' of a changed file changed - changing a local variable vs changing an exported variable
(3.1) If no shape changes -> done
(3.2) Else If external modules are used traverse the dependency graph in reverse order and only perform a semantic check on them
(3.3) Else If internal modules are used perform a semantic check on all files
With this approach we achieve an average code emit/validate time of ~1second for a code base with more than 1000 files - it obviously depends on what the change. I am pessimistic if gulp-typescript achieves this performance because it is not incremental. The main differences are:
- use of language service api vs compiler api
- incremental behaviour vs starting over again
In summary, I think this justifies having two implementations. gulp-typescript is for sure correct wrt enums but gulp-tsb is fast.
*With respect to enums and inlining their const values you are correct. There is simple trick to prevent that from happening (a97becb) and according to the TS team this shouldn't be an issue anymore with 1.5. I have to confirm the latter tho. And even if and if inlined enums are desired there are ways of knowing where enums are defined and used.
from gulp-tsb.
gulp-typescript does support incremental compilation, by calling createProject
outside of the task, just like your plugin. That gives a big increase in performance. The compiler api does support incremental compilation. Your step 3 is handled by TypeScript in gulp-typescript, it feels a bit unsafe for me to implement my own logic for that.
I'm looking to implement single file compilation in gulp-typescript, that's new in TS1.5. That will disallow all unsafe features. I think that will result in a very big performance boost and it remains safe.
from gulp-tsb.
Yes - I am eager to see what is going to be possible with 1.5. Go ahead and take the lead on that and if it fits our perf requirements I am happy to give up this project.
from gulp-tsb.
@jrieken Can you take a look at ivogabe/gulp-typescript#130? Note that you will have to use gulp-plumber and TypeScript 1.5-alpha or newer. Currently you'll see lots of errors, but that will be fixed in TypeScript 1.5.
from gulp-tsb.
I was doing a code merge to demonstrate a classic pattern to some guys who never used a packager before, when I noticed that I was only getting only the changed file in the output. No big deal, just though you might want to know it was a little confusing in that particular non-optimal scenario.
Don't know if you intend to continue with this or not, but I learned a hell of a lot about how the typescript compiler works, just by studying this effort. I was trying to do use ts-services on something else a while back, when I first encountered this, and there was not a lot of info on it then.
Thanks for this great project!
from gulp-tsb.
Don't know if you intend to continue with this or not, but I learned a hell of a lot about how the typescript compiler works, just by studying this effort.
Actually, we are using gulp-tsc to build microsoft/vscode, so we have a lot of interest in this module to make it good and fast.
from gulp-tsb.
@ivogabe Does gulp-typescript already make use of the compiler API, introduced with 2.7, which allows for fast and incremental compiles? We have the code changes for that in master and have dropped our custom reconcile logic. Given that gulp-tsb lost its beef by that I am willing to retire it - assuming gulp-typescript is now incremental and fast?
from gulp-tsb.
gulp-typescript still uses the old incremental api, I didn’t have time to update to the new api yet. I think that I can implement it in april, I have a free week then.
from gulp-tsb.
Hi @jrieken and @ivogabe, do you have any news w.r.t. gulp-typescript
using the new compiler API to speed up the incremental compilation (in watch mode).
The reason I am asking is because in our project we are struggling with long incremental compilations, which are getting worse as project grows.
We do use gulp-typescript's incremental compilation approach (project outside of the task), but he speedup, while there, is not huge, about 25-30% faster as compared to the full re-compilation, which is still quite long. Basically, full recompilation after a single file change is quite painful.
So, the question is what to do: try to switch to gulp-tsb or maybe there is some magic bullet in the works for gulp-typescript (maybe new Compiler API would improve things significantly)?
Thanks!
from gulp-tsb.
Related Issues (20)
- tsconfig.json lib option doesn't work on windows HOT 1
- gul-tsb fails with @types if tsconfig.json in sub directories HOT 6
- can not compile project with es5 library on Windows HOT 1
- Error out on TypeScript error HOT 2
- Request/favor - could the code be modularized to decouple from Gulp HOT 4
- Update for TypeScript 2.4.1 Module Resolution Changes HOT 1
- Generating source maps? HOT 2
- Subtle errors in options passed to tsb.create() are ignored (not reported)
- Documentation: explain how sourceMaps should work
- Documentation: readme should show option of passing a tsconfig.json file as input
- Confusion between libraries and local files HOT 3
- Initial build includes inputted files but not resolved files HOT 4
- Don't force declarations=true HOT 1
- New Release/Update vinyl dependency to >= 0.5.3 HOT 1
- Does not respect baseUrl compilerOption
- gulp-tsb@3 refuses to output js files with allowJs
- Version mismatching
- Tag new version (4.0.5) HOT 3
- Build with latest typescript throws errors HOT 1
- Please provide tags HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-tsb.