<p dir="auto">When using <code class="notranslate">deno run webserver.ts</code> directly, the error stack looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
    &quot;errStack&quot;: [
        &quot;Error: test error&quot;,
        &quot;    at router (router.ts:11:11)&quot;,
        &quot;    at webserver.ts:44:17&quot;
    ]
}"><pre class="notranslate"><code class="notranslate">{
    "errStack": [
        "Error: test error",
        "    at router (router.ts:11:11)",
        "    at webserver.ts:44:17"
    ]
}
</code></pre></div>
<p dir="auto">When used <code class="notranslate">deno bundle</code> or <code class="notranslate">deno compile</code>, the error stack looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
    &quot;errStack&quot;: [
        &quot;Error: test error&quot;,
        &quot;    at router (file://$deno$/bundle.js:8446:15)&quot;,
        &quot;    at file://$deno$/bundle.js:8490:21&quot;
    ]
}"><pre class="notranslate"><code class="notranslate">{
    "errStack": [
        "Error: test error",
        "    at router (file://$deno$/bundle.js:8446:15)",
        "    at file://$deno$/bundle.js:8490:21"
    ]
}
</code></pre></div>
<p dir="auto">It would be very helpful if the stack information of the ts file can also be available after compilation.</p>
<p dir="auto">Maybe it is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="588894064" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/4499" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/4499/hovercard" href="https://github.com/denoland/deno/issues/4499">#4499</a>.</p>
<p dir="auto">Current Deno will remap stack traces on files that have been compiled by Deno, as Deno caches both the original file and the emitted map, and loads those from the cache.  When consuming JavaScript with source maps from other sources (like already compiled code) Deno does not handle the source map and ignore source map pragma included in files.</p>
<p dir="auto">Deno should support both external source maps and inline source maps when fetching modules and store any source maps in the cache to be used when remapping stack traces.</p>
<p dir="auto">This will have the side-effect of supporting the generation of source maps for bundles generated by <code class="notranslate">deno bundle</code>.</p>
<p dir="auto">One consideration is that source maps optionally can include the original sources.  If they do, then when emitting an error, the original source line is available, but if they don't, we would not be able to log-out/resolve that original source line.</p>