title: How to import pure TypeScript package using npm
body: <p>I'm building a TypeScript specific package that allows users to automatically consume REST API's and convert the resulting JSON-data into true TypeScript-objects. The package will be used in another TypeScript-project in combination with Vue.js.</p>
  
  <p>I've tried several different ways to compile and repackage the package using Webpack and distribute it through npm. I'm able to compile the package into JavaScript and I generate an index.d.ts which are all correctly configured in the package.json. I am also able to include the package into my other project. When trying to compile my TypeScript/Vue project, I always get a <code>This dependency was not found</code> error in the resulting components.</p>
  
  <p>The full error message is:</p>
  
  <pre><code>This dependency was not found:
  
  * typescript-rest-mapper in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/ts-loader??ref--12-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/sample/SampleDetailsComponent.vue?vue&amp;type=script&amp;lang=ts&amp;, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_module
  s/ts-loader??ref--12-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/sample/SampleOverviewComponent.vue?vue&amp;type=script&amp;lang=ts&amp; and 7 others
  </code></pre>
  
  <p>This is the package.json and webpack.config.js of the package:</p>
  
  <p>Package.json:</p>
  
  <pre><code>{
    "name": "typescript-rest-mapper",
    "version": "1.0.6",
    "description": "Package that allows you to automagically build services that consume REST API's. Received/send data is automatically converted between real TypeScript-objects and JSON-objects.",
    "main": "dist/index.js",
    "typings": "dist/index.d.ts",
    "scripts": {
      "build": "webpack &amp;&amp; dts-bundle --configJson dts-bundle.config.json",
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "repository": {
      "type": "git",
      "url": "git+https://github.com/AbyxBelgium/TypeScriptRestMapper.git"
    },
    "keywords": [
      "service",
      "rest-api",
      "typescript",
      "rest",
      "mapper"
    ],
    "author": "Pieter Verschaffelt",
    "license": "Apache-2.0",
    "bugs": {
      "url": "https://github.com/AbyxBelgium/TypeScriptRestMapper/issues"
    },
    "homepage": "https://github.com/AbyxBelgium/TypeScriptRestMapper#readme",
    "devDependencies": {
      "@babel/core": "^7.4.0",
      "@babel/preset-env": "^7.4.2",
      "babel-loader": "^8.0.5",
      "dts-bundle": "^0.7.3",
      "ts-loader": "^5.3.3",
      "typescript": "^3.3.4000",
      "webpack": "^4.29.6",
      "webpack-cli": "^3.3.0"
    },
    "dependencies": {
      "reflect-metadata": "^0.1.13",
      "axios": "^0.18.0",
      "pluralize": "^7.0.0"
    }
  }
  </code></pre>
  
  <p>webpack.config.js:</p>
  
  <pre class="lang-js prettyprint-override"><code>const path = require('path');
  
  module.exports = {
      entry: path.join(__dirname, '/src/index.ts'),
      devtool: 'inline-source-map',
      module: {
          rules: [
              {
                  test: /\.tsx?$/,
                  use: [
                      'ts-loader'
                  ],
                  exclude: /node_modules/
              }
          ]
      },
      resolve: {
          extensions: ['.tsx', '.ts', '.js']
      },
      output: {
          filename: 'bundle.js',
          path: path.resolve(__dirname, 'dist'),
          library: 'TypeScriptRestMapper',
          libraryTarget: 'umd'
      },
      mode: 'development'
  };
  </code></pre>
  
  <p>In my other project, I include files using for example <code>import {Service} from "typescript-rest-mapper";</code>. Note that <code>Service</code> is defined in <code>src/service/Service.ts</code> in my package. In order to export all the different classes from my package, I've built a index.ts file, which states:</p>
  
  <pre class="lang-js prettyprint-override"><code>export {Entity} from "./entity/Entity";
  export {Service} from "./service/Service";
  export {Status} from "./service/Status";
  export {Read} from "./decorators/read";
  export {ReadArray} from "./decorators/readArray";
  export {Store} from "./decorators/store";
  export {StoreArray} from "./decorators/storeArray";
  export {Update} from "./decorators/update";
  export {UpdateArray} from "./decorators/updateArray";
  </code></pre>
  
  <p>I've tried changing the exports to <code>export * from "./entity/Entity</code>, etc. What could've gone wrong?</p>
  
  <p>Note: My package is open source and can be found on GitHub: <a href="https://github.com/AbyxBelgium/TypeScriptRestMapper" rel="nofollow noreferrer">https://github.com/AbyxBelgium/TypeScriptRestMapper</a></p>