title: Cannot read property 'externalModuleIndicator' of undefined while running unit test using karma and webpack 4
body: <p>After upgrading my angular project with webpack 4 I am getting below error while running unit test using karma </p>
  
  <blockquote>
    <p>[at-loader] Using typescript@2.7.2 from typescript and "tsconfig.json"
    from demo-app-app\src\tsconfig.json.</p>
    
    <p>[at-loader] Checking started in a separate process...</p>
    
    <p>[at-loader] Checking finished with 1509 errors
    [at-loader]: Child process failed to process the request:  TypeError: Cannot 
    read property 'externalModuleIndicator' of undefined
     at Object.isExternalModule
    (demo-app\node_modules\typescript\lib\typescript.js:13733:20)  at
    Object.getAllDependencies
    (demo-app\node_modules\typescript\lib\typescript.js:75788:46)  at
    Object.getAllDependencies
    (demo-app\node_modules\typescript\lib\typescript.js:76133:80)  at
    processEmit
    (demo-app\node_modules\awesome-typescript-loader\src\checker\runtime.ts:451:24)
    at
    demo-app\node_modules\awesome-typescript-loader\src\checker\runtime.ts:602:6
    at Object.send
    (demo-app\node_modules\awesome-typescript-loader\src\checker\runtime.ts:48:6)
    at Checker.req
    (demo-app\node_modules\awesome-typescript-loader\src\checker\checker.ts:100:15)
    at Checker.emitFile
    (demo-app\node_modules\awesome-typescript-loader\src\checker\checker.ts:105:15)
    at transform
    (demo-app\node_modules\awesome-typescript-loader\src\index.ts:132:26) 
    at transformationFunction
    (demo-app\node_modules\awesome-typescript-loader\src\index.ts:74:40) 
    at compiler
    (demo-app\node_modules\awesome-typescript-loader\src\index.ts:85:21) 
    at Object.loader
    (demo-app\node_modules\awesome-typescript-loader\src\index.ts:16:12) 
    at LOADER_EXECUTION
    (demo-app\node_modules\loader-runner\lib\LoaderRunner.js:119:14)  at
    runSyncOrAsync
    (demo-app\node_modules\loader-runner\lib\LoaderRunner.js:120:4)  at
    iterateNormalLoaders
    (demo-app\node_modules\loader-runner\lib\LoaderRunner.js:229:2)  at
    iterateNormalLoaders
    (demo-app\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
        &lt;--- Last few GCs ---></p>
    
    <p>136168 ms: Mark-sweep 1255.3 (1435.8) -> 1242.3 (1435.8) MB, 893.2 /
    0.0 ms [allocation failure] [GC in old space requested].   137084 ms: Mark-sweep 1242.3 (1435.8) -> 1242.3 (1435.8) MB, 915.6 / 0.0 ms
    [allocation failure] [GC in old space requested].   138055 ms:
    Mark-sweep 1242.3 (1435.8) -> 1248.2 (1408.8) MB, 970.0 / 0.0 ms [last
    resort gc].   139026 ms: Mark-sweep 1248.2 (1408.8) -> 1254.0 (1408.8)
    MB, 971.0 / 0.0 ms [last resort gc].</p>
    
    <p>&lt;--- JS stacktrace ---></p>
    
    <p>==== JS stack trace =========================================</p>
    
    <p>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap
    out of memory</p>
  </blockquote>
  
  <p>Package Json:</p>
  
  <blockquote>
    <p>awesome-typescript-loader:5.0.0-0
    karma-webpack:2.0.4
    webpack:4.1.1</p>
  </blockquote>
  
  <pre><code>var webpack = require('webpack');
  var helpers = require('./helpers');
  
  module.exports = {
      devtool: 'inline-source-map',
  
      resolve: {
          extensions: ['.ts', '.js']
      },
  
      mode: 'development',
  
      module: {
          loaders: [
              {
                  test: /\.ts$/,
                  loaders: ['awesome-typescript-loader', 'angular2-template-loader']
              },
              {
                  test: /\.html$/,
                  loader: 'html-loader'
  
              },
              {
                  test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
                  loader: 'null'
              },
              {
                  test: /\.css$/,
                  include: helpers.root('src', 'app'),
                  loader: 'raw'
              },
              {
                 enforce: 'post',
                 test: /\.(js|ts)$/,
                 loader: 'istanbul-instrumenter-loader',
                 include: helpers.root('src'),
                 exclude: [
                   /\.(e2e|spec)\.ts$/,
                   /node_modules/
                 ]
              }
          ]
      },
  
      plugins: [
          new webpack.ContextReplacementPlugin(
            /angular(\\|\/)core(\\|\/)@angular/,
            helpers.root('./src'),
            {}
          )
      ]
  };
  </code></pre>
  
  <p>Please note that I am able to run my angular project without any issue only UT configuration are giving errors.</p>