Nov 22, 2012 at 10:22 PM
Edited Nov 22, 2012 at 11:30 PM
|
>It is probably important to produce multiple JavaScript (".js") files as output, rather than a single file
1) AMD idea is good but it is, in my opinion,
it is too idealistic idea (when each module loaded as separate file). Reason very simple - total time of loading of all files. So I'm doubt that somebody deploy project which
contains, for example, 100 not concatenated JS files.
So for me AMD is just way not write:
var myLib = myLib || {};
var myLib.view = myLib.view || {};
and so on.
I'm just place files in appropriate directories and "build system/compiler" do all job
for me.
2) >because of AMD reasons
Now, I use such way for TypeScript based projects: write TypeScript code => call TypeScript compiler (with --module amd) => in result I get separated JS files =>
pass these files to r.js => in result I have minified and combined single release .js file
Everything this occurs with help ANT.
If to look into such release .js file then there are constructions like:
define("myApp/view/MyListView",["require","exports"],function(e,t){var n=function().........),
define("myApp/view/MyOtherListView",["require","exports"],function(e,t){var n=function().........),
and so on.
I.e. r.js create named AMD modules.
Such pattern "file path equals class namespace" exists at least in Java and ActionScript. And when I open directory myApp/views and see there files View1.as, View2.as then I sure that file View1.as contains myApp.views.View1 class. And so on.
Similar thing make brunch.io.
==========
If to continue to dream about
TypeScript "library" then there is possible such way:
compile TypeScript library mean that TypeScript compiler create "library" files which contains something like:
var classes: any = {};
classes["myApp/view/ListView"] = 'define("myApp/view/MyListView",["require","exports"],function(e,t){var n=function().........)';
classes["myApp/view/MyOtherListView"] = 'define("myApp/view/MyOtherListView",["require","exports"],function(e,t){var n=function().........)';
.... // and so on
also such files should contains definitions (like in *.d.ts files) for inner classes/modules.
In result in my code I will just import "myApp/view/ListView" and use it,. And my application release file will contains only code related to "myApp/view/ListView" and will not contains code of all library.
But in order to implement this, TypeScript compiler should support "source path(s)".
Also it would be good to have ability to "exclude" some code from app release file.
>as well as any HTML and CSS files in the project
Mmm.. :) I'm doubt. Yes. I'm agree that this is cool ability (like single swf file with all resources) but it is, in my opinion,
beyond the scope of TypeScript.
=============
By the way, for admins: rich text editor have not "clear format" button
|