title: transpile __dirname as a value
body: <p>I want to get the directory of the source file, so I want to use <code>__dirname</code> in my .ts file as a value, not a variable.</p>
  <p>in other words, I want this code to output the same value whatever the location of the output.</p>
  <p>/src/index.ts</p>
  <pre><code>console.log(__dirname); // -&gt; /src
  
  </code></pre>
  <p>when transpiling this file via <code>tsc</code> into a different location, it should log the new location.
  but I want to log the same value each time</p>
  <p>/dist/index.js</p>
  <pre><code>console.log(__dirname); // -&gt; /dist
  
  </code></pre>
  <p>what I want is that when I open <code>dist/index.js</code> to see <code>cosole.log(&quot;/src&quot;)</code> instead of <code>console.log(__dirname)</code></p>
  <p><strong>why I do that?</strong></p>
  <p>because sometimes you don't want to respect tsconfig.json, and output to a different path.</p>
  <p>for instance using <code>ts-node src/index.ts</code>  acts as if it outputs the compiled file into the same directory of the spurce file, so __dirname here gives the same path as the source file</p>
  <p>another example using <code>jest</code> you need to transpile .ts files on the fly rather than compiling it into the dist folder then running the test.</p>
  <p>you then need to refer to a path relatively to a fixe
  d point, whatever the output file lives.</p>