title: Use non-relative imports using TypeScript's baseurl property without WebPack
body: <p>I am writing a node web application using TypeScript and Express.</p>
  
  <p>I managed to get everything working, however the issue I have run into is that my imports don't seem to respect the <code>baseUrl</code> option of my <code>tsconfig.json</code>.</p>
  
  <p>Here is how my <code>tsconfig.json</code> looks like:</p>
  
  <pre><code>{
    "compilerOptions": {
      "module": "commonjs",
      "moduleResolution": "node",
      "pretty": true,
      "sourceMap": true,
      "target": "es6",
      "outDir": "./dist",
      "baseUrl": "./src"
    },
    "exclude": [
      "node_modules"
    ]
  }
  </code></pre>
  
  <p>As an example, let's say I have the following files:</p>
  
  <pre><code>- dist/
     - a/
        - car.js
     - b/
        - hat.js
  </code></pre>
  
  <p>In <code>car.js</code> I can easily require <code>hat.js</code> by doing:</p>
  
  <pre><code>import hat from '../../b/hat'; // relative version
  </code></pre>
  
  <p>This works as expected.</p>
  
  <p>However, I also want to be able to do the following:</p>
  
  <pre><code>import hat from 'b/hat'; // absolute version
  </code></pre>
  
  <p>This does not generate any issues during compilation or shows any IDE errors, as the <code>tsconfig.json</code> specifies the <code>baseUrl</code> as <code>./src</code>. Thus the above is perfectly valid TypeScript code.</p>
  
  <p>However, my expectation was that the code will compile down to the relative version:</p>
  
  <pre><code>const hat = require('../../b/hat');
  </code></pre>
  
  <p>Unfortunatly it compiled down to:</p>
  
  <pre><code>const hat = require('b/hat');
  </code></pre>
  
  <p>and thus predictably does not work.</p>
  
  <p>Other users have solved this issue by using 3rd party tools such as: <a href="https://github.com/s-panferov/awesome-typescript-loader" rel="nofollow noreferrer">https://github.com/s-panferov/awesome-typescript-loader</a>
  <a href="https://decembersoft.com/posts/say-goodbye-to-relative-paths-in-typescript-imports/" rel="nofollow noreferrer">https://decembersoft.com/posts/say-goodbye-to-relative-paths-in-typescript-imports/</a></p>
  
  <p>But majority of these tools is designed to work with WebPack, which isn't really suitable for an node back-end application. This is because we are running a long-running server, and thus won't benefit from being bundled into a single file versus several different files (unlike front-end web development).</p>
  
  <p>My question is, how can I compile my TypeScript files, without WebPack, so that absolute imports works correctly.</p>