title: Webpack worker-loader fails to compile typescript worker
body: <p>I am configuring my project as described in <a href="https://github.com/webpack-contrib/worker-loader" rel="noreferrer">worker-loader</a> documentation and I was able to get TS code intel working using the correct d.ts.</p>
  
  <p>However, during webpack build it throws an error and I don't understand why.</p>
  
  <pre><code> ERROR in ./src/test.worker.ts
  Module parse failed: Unexpected token (1:9)
  You may need an appropriate loader to handle this file type.
  | const ctx: Worker = self as any;
  | ctx.addEventListener('message', event =&gt; {
  |   console.log(event);
  </code></pre>
  
  <p>My worker file content <code>test.worker.ts</code>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const ctx: Worker = self as any;
  ctx.addEventListener('message', event =&gt; {
    console.log(event);
    setTimeout(() =&gt; ctx.postMessage({
      foo: 'boo'
    }), 5000);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Application entry <code>index.ts</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import TestWorker from './test.worker.ts';
  
  const test = new TestWorker();
  test.postMessage({});</code></pre>
  </div>
  </div>
  </p>
  
  <p>And finally here is my <code>webpack.config.js</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const path = require('path');
  const webpack = require('webpack');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  
  const DIR_SOURCE = path.resolve(__dirname, 'src');
  const DIR_BUILD = path.resolve(__dirname, 'build');
  
  module.exports = {
  
    entry: `${DIR_SOURCE}/index.tsx`,
  
    output: {
      path: DIR_BUILD,
      filename: 'project.bundle.js'
    },
  
    devtool: "source-map",
  
    resolve: {
      // Add '.ts' and '.tsx' as resolvable extensions.
      extensions: [".ts", ".tsx", ".js", ".json"]
    },
  
    module: {
      rules: [
        {test: /\.tsx?$/, loader: "ts-loader" },
        {test: /\.worker\.ts$/, use: ['ts-loader', 'worker-loader'] },
        {test: [/\.vert$/, /\.frag$/], use: 'raw-loader'},
        {test: /\.(png|jpg|gif|svg)$/, use: {loader: 'file-loader', options: {}} },
        {test: /.*\.sass/, use: ['style-loader', 'css-loader', 'sass-loader'] },
      ]
    },
  
    plugins: [
      new webpack.DefinePlugin({
        'CANVAS_RENDERER': JSON.stringify(true),
        'WEBGL_RENDERER': JSON.stringify(true)
      }),
      new HtmlWebpackPlugin({
        template: 'src/index.ejs'
      }),
    ]
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any help is much appreciated.</p>
  
  <p>Thank you :)</p>