Amd module with generate name for module ?

Topics: Code Checkins, General, Language Specification
Nov 15, 2012 at 8:25 AM
Edited Nov 15, 2012 at 8:27 AM

I have a typescript


export module MasterView {
	export function Init() {


It will generate


define(["require", "exports"], function(require, exports) {
    (function (MasterView) {
    })(exports.MasterView || (exports.MasterView = {}));


I want it to generate


define("ModuleName", ["require", "exports"], function(require, exports) {


Why i need to it, because i want to used with Mvc 4 Bundle to combine all js file and i don't want amd load mode request of javascript.

How can i generate a javascript with ModuleName ?

How about a singleton in typescript?. Please explain to me.

Thanks !

Nov 15, 2012 at 5:47 PM

The requirejs optimizer can transform your code into the define("ModuleName" ... syntax.  I take my typescript output and run it through the r.js optimizer.

See and for singleton approaches. Another method would be to use the global namespace and have a function to get the current instance if exists, otherwise create one and return it,

Nov 15, 2012 at 6:01 PM

>How about a singleton in typescript

Also you can use such way