title: Configuring webpack for node TS with lerna subpackages
body: <p>I have the following structure (lerna based):</p>
  
  <pre><code>app/
    packages/
      core/
        index.ts
        src/
          server.ts
        node_nodules/
          ...
          express/
      auth/
        ...
  </code></pre>
  
  <p><strong>index.ts</strong></p>
  
  <pre><code>import { Server } from './src/server';
  
  new Server()
  
  console.log('test');
  </code></pre>
  
  <p><strong>src/server.ts</strong></p>
  
  <pre><code>import * as express from 'express';
  
  export class Server {
  
    private app: express.Application
  
    constructor() {
      this.init();
      this.bootstrap();
    }
  
    init(): void {
      this.app = express();
      this.app.get('/', (req, res, next) =&gt; {
        res.send("Hello world");
        next();
      });
    }
  
    bootstrap(): void {
      const PORT = 3000;
      this.app.listen(PORT, () =&gt; {
        console.log(`Express server listening on port ${PORT}.\nEnvironment: ${process.env.NODE_ENV}`)
      });
    }
  }
  </code></pre>
  
  <p>I am trying to compile typescript code with webpack, here is my config file:</p>
  
  <p><strong>webpack.config.js</strong></p>
  
  <pre><code>const path = require('path');
  const CleanWebpackPlugin = require('clean-webpack-plugin');
  
  module.exports = {
    target: 'node',
    entry: {
      app: './packages/core/index.ts'
    },
    devtool: 'inline-source-map',
    plugins: [
      new CleanWebpackPlugin(['dist']),
    ],
    resolve: {
      extensions: ['.ts', '.tsx', '.js'],
      modules: ['node_modules']
    },
    module: {
      rules: [{
        test: /\.ts|\.tsx$/,
        include: ['packages/**/src'],
        use: [{
          loader: 'awesome-typescript-loader',
          options: {
              configFileName: 'tsconfig.json',
              sourceMap: true
          },
        }],
      }],
    },
  };
  </code></pre>
  
  <p><strong>tsconfig.json</strong></p>
  
  <pre><code>{
    "compilerOptions": {
      "allowSyntheticDefaultImports": true,
      "declaration": false,
      "emitDecoratorMetadata": true,
      "strictNullChecks": false,
      "noImplicitAny": true,
      "removeComments": true,
      "experimentalDecorators": true,
      "lib": [
        "dom",
        "es2015",
        "esnext.asynciterable"
      ],
      "module": "es2015",
      "moduleResolution": "node",
      "sourceMap": true,
      "target": "es5"
    },
    "include": [
      "packages/**/*.ts"
    ],
    "exclude": [
      "node_modules",
      "./packages/**/node_modules",
      "./packages/**/*.spec.ts",
      "e2e"
    ],
    "compileOnSave": false,
    "atom": {
      "rewriteTsconfig": false
    }
  }
  </code></pre>
  
  <p>but when running <code>webpack</code> I get the following:</p>
  
  <pre><code>➜  app git:(master) ✗ npm run build
  
  &gt; app-core@0.0.1 build /home/dev/app
  &gt; webpack --mode development
  
  clean-webpack-plugin: /home/dev/app/dist has been removed.
  Hash: a2cdfcfd39d5692648d6
  Version: webpack 4.1.0
  Time: 80ms
  Built at: 2018-3-7 10:50:04
   Asset      Size  Chunks             Chunk Names
  app.js  7.83 KiB     app  [emitted]  app
  Entrypoint app = app.js
  [./packages/core/index.ts] 80 bytes {app} [built]
  [./packages/core/src/server.ts] 218 bytes {app} [built] [failed] [1 error]
  
  ERROR in ./packages/core/src/server.ts
  Module parse failed: Unexpected token (5:10)
  You may need an appropriate loader to handle this file type.
  | export class Server {
  | 
  |   private app: express.Application
  | 
  |   constructor() {
   @ ./packages/core/index.ts 1:0-38 3:4-10
  npm ERR! code ELIFECYCLE
  npm ERR! errno 2
  npm ERR! app@0.0.1 build: `webpack --mode development`
  npm ERR! Exit status 2
  npm ERR! 
  npm ERR! Failed at the app-core@0.0.1 build script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  </code></pre>