title: "Critical dependency: require function is used in a way in which dependencies cannot be statically extracted" with Webpack and typescript
body: <p>I am new to typescript as well as webpack programming, so please do not take for granted too much background... Also I saw many similar questions in stack overflow, none of the solutions until now solved my problem:</p>
  
  <p>I use vscode. My build produces the following warnings:</p>
  
  <pre><code>WARNING in ./src/amxcanvas.ts 3:24-31
  Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
  
  WARNING in ./src/amxmisc.ts 3:24-31
  Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
   @ ./src/amxcanvas.ts
  </code></pre>
  
  <p>As I get errors (module not found) when executing the resulting javascript code, I think that I should first get rid of these warnings.</p>
  
  <p>I use the following webpack.config.js:</p>
  
  <pre><code>var path = require("path");
  
  module.exports = {
    entry: path.join(__dirname, '/src', '/amxcanvas.ts'),
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          use: 'ts-loader',
          exclude: /node_modules/
        }
      ]
    },
    resolve: {
      extensions: [ '.tsx', '.ts', '.js' ]
    },
    output: {
      filename: 'amxcanvas.bundle.js',
      path: path.resolve(__dirname, 'dist'),
      libraryTarget: 'var',
      library: 'AmxCvs'
    }
  };
  </code></pre>
  
  <p>The amxcanvas.ts file starts like that:</p>
  
  <pre><code>import * as drawable from "./amxdrawables";
  import * as misc from "./amxmisc";
  
  export function amxCanvasInit(canvasId:string, shapes:drawable.IDrawable[]) {
      var s = new CanvasState(document.getElementById(canvasId), shapes);
  }
  </code></pre>
  
  <p>The amxmisc.ts file starts like that:</p>
  
  <pre><code>export function generateUUID(): string {
      return "";
  }
  
  var gripSize:number = 7;
  </code></pre>
  
  <p>I struggle with this since nearly a week now, does anybody see what I am doing wrong?</p>