Giter Site home page Giter Site logo

Duplicate of gulp-typescript about gulp-tsb HOT 9 CLOSED

jrieken avatar jrieken commented on June 6, 2024
Duplicate of gulp-typescript

from gulp-tsb.

Comments (9)

jrieken avatar jrieken commented on June 6, 2024

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.

ivogabe avatar ivogabe commented on June 6, 2024

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.

jrieken avatar jrieken commented on June 6, 2024

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.

ivogabe avatar ivogabe commented on June 6, 2024

@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.

djabraham avatar djabraham commented on June 6, 2024

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.

egamma avatar egamma commented on June 6, 2024

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.

jrieken avatar jrieken commented on June 6, 2024

@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.

ivogabe avatar ivogabe commented on June 6, 2024

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.

vvs avatar vvs commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.