title: Minification of internal typescript modules with webpack / uglifyJS
body: <p>My project is using internal typescript modules, it basically consists of one big module <code>project</code> with lots of sub modules <code>project.sub.etc</code>.
  With <code>tsc --out</code> this is compiled into a <code>bundle.js</code>, which when loaded automatically makes <code>project</code> available as a global variable.</p>
  
  <p>Now I want to minify my bundle. For the rest of the project I rely on webpack a lot, so I tried to setup a webpack config to minify the generated bundle. For that I used the uglyfiJS plugin which comes with webpack. However when I load the generated <code>bundle.min.js</code> <strong>the global module is not available in the global scope</strong>.</p>
  
  <pre><code>Uncaught ReferenceError: project is not defined
  </code></pre>
  
  <p>How come and how can I fix this?</p>
  
  <pre><code>var webpack = require("webpack");
  module.exports = {
      entry: "./builds/bndle.js",
      output: {
          path: "./builds",
          filename: "bundle.min.js"
      },
      plugins: [
          new webpack.optimize.UglifyJsPlugin({
              mangle:false
          })
      ]
  };
  </code></pre>
  
  <p>I already tried turning off mangling, because I thought that would change the name of the modules, but it didn't help.</p>
  
  <p>I also tried adding </p>
  
  <pre><code>output: {
     libraryTarget: "var",
     library: "Foo"
  }
  </code></pre>
  
  <p>to the webpack config. This gives me a globl <code>project</code> variable, but it is empty.</p>