Search code examples
typescriptgulpamd

Typescript, AMD and module names


Is there a way to set the names of the compiled modules from *.ts? Some tsconfig,json setting, or some Gulp pluggin that could do this.

Currently I'm getting

define([], function(){ .. })

But i wan't to be able to set the name like so:

define('module-name', [], function(){ .. })

Tried a few gulp pluggins but they overwrite the sourcemaps information and i loose the "ts debugging" ability in the browser


Solution

  • You can use a declaration at the top of your module to get the desired result:

    ///<amd-module name='foo-module'/>
    

    This will result in

    define('foo-module', [], function(){ .. })
    

    being emitted by the compiler