title: Invoke the text plugin from requirejs mapping
body: <p>I'm writing a web app using TypeScript, Backbone, and Mustache. I want to use Requirejs for dependency loading.</p>
  
  <p>I'm also using the Web Essentials visual studio plugin for TypeScript with the AMD compilation option turned on.  For those that are not familiar with this, it will wrap your type script file in an AMD module if you import external modules.
  For example:</p>
  
  <p>In type script I import the following modules in type definition files.</p>
  
  <pre><code>export import Backbone = module("Backbone"); 
  import mainTemplate = module("MainTemplate");
  </code></pre>
  
  <p>The output is something like: </p>
  
  <pre><code>define(["require", "exports", "Backbone", "MainTemplate"], function(require, exports, __Backbone__, __mainTemplate__) {
  //...code goes here ...
  });
  </code></pre>
  
  <p>For the template, I've declared the following in a type definition file:</p>
  
  <pre><code>declare module "MainTemplate" { }
  </code></pre>
  
  <p>In order to support requirejs plugins, you need to declare your module as:</p>
  
  <pre><code>declare module "text!MainTemplate.html" { }
  </code></pre>
  
  <p>I'd like to keep the module name free of plugins and file extensions. This would leave me with some flexibility in the future.</p>
  
  <p>I have the following mapping in require.</p>
  
  <pre><code>require.config({
      map: {
          "MyModule": {
              "MainTemplate": "text!MainTemplate.html"
          }
      }
  }
  </code></pre>
  
  <p>This successfully invokes the text plugin however, the plugin loads the wrong url. Sifting through the source code for the text plugin, I found that the following code is the culprit.</p>
  
  <pre><code>load: function (name, req, onLoad, config) {
    ...
    url = req.toUrl(nonStripName),
    //returns "scripts/**text!**MainTemplate.html**.html**"
    ...
  }
  </code></pre>
  
  <p>If I name the module, 'MainTemplate.html' it works fine but I'd like to keep the extension out of the module name.</p>
  
  <p>I've modified the text plugin with a simple regex replacement to strip out the plugin reference and the duplicate extension.</p>
  
  <p>Is there a better way to handle this?</p>