In short, releasing this lock will allow me to compile a project to single js file and then use this file as amd/commonjs external module.
Currently there is no support to create single js file and use external modules. To achieve this you must set –module to none, compile to single js file and remove all top export directives. After compiling you change output js file so that you manually add
code to export modules. In simple case when commonjs library has single root module, you just add something like this at the end:
exports.rootmodule = rootmodule;
On the import side you then use:
var __ rootmodule: typeof rootmodule = require("./rootmodule"). rootmodule;
Problem is that this statements can’t be used in all situations, for example it doesn’t work if you try to require path module in node. So you end up without type information. If you enable import as type annotation when –module is set to none you will be able
import _path = require("path");
var path: typeof _path = require("path");
For me this will be very helpful. In big project it is really difficult to maintain all those import paths. For example just renaming/moving file to other location may require a lot of changes in your code. Also I don’t feel very comfortable if I have to deploy
1000+ files, which should be no more than 10 js libraries. Also using single file for more classes it is not an option, I have tried this and is totally unmaintainable.
It would be great if tsc will allow to compile to single file with commonjs/amd support. Of course because project(all files) will have single js module output, you can force that all import/export directive must be used inside _references.ts.