title: How to use a pure TypeScript library as a dependency with Webpack?
body: <p>I have 3 repos - <code>client</code>, <code>backend</code> and <code>interfaces</code>.</p>
  <p>All are written in TypeScript. Client and backend repos compile into JavaScript during the build phase then deployed to server.</p>
  <p>Last repo <code>interfaces</code> is not supposed to be compiled to anything, but just used as an npm dependency for both client and backend repos declaring how client and backend apps communicate with each other.</p>
  <p>Before I introduced <code>interfaces</code> repo and added it as a dependency to both other repos, I used hardcoded messages types strings and all compiled just fine.</p>
  <p>Now, with a purely TypeScript dependency, which is <code>interfaces</code>, I can inject types from it into <code>client</code> or <code>backend</code> repos code and see them connected properly.</p>
  <p>But the problem is I cannot compile projects now because seems like something is not configured properly for this case in Webpack.</p>
  <p>Here is the related piece of <code>webpack.config.js</code>:</p>
  <pre><code>module: {
      rules: [
          {
              test: /\.js$/,
              use: 'babel-loader',
              // exclude: /node_modules/
          },
          {
              test: /\.ts$/,
              use: 'ts-loader',
              exclude: /node_modules/
          }
      ]
  },
  </code></pre>
  <p>With this one I see an error while trying to build with webpack:</p>
  <blockquote>
  <p>ERROR in ./node_modules/myapp_interfaces/interfaces/ClientRequestPayload.ts</p>
  <p>Module parse failed: The keyword 'interface' is reserved (1:0)</p>
  <p>You may need an appropriate loader to handle this file type.</p>
  </blockquote>
  <p>If I comment out <code>exclude: /node_modules/</code>, I see this:</p>
  <blockquote>
  <p>ERROR in ./node_modules/myapp_interfaces/index.ts</p>
  <p>Module build failed: Error: Typescript emitted no output for /myapp/myapp_backend/node_modules/myapp_interfaces/index.ts.</p>
  <p>You should not need to recompile .ts files in node_modules.</p>
  <p>Please contact the package author to advise them to use --declaration --outDir.</p>
  </blockquote>
  <p>This interfaces code would work normally if it were in another folder of the project I suppose.</p>
  <p>How do I get rid of this error and just import these into my code then compile?</p>