<h2 dir="auto">Feature request</h2>
<p dir="auto">Implement NodeJS v12+ internal package.json imports that only apply to import specifiers from within the package itself.</p>
<p dir="auto">NodeJS documentation: <a href="https://nodejs.org/api/packages.html#packages_subpath_imports" rel="nofollow">https://nodejs.org/api/packages.html#packages_subpath_imports</a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<blockquote>
<p dir="auto">Entries in the imports field must always start with # to ensure they are disambiguated from package specifiers.</p>
<p dir="auto">For example, the imports field can be used to gain the benefits of conditional exports for internal modules:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// package.json
{
&quot;imports&quot;: {
   &quot;#dep&quot;: {
     &quot;node&quot;: &quot;dep-node-native&quot;,
     &quot;default&quot;: &quot;./dep-polyfill.js&quot;
  }
},
 &quot;dependencies&quot;: {
  &quot;dep-node-native&quot;: &quot;^1.0.0&quot;
 }
}"><pre class="notranslate"><code class="notranslate">// package.json
{
"imports": {
   "#dep": {
     "node": "dep-node-native",
     "default": "./dep-polyfill.js"
  }
},
 "dependencies": {
  "dep-node-native": "^1.0.0"
 }
}
</code></pre></div>
<p dir="auto">where import '#dep' does not get the resolution of the external package dep-node-native (including its exports in turn), and<br>
instead gets the local file ./dep-polyfill.js relative to the package in other environments.</p>
<p dir="auto">Unlike the "exports" field, the "imports" field permits mapping to external packages.</p>
<p dir="auto">The resolution rules for the imports field are otherwise analogous to the exports field.</p>
</blockquote>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong></p>
<ol dir="auto">
<li>Maintaining interoperability with node package.json specifications.</li>
<li>This feature dis-incentive the use of subpath exports + self-referencing package for internal access. It offers a clean way to replace these <code class="notranslate">import { X } from "../../../lib"</code>, (e.g: by <code class="notranslate">import { X } from "#lib"</code>).</li>
</ol>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong></p>
<p dir="auto">No idea, but looks like webpack subpath exports already implement most of the feature.</p>
<p dir="auto"><strong>Are you willing to work on this yourself?</strong><br>
no</p>
<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong></p>
<p dir="auto">Bug.</p>


<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">When using any <code class="notranslate">devtool</code> strategy that uses <code class="notranslate">eval</code>, such as <code class="notranslate">cheap-module-eval-source-map</code>, the browser developer tools show <em>two</em> sets of files with quasi-identical names. The first set under the <code class="notranslate">webpack://</code> origin contains original sources. The second set under <code class="notranslate">webpack-internal://</code> origin contains transpiled sources.</p>
<p dir="auto">Note that this has changed in webpack 4. In the previous version that <code class="notranslate">webpack-internal://</code> files used numeric identifiers, so there was no risk to open them by accident and they did not show up when using Ctrl+P in Chrome.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/lorenzodallavecchia/webpack-bug-duplicatesource.git
cd webpack-bug-duplicatesource
npm install
npm start"><pre class="notranslate"><code class="notranslate">git clone https://github.com/lorenzodallavecchia/webpack-bug-duplicatesource.git
cd webpack-bug-duplicatesource
npm install
npm start
</code></pre></div>



<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">I would expect to only see original sources (under <code class="notranslate">webpack://</code>) or at least give the "internal" sources a numeric identifier so that they do not show up when searching with Ctrl+P.</p>
<p dir="auto"><strong>Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.</strong></p>
<p dir="auto">webpack 4<br>
Node 6.11.0<br>
Chrome 65<br>
Windows 10 1709</p>