<h1 dir="auto">Bug report</h1>
<p dir="auto"><strong>What is the current behavior?</strong><br>
Requiring or importing a json file starting with a byte order mark \ufeff, commonly added by Microsoft editors, in webpack 4 causes the following error:</p>
<blockquote>
<p dir="auto">Unexpected token ﻿ in JSON at position 0</p>
</blockquote>
<p dir="auto">webpack 3 handles this though.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
<a href="https://github.com/gatimus/webpack-json-bom/tree/webpack-4">https://github.com/gatimus/webpack-json-bom/tree/webpack-4</a><br>
<code class="notranslate">npm start</code></p>
<p dir="auto"><strong>What is the expected behavior?</strong><br>
<a href="https://github.com/gatimus/webpack-json-bom/tree/webpack-3">https://github.com/gatimus/webpack-json-bom/tree/webpack-3</a><br>
<code class="notranslate">npm start</code></p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version: 4.8.3<br>
Node.js version: 8.11.1<br>
Operating System: Win 10</p>
<h1 dir="auto">Bug report</h1>
<p dir="auto"><strong>What is the current behavior?</strong><br>
Requiring or importing a json file starting with the zero length, white space character, byte order mark (\ufeff), commonly added by Microsoft editors, in webpack 4 causes the following error:</p>
<blockquote>
<p dir="auto">Unexpected token ﻿ in JSON at position 0</p>
</blockquote>
<p dir="auto">webpack 3 handles this with out error though.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
<a href="https://github.com/gatimus/webpack-json-bom/tree/webpack-4">https://github.com/gatimus/webpack-json-bom/tree/webpack-4</a></p>
<ul dir="auto">
<li>clone <a href="https://github.com/gatimus/webpack-json-bom">https://github.com/gatimus/webpack-json-bom</a></li>
<li>checkout branch webpack-4</li>
<li><code class="notranslate">npm i</code></li>
<li><code class="notranslate">npm start</code></li>
</ul>
<blockquote>
<p dir="auto">Unexpected token ﻿ in JSON at position 0</p>
</blockquote>
<p dir="auto"><strong>What is the expected behavior?</strong><br>
<a href="https://github.com/gatimus/webpack-json-bom/tree/webpack-3">https://github.com/gatimus/webpack-json-bom/tree/webpack-3</a></p>
<ul dir="auto">
<li>clone <a href="https://github.com/gatimus/webpack-json-bom">https://github.com/gatimus/webpack-json-bom</a></li>
<li>checkout branch webpack-3</li>
<li><code class="notranslate">npm i</code></li>
<li><code class="notranslate">npm start</code><br>
no errors</li>
</ul>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version: 4.8.3<br>
Node.js version: 8.11.1<br>
Operating System: Win 10</p>
<p dir="auto">I don't know how webpack 3 handles it but calling <code class="notranslate">.trim()</code> or <code class="notranslate">.replace('\ufeff', '')</code> on the file contents before passing to <code class="notranslate">JSON.parse()</code> would solve.</p>