title: Reading NodeJS process.argv in webpack compiled JavaScript
body: <p>I'm trying to compile a simple TS file with webpack (via 'awesome-typescript-loader') that should read command line arguments.</p>
  
  <p>However, I believe the compiled JS is redefining the Node 'process' variable with a closure - making process.argv 'undefined'.</p>
  
  <p><strong>TL;DR</strong>: How do I read command line arguments with webpack-compiled JS?</p>
  
  <h2>a.ts</h2>
  
  <pre><code>console.log(process.argv[2]);
  </code></pre>
  
  <h2>webpack.config.js</h2>
  
  <pre><code>const path = require('path');
  
  module.exports = {
      resolve:{
        extensions: ['.ts']
      },
      module: {
        rules: [{
            test: /\.ts$/,
            loaders: ['awesome-typescript-loader'],
            include: [
                path.resolve(__dirname, "src")
            ]
        }]
      },
      entry: {
          a: "./src/a.ts"
      },
      output: {
          path: path.resolve(__dirname, 'output'),
          filename: '[name].js'
      }
  };
  </code></pre>
  
  <h2>package.json</h2>
  
  <pre><code>{
    "name": "my-proj",
    "version": "1.0.0",
    "description": "some purpose",
    "scripts": {
      "start:a": "rimraf output/a.js &amp; webpack --watch &amp;&amp; node output/a.js myarg",
      "lint": "tslint \"src/*.ts\"",
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "keywords": [
      "javascript",
      "node"
    ],
    "author": "some guy",
    "license": "ISC",
    "dependencies": {
      "@types/lodash": "^4.14.56",
      "core-js": "^2.4.1",
      "lodash": "^4.17.4",
      "mathjs": "^3.10.0",
      "path": "^0.12.7",
      "rxjs": "^5.2.0",
      "ts-loader": "^2.0.2",
      "typings": "^2.1.0",
      "yargs": "^7.0.2"
    },
    "devDependencies": {
      "@types/node": "^7.0.8",
      "awesome-typescript-loader": "^3.1.2",
      "compression-webpack-plugin": "^0.3.2",
      "concurrently": "^3.4.0",
      "copy-webpack-plugin": "^4.0.1",
      "cross-env": "^3.2.4",
      "external-loader": "^0.1.1",
      "extract-text-webpack-plugin": "^2.1.0",
      "file-loader": "^0.10.1",
      "nodemon": "^1.11.0",
      "null-loader": "^0.1.1",
      "raw-loader": "^0.5.1",
      "rimraf": "^2.6.1",
      "tslint": "^4.5.1",
      "typescript": "^2.2.1",
      "webpack": "^2.2.1",
      "webpack-merge": "^4.1.0"
    }
  }
  </code></pre>
  
  <blockquote>
    <p>For building without script simply run: <strong>"webpack"</strong>, go to output folder, and run <strong>"node a.js myarg"</strong></p>
  </blockquote>