Reputation: 1031
Is there a way to create non-anonymous AMD Modules in Typescript. When I define a module like this:
export module Bootstrapper {
export function run() {
var i = 0;
}
}
the generate code is:
define(["require", "exports"], function(require, exports) {
(function (Bootstrapper) {
function run() {
var i = 0;
}
Bootstrapper.run = run;
})(exports.Bootstrapper || (exports.Bootstrapper = {}));
})
How can I define a non-anomymous module like this:
define('bootstrapper', ["require", "exports"], function(require, exports) {
(function (Bootstrapper) {
function run() {
var i = 0;
}
Bootstrapper.run = run;
})(exports.Bootstrapper || (exports.Bootstrapper = {}));
})
Upvotes: 10
Views: 730
Reputation: 26321
This feature was recently added to the TypeScript master branch via this pull request. Declaring an AMD module name is with the following reference comment:
/// <amd-module name='MyModuleName'/>
will produce the following JavaScript:
define("MyModuleName", ["require", "exports"], function (require, exports) { ... }
Upvotes: 6
Reputation: 3722
As of TS 0.9.x it is not possible to name an AMD module. The TS compiler will only generate a define statement in the format
define( ['dep1', 'dep2', ..., 'depN'], function( __dep1__, __dep2__, ..., __depN__ ) {... } );
discussion on the TS forums : https://typescript.codeplex.com/discussions/451454
Upvotes: 1
Reputation: 12414
As you can see in the file emitter.ts at line 1202 (make a search for " var dependencyList = "
) there is no implementation for it.
You can open an issue on codeplex about it.
Upvotes: 2