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





<p dir="auto"><strong>What is the expected behavior?</strong><br>
When handling images with 'asset/resource' using server-side rendering, we do not want the image file to be emitted, but we do want the image URL to be populated in the HTML in the server bundle. The client bundle can emit the image file.</p>
<p dir="auto">With file-loader one could do this with the emitFile=false flag, but we cannot do that with Webpack 5 Asset Modules.</p>
<p dir="auto">'asset/inline' does suppress the output of the image file, but it requires the image to be inlined, which isn't what is desired.</p>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong><br>
Webpack 5 Asset Modules deprecated the file-loader. But the emitFile feature of file-loader is not available in Asset Modules. That is a required feature for Server Side Rendering</p>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong><br>
Include a flag similar to emitFile with 'asset/resource'</p>
<p dir="auto"><strong>Are you willing to work on this yourself?</strong><br>
no</p>
<p dir="auto">I'm having problems with my bundle creation script that uses webpack. The process prints out "Killed" and exits, which indicates that its getting killed by the linux out of memory killer. I'm also seeing this unhelpful error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="buffer.js:194
      this.parent = new SlowBuffer(this.length);
                    ^
RangeError: length &gt; kMaxLength
    at new Buffer (buffer.js:194:21)
    at fs.js:220:16
    at Object.oncomplete (fs.js:107:15)"><pre class="notranslate"><code class="notranslate">buffer.js:194
      this.parent = new SlowBuffer(this.length);
                    ^
RangeError: length &gt; kMaxLength
    at new Buffer (buffer.js:194:21)
    at fs.js:220:16
    at Object.oncomplete (fs.js:107:15)
</code></pre></div>
<p dir="auto">I think this is saying that a buffer is being created that is too big (too big for what? I don't know). The code for what kMaxLength is seems to show that it's over a gigabyte: <a href="https://github.com/joyent/node/blob/master/src/smalloc.h">https://github.com/joyent/node/blob/master/src/smalloc.h</a> . I'm pretty confused why such a gigantic buffer would be created.</p>
<p dir="auto">So because of this, I'm suggesting that webpack use streams internally to mitigate memory issues like this. I am using webpack's watcher, and so I'm not sure how streams could be incorporated into what the watcher does or how the watcher could reduce its memory footprint.</p>