<p dir="auto">I'm seeing webpack in watcher  mode writing truncated files. The number of bytes seems to always be either 1682 or 0 - not sure if that's significant somehow. When its 1682 bytes, it cuts off often in the middle of a variable. It seems like it just aborts writing right in the middle of things. When this happens, I see the webpack callback being called many times in a row without any errors or warnings, which my code takes to be a success. Looks like the callback is being called somewhere around 40 times repeatedly, even though I only made one change.</p>
<p dir="auto">It seems to happen when I try to read from the bundle while its trying to write. In those cases, it would make sense to me if the file wasn't written at all, or if the system returned an error. But when no error is being given back, and the file is partially written - that doesn't make sense to me.</p>
<p dir="auto">Sorry I don't have more good info, its a weird intermittent problem, and I don't have time to futz with things right now.</p>
<p dir="auto">Hey fellas,</p>
<p dir="auto">I've been using webpack for a few months now, and I had an idea for an optimization plugin.  Before I invested a lot of time and energy figuring out how to write it, I wanted to run the idea by you guys to make sure it was sound and hadn't been attempted (and discarded) before.</p>
<p dir="auto">Basically, I'm wondering if webpack can construct a global strings hash table, insert all strings that are used above a certain threshold, then replace references to those strings with hash table lookups.</p>
<p dir="auto">Say webpack generates these lines of code right now (in multiple modules that are eventually output to the same bundle):</p>
<p dir="auto"><code class="notranslate">var some_var = "some string";</code><br>
<code class="notranslate">var some_other_var = "some string";</code><br>
<code class="notranslate">var some_other_other_var = "some string";</code></p>
<p dir="auto">Could it instead generate this code:</p>
<p dir="auto"><code class="notranslate">var strings = { a: "some string" };</code><br>
<code class="notranslate">var some_var = strings.a</code><br>
<code class="notranslate">var some_other_var = strings.a</code><br>
<code class="notranslate">var some_other_other_var = strings.a</code></p>
<p dir="auto">Hoisting all strings seems like it wouldn't be wise, so I was planning on configuration options for frequency and length to determine what strings were hoisted to the lookup table.</p>
<p dir="auto">So my questions before I dive in and get to work on something:</p>
<ol dir="auto">
<li>Is this possible with the API webpack exposes to plugins?</li>
<li>Has this been attempted and rejected before?</li>
</ol>
<p dir="auto">Thanks in advance!</p>