<h2 dir="auto">Feature request</h2>





<p dir="auto"><strong>What is the expected behavior?</strong><br>
Every loader that uses <code class="notranslate">[hash]</code> needs to use <code class="notranslate">[hash:10]</code> to be consistent if webpack's options were set as <code class="notranslate">output: { hashDigestLength: 10 } }</code>. It would be better if loaders were able to use the same value by default if they choose to.</p>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong><br>
<code class="notranslate">hashDigestLength</code> should be able to be used by <code class="notranslate">[hash]</code> in file-loader and other loaders if they choose to, so that <code class="notranslate">[hash]</code> would by default have a length of <code class="notranslate">10</code>.</p>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong><br>
In <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="393426759" data-permission-text="Title is private" data-url="https://github.com/webpack/loader-utils/issues/121" data-hovercard-type="issue" data-hovercard-url="/webpack/loader-utils/issues/121/hovercard?comment_id=602487372&amp;comment_type=issue_comment" href="https://github.com/webpack/loader-utils/issues/121#issuecomment-602487372">webpack/loader-utils#121 (comment)</a> it says that the issue should be solved on the webpack side. There was also an issue in <code class="notranslate">file-loader</code> project which said it can't be solved there.</p>
<p dir="auto"><strong>Are you willing to work on this yourself?</strong></p>
<h2 dir="auto">Feature request</h2>
<p dir="auto">We all know that webapck can set the resolve.mainFields to read the node_modules package dependency file, but if I set<code class="notranslate"> {" es2015": "./fesm2015/core.js "} </code>like <code class="notranslate">@angluer/core </code>package.json;<br>
I will configure <code class="notranslate">resolve.mainFields</code> as<code class="notranslate">[' es2015 ', 'module', 'main']</code>;<br>
If my build target is es5,<br>
<code class="notranslate">babel-loader</code>should exclude loading <code class="notranslate">[' module', 'main ']</code>; Including mainFields as<code class="notranslate"> [' es2015 ']</code>; How can I fulfill this abnormal demand</p>





<p dir="auto"><strong>What is the expected behavior?</strong><br>
I can filter module. rules freely according to <code class="notranslate">resolve.mainFields </code></p>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong><br>
In order to embrace the future, convenient tree-string, reduce duplication of code</p>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong><br>
Rule exclude or some other conditional Rule that tells the Rule function whether the incoming file reads the mainFields field in the package.json, what's the name of the field?<br>
e.g :</p>
<h4 dir="auto">Scenario 1</h4>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
&quot;es2015&quot;:&quot;./lib/es/index.js&quot;,
&quot;main&quot;:&quot;./lib/bundles/index.js&quot;
}"><pre class="notranslate">{
<span class="pl-ent">"es2015"</span>:<span class="pl-s"><span class="pl-pds">"</span>./lib/es/index.js<span class="pl-pds">"</span></span>,
<span class="pl-ent">"main"</span>:<span class="pl-s"><span class="pl-pds">"</span>./lib/bundles/index.js<span class="pl-pds">"</span></span>
}</pre></div>
<p dir="auto">node_models/a/lib/es/index.js(es2015:'./lib/es/index.js')  {mainField: 'es2015'}</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//  lib/es/index.js
import b from &quot;./b.js&quot;"><pre class="notranslate"><span class="pl-c">//  lib/es/index.js</span>
<span class="pl-k">import</span> <span class="pl-s1">b</span> <span class="pl-k">from</span> <span class="pl-s">"./b.js"</span></pre></div>
<p dir="auto">node_models/a/lib/es/b.js  {mainField: [false?|undefined?]}</p>
<h4 dir="auto">Scenario 2</h4>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
&quot;main&quot;:&quot;./lib/bundles/index.js&quot;
}"><pre class="notranslate">{
<span class="pl-ent">"main"</span>:<span class="pl-s"><span class="pl-pds">"</span>./lib/bundles/index.js<span class="pl-pds">"</span></span>
}</pre></div>
<p dir="auto">node_models/b/lib/bundles/index.js("main":"./lib/bundles/index.js")  {mainField: 'mian'}<br>
<strong>Are you willing to work on this yourself?</strong><br>
yes</p>