ToddThomson / Ts2Js

A simple, fast, extendable Typescript compiler supporting incremental and type checking builds.
Other
1 stars 0 forks source link

Ts2Js only emits results of the ts.program root files? #5

Open seant-ca opened 7 years ago

seant-ca commented 7 years ago

In an effort to get a better understanding of what's happening under the hood, I started to examine the source code for Ts2Js, assuming that TsBundler and TsMinifier all rely on Ts2Js as a dependency.

in the Compiler.ts class file, I notice the emit method only iterates over the the file names specified as the program root file names, and to my understanding according to the TypeScript API these are the entry points into the application. My question is why are you not iterating over the entire list of source files form ts.program.getSourceFiles so that all the dependencies can be compiled as well? I believe TsBundler is supposed to compile dependencies as well?

I notice my output from TsMinifier results always shows only the entry file and this confused me because I assumed the dependencies would be minified as well? Maybe Ts.Bundler is doing additional work to compile and bundle dependencies that isn't happening in Ts2Js by default? I haven't gone through all of the source code but I thought I'd ask about this.

ToddThomson commented 7 years ago

@seansat Thank-you for your questions!

TsBundler, TsMinifier and Ts2Js are currently all currently works in progress. They are projects which resulted from a decoupling of the main features in TsProject. There are currently use cases that I haven't got to yet. The API's for each project is however not pretty much fixed.

TsMinifier can minify a set of files ( or a single file ) or files within a ts.program context or typescript project.

TsBundler does not care about the "intermediate" compiled project files and only focuses on the final single file typescript file that is generated and then compiled and minified.

Ts2Js should compile all files in the program or project context. I will review this. TsMinifer should also minify all the files within a ts.program or typescript project context. I will review this.

ToddThomson commented 5 years ago

@seant-ca Added to production milestone Ts2Js Release 3.0