title: webpack typescript production build fails
body: <p>So basicly I decided to introduce typescript to our react project and the build got issues with resolving imports not specifying the .ts / .tsx extensions so I decided to add the ts-loader to our webpack configuration and it stopped working.</p>
  
  <pre><code>const nodeExternals = require('webpack-node-externals');
  const paths = require('../config/paths');
  const publicPath = paths.servedPath;
  const webpack = require('webpack');
  const GitRevisionPlugin = require('git-revision-webpack-plugin');
  const gitRevisionPlugin = new GitRevisionPlugin({
    versionCommand: 'describe --always --tags',
  });
  
  module.exports = {
    mode: 'production',
    bail: true,
    entry: [require.resolve('@babel/polyfill'), paths.appServerJs],
    externals: [nodeExternals()], 
    target: 'node',
    output: {
      // The build folder.
      path: __dirname + '/dist',
      filename: 'loader.js',
      publicPath: publicPath,
      libraryTarget: 'commonjs2'
    },
    plugins: [
      gitRevisionPlugin,
      new webpack.DefinePlugin({
        __BUILD_VERSION__: JSON.stringify(gitRevisionPlugin.version())
      })
    ],
    module: { 
      rules: [
        {
          test: /\.(js|jsx)$/,
          use: 'babel-loader',
          exclude: /node_modules/
        },
        {
          test: /\.ts(x)?$/,
          use: [
            'awesome-typescript-loader'
          ],
          exclude: /node_modules/
        },
        {
          test: /\.css$/,
          loader: 'css-loader'
        },
        {
          test: /\.scss$/,
          loader: 'null-loader'
        },
        {
          test: /\.(gif|jpe?g|png|ico)$/,
          loader: 'url-loader?limit=10000'
        },
        {
          test: /\.(otf|eot|svg|ttf|woff|woff2).*$/,
          loader: 'url-loader?limit=100000'
        },
      ]
    },
    resolve: {
      modules: [paths.appSrc, paths.appServer],
      extensions: ['.ts', '.tsx', '.js', '.jsx']
    }
  };
  </code></pre>
  
  <p>tsconfig.json:</p>
  
  <pre><code>{
      "compilerOptions": {
        "target": "es5",
        "lib": [
          "dom",
          "dom.iterable",
          "esnext"
        ],
        "noImplicitAny": false,
        "strictNullChecks": true,
        "skipLibCheck": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "noEmit": false,
        "esModuleInterop": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "allowSyntheticDefaultImports": true,
        "jsx": "react"
      },
      "exclude": [
        "node_modules"
      ],
      "include": [
        "next-env.d.ts",
        "**/*.ts",
        "**/*.tsx",
      ]
    }
  </code></pre>
  
  <p>Babelrc:</p>
  
  <pre><code>{
    "compact": true,
    "presets": [
      [
        "@babel/preset-env",
        {
          "modules": false
        }
      ],
        "@babel/preset-react"
    ]
  }
  </code></pre>
  
  <p>The error I am getting when building is: </p>
  
  <pre><code>/app/prod_node_modules/@babel/preset-typescript/test/fixtures/flow-compat/ts-invalid/input.ts
  TypeScript error in /app/prod_node_modules/@babel/preset-typescript/test/fixtures/flow-compat/ts-invalid/input.ts(1,13):
  Property or signature expected.  TS1131
  
    &gt; 1 | type Foo = {||};
        |             ^
      2 | 
      3 | foo;
      4 |
  </code></pre>
  
  <p>Am I missing something? I initialize the build by the following commands: </p>
  
  <pre><code>"build:server": "webpack --config ./server/webpack.config.prod.js",
  </code></pre>