<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
Modules from internal library (also built with Webpack) is missing all exports and is missing from <code class="notranslate">__webpack_modules__</code> when building with <code class="notranslate">mode: development</code>.<br>
The same code works and the page is loading fine when building with <code class="notranslate">mode: production</code> and serving dist.</p>
<p dir="auto">It seems like the dist bundle file is never "expanded" in <code class="notranslate">__webpack_modules__</code>.<br>
If you look at the image you'll see that the bundle is an entry in <code class="notranslate">__webpack_modules__</code>, but the exported modules from said file is not appearing in the list when checking. The list consists om a bunch of modules from node_modules and the modules from the application using the library.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/5993909/97200424-7edd1380-17b1-11eb-9847-e0d8daae7cdd.png"><img src="https://user-images.githubusercontent.com/5993909/97200424-7edd1380-17b1-11eb-9847-e0d8daae7cdd.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">So when it looks for the module in <code class="notranslate">__webpack_modules__</code> it will end up with <code class="notranslate">undefined</code>.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);"><pre class="notranslate"><span class="pl-s1">__webpack_modules__</span><span class="pl-kos">[</span><span class="pl-s1">moduleId</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">,</span> <span class="pl-smi">module</span><span class="pl-kos">,</span> <span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">That will cause the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Uncaught TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (main.js:2793)
    at eval (index.ts:30)
    at Object../src/index.ts (index.js:2168)
    at __nested_webpack_require_8364606__ (index.js:5397)
    at eval (index.js:5436)
    at eval (index.js:5437)
    at webpackUniversalModuleDefinition (index.js:11)
    at eval (index.js:18)
    at Object.../web-lib-core/dist/index.js (lib.js:87)
    at __webpack_require__ (main.js:2793)"><pre class="notranslate"><code class="notranslate">Uncaught TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (main.js:2793)
    at eval (index.ts:30)
    at Object../src/index.ts (index.js:2168)
    at __nested_webpack_require_8364606__ (index.js:5397)
    at eval (index.js:5436)
    at eval (index.js:5437)
    at webpackUniversalModuleDefinition (index.js:11)
    at eval (index.js:18)
    at Object.../web-lib-core/dist/index.js (lib.js:87)
    at __webpack_require__ (main.js:2793)
</code></pre></div>
<p dir="auto">The module is also missing all exports:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/5993909/97201046-42f67e00-17b2-11eb-9b1d-f06b1302d33e.png"><img src="https://user-images.githubusercontent.com/5993909/97201046-42f67e00-17b2-11eb-9b1d-f06b1302d33e.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">The code is present in the dist file (i have removed the contents):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/***/ &quot;./src/metadata/oasbasicmetadataextensions.class.ts&quot;:
/*!**********************************************************!*\
  !*** ./src/metadata/oasbasicmetadataextensions.class.ts ***!
  \**********************************************************/
/*! flagged exports */
/*! export OasBasicMetadataTypeExtensionBase [provided] [no usage info] [missing usage info prevents renaming] */
/*! export __esModule [provided] [no usage info] [missing usage info prevents renaming] */
/*! other exports [not provided] [no usage info] */
/*! runtime requirements: __webpack_exports__, __webpack_require__ */
/***/ ((__unused_webpack_module, exports, __webpack_require__) =&gt; {

&quot;use strict&quot;;
eval(&quot;\r\nObject.defineProperty(exports, \&quot;__esModule\&quot;, ({ value: true }));\r\nexports.OasBasicMetadataTypeExtensionBase = void 0;\r\nvar tslib_1 = __webpack_require__(/*! tslib */ \&quot;../../node_modules/tslib/tslib.es6.js\&quot;);\r\nvar utils_1 = __webpack_require__(/*! ../utils */ \&quot;./src/utils/index.ts\&quot;); var OasBasicMetadataTypeExtensionBase = /** @class */ (function () {\r\n    function OasBasicMetadataTypeExtensionBase(type, typeRef) {...}\r\nexports.OasBasicMetadataTypeExtensionBase = OasBasicMetadataTypeExtensionBase;//# sourceURL=webpack-internal:///./src/metadata/oasbasicmetadataextensions.class.ts\n&quot;);

/***/ })"><pre class="notranslate"><span class="pl-c">/***/</span> <span class="pl-s">"./src/metadata/oasbasicmetadataextensions.class.ts"</span>:
<span class="pl-c">/*!**********************************************************!*\</span>
<span class="pl-c">  !*** ./src/metadata/oasbasicmetadataextensions.class.ts ***!</span>
<span class="pl-c">  \**********************************************************/</span>
<span class="pl-c">/*! flagged exports */</span>
<span class="pl-c">/*! export OasBasicMetadataTypeExtensionBase [provided] [no usage info] [missing usage info prevents renaming] */</span>
<span class="pl-c">/*! export __esModule [provided] [no usage info] [missing usage info prevents renaming] */</span>
<span class="pl-c">/*! other exports [not provided] [no usage info] */</span>
<span class="pl-c">/*! runtime requirements: __webpack_exports__, __webpack_require__ */</span>
<span class="pl-c">/***/</span> <span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">__unused_webpack_module</span><span class="pl-kos">,</span> <span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">__webpack_require__</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>

<span class="pl-s">"use strict"</span><span class="pl-kos">;</span>
<span class="pl-en">eval</span><span class="pl-kos">(</span><span class="pl-s">"\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.OasBasicMetadataTypeExtensionBase = void 0;\r\nvar tslib_1 = __webpack_require__(/*! tslib */ \"../../node_modules/tslib/tslib.es6.js\");\r\nvar utils_1 = __webpack_require__(/*! ../utils */ \"./src/utils/index.ts\"); var OasBasicMetadataTypeExtensionBase = /** @class */ (function () {\r\n    function OasBasicMetadataTypeExtensionBase(type, typeRef) {...}\r\nexports.OasBasicMetadataTypeExtensionBase = OasBasicMetadataTypeExtensionBase;//# sourceURL=webpack-internal:///./src/metadata/oasbasicmetadataextensions.class.ts\n"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">/***/</span> <span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Config files:</strong><br>
<a href="https://gist.github.com/JonWallsten/69c82a3eb7688cae285f9034a8699f5b">https://gist.github.com/JonWallsten/69c82a3eb7688cae285f9034a8699f5b</a></p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>






<p dir="auto">I will work on a repro, but we have a large complex monorepo with a lot of sensitive information. Will update issue when I have created a similar repo with minimal code.</p>
<p dir="auto"><strong>What is the expected behavior?</strong><br>
Modules from our internal library, also built with Webpack, should be found in <code class="notranslate">__webpack_modules__</code> and the site should load just fine like it does with <code class="notranslate">mode: production</code>.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:<br>
Node.js version:<br>
Operating System:<br>
Additional tools:</p>
<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong><br>
Report a bug (though i might just need to set a property somewhere - couldn't tell from the docs. I suspect this is related to natively supporting JSON modules now.)</p>


<p dir="auto"><strong>What is the current behavior?</strong><br>
I have a loader which loads a JSON file and outputs JS code. When I try to use it with Webpack 4, I get a JSON parse error (webpack is trying to parse the outputted JS code as JSON)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
ERROR in ./node_modules/config-loader!./src/config.json
Module parse failed: Unexpected token r in JSON at position 0
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token r in JSON at position 0
  at JSON.parse (&lt;anonymous&gt;:null:null)
  at JsonParser.parse (/Users/jback/dev/plugin-build/node_modules/webpack/lib/JsonParser.js:16:21)
  at doBuild.err (/Users/jback/dev/plugin-build/node_modules/webpack/lib/NormalModule.js:367:32)
  at runLoaders (/Users/jback/dev/plugin-build/node_modules/webpack/lib/NormalModule.js:264:12)
  at /Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:370:3
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:211:10)
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:218:10)
  at /Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:233:3
  at runSyncOrAsync (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
  at Array.&lt;anonymous&gt; (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:202:4)
  at Storage.finished (/Users/jback/dev/plugin-build/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
  at provider (/Users/jback/dev/plugin-build/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
  at /Users/jback/dev/plugin-build/node_modules/graceful-fs/graceful-fs.js:78:16
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)"><pre class="notranslate"><code class="notranslate">
ERROR in ./node_modules/config-loader!./src/config.json
Module parse failed: Unexpected token r in JSON at position 0
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token r in JSON at position 0
  at JSON.parse (&lt;anonymous&gt;:null:null)
  at JsonParser.parse (/Users/jback/dev/plugin-build/node_modules/webpack/lib/JsonParser.js:16:21)
  at doBuild.err (/Users/jback/dev/plugin-build/node_modules/webpack/lib/NormalModule.js:367:32)
  at runLoaders (/Users/jback/dev/plugin-build/node_modules/webpack/lib/NormalModule.js:264:12)
  at /Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:370:3
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:211:10)
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:218:10)
  at /Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:233:3
  at runSyncOrAsync (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
  at iterateNormalLoaders (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
  at Array.&lt;anonymous&gt; (/Users/jback/dev/plugin-build/node_modules/loader-runner/lib/LoaderRunner.js:202:4)
  at Storage.finished (/Users/jback/dev/plugin-build/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
  at provider (/Users/jback/dev/plugin-build/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
  at /Users/jback/dev/plugin-build/node_modules/graceful-fs/graceful-fs.js:78:16
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
</code></pre></div>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>



<p dir="auto"><strong>What is the expected behavior?</strong><br>
I can output JS code from my loader parsing a JSON file (maybe with an option saying I'm outputting JS instead of JSON)<br>
<strong>If this is a feature request, what is motivation or use case for changing the behavior?</strong></p>
<p dir="auto"><strong>Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.</strong><br>
OSX 10.13.3, Node 8.9.4, Webpack 4</p>