<p dir="auto">I am currently working on splitting up various parts of my app into separate files and lay-loading them when needed. The concept works out, however, webpack doesn't play nicely. In two separate files - <code class="notranslate">main.oj</code> and <code class="notranslate">editor.oj</code>- I use <code class="notranslate">require("highlight.js")</code> to require the HighlightJS module. However, what  the difference is:</p>
<ul dir="auto">
<li><code class="notranslate">main.oj</code> uses the async require.</li>
<li><code class="notranslate">editor.oj</code> uses the sync require directly in a call.</li>
</ul>
<p dir="auto">In <code class="notranslate">main.oj</code>:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// ...
    if($(&quot;body&quot;).find(&quot;pre code&quot;).length &gt; 0) {
        require([
            // Should only load the hljs stuff we need...
            &quot;highlight.js&quot;,
            // Stylesheet.
            &quot;highlight.js/styles/hybrid.css&quot;
        ], function(hljs){
            // ... snip ...
        });
    }
// ..."><pre class="notranslate"><span class="pl-c">// ...</span>
    <span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-en">$</span><span class="pl-kos">(</span><span class="pl-s">"body"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">find</span><span class="pl-kos">(</span><span class="pl-s">"pre code"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">&gt;</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-kos">[</span>
            <span class="pl-c">// Should only load the hljs stuff we need...</span>
            <span class="pl-s">"highlight.js"</span><span class="pl-kos">,</span>
            <span class="pl-c">// Stylesheet.</span>
            <span class="pl-s">"highlight.js/styles/hybrid.css"</span>
        <span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">hljs</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
            <span class="pl-c">// ... snip ...</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-c">// ...</span></pre></div>
<p dir="auto">In <code class="notranslate">editor.oj</code>:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// ...
                $html = $(data);
                $html.filter(&quot;pre&quot;).find(&quot;code&quot;).each(function(i, block) {
                    $(block).parent().css({&quot;border&quot;:&quot;none&quot;, &quot;background&quot;:&quot;none&quot;});
                    require(&quot;highlight.js&quot;).highlightBlock(block);
                });
// ..."><pre class="notranslate"><span class="pl-c">// ...</span>
                <span class="pl-s1">$html</span> <span class="pl-c1">=</span> <span class="pl-en">$</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                <span class="pl-s1">$html</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span><span class="pl-s">"pre"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">find</span><span class="pl-kos">(</span><span class="pl-s">"code"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">each</span><span class="pl-kos">(</span><span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">i</span><span class="pl-kos">,</span> <span class="pl-s1">block</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                    <span class="pl-en">$</span><span class="pl-kos">(</span><span class="pl-s1">block</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">parent</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">css</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-s">"border"</span>:<span class="pl-s">"none"</span><span class="pl-kos">,</span> <span class="pl-s">"background"</span>:<span class="pl-s">"none"</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                    <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"highlight.js"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">highlightBlock</span><span class="pl-kos">(</span><span class="pl-s1">block</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// ...</span></pre></div>
<p dir="auto">... And this shows up on the compile:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="chunk    {2} ba91d8a1dcc9a057b0f7-2.2.js 74.6 kB {0} [rendered]
   [48] ./~/highlight.js/lib/languages/ini.js 599 bytes {2} {3} [built]
   [47] ./~/highlight.js/lib/languages/http.js 843 bytes {2} {3} [built]
   [50] ./~/highlight.js/lib/languages/json.js 1.02 kB {2} {3} [built]
   [40] ./web-lib/highlight.js 1.14 kB {2} {3} [built]
   [56] ./~/highlight.js/styles/hybrid.css 1.36 kB {2} [built]
   [46] ./~/highlight.js/lib/languages/markdown.js 2.3 kB {2} {3} [built]
   [42] ./~/highlight.js/lib/languages/bash.js 2.35 kB {2} {3} [built]
   [51] ./~/highlight.js/lib/languages/objectivec.js 2.4 kB {2} {3} [built]
   [55] ./~/highlight.js/lib/languages/xml.js 2.48 kB {2} {3} [built]
   [45] ./~/highlight.js/lib/languages/css.js 2.58 kB {2} {3} [built]
   [52] ./~/highlight.js/lib/languages/php.js 3.28 kB {2} {3} [built]
   [49] ./~/highlight.js/lib/languages/javascript.js 3.51 kB {2} {3} [built]
   [44] ./~/highlight.js/lib/languages/cs.js 3.59 kB {2} {3} [built]
   [43] ./~/highlight.js/lib/languages/cpp.js 4.19 kB {2} {3} [built]
   [57] ./~/css-loader?keepSpecialComments=0&amp;processImport=true&amp;rebase=true&amp;relativeTo=/Users/Ingwie/Work/Bird3&amp;shorthandCompacting=true&amp;target=/Users/Ingwie/Work/Bird3/cdn/app&amp;sourceMap!./~/highlight.js/styles/hybrid.css 5.68 kB {2} [built]
   [54] ./~/highlight.js/lib/languages/sql.js 7.25 kB {2} {3} [built]
   [53] ./~/highlight.js/lib/languages/scss.js 7.6 kB {2} {3} [built]
   [41] ./~/highlight.js/lib/highlight.js 22.4 kB {2} {3} [built]

chunk    {3} ba91d8a1dcc9a057b0f7-3.3.js 126 kB {0} [rendered]
   [60] ./web_modules/LDT.webpack.js 421 bytes {3} [built]
   [48] ./~/highlight.js/lib/languages/ini.js 599 bytes {2} {3} [built]
   [64] ./~/exports-loader?SelectHelper!./web_modules/LDT/lib/SelectHelper.js 698 bytes {3} [built]
   [70] ./protected/extensions/BIRD3/js/views/editor/link.ejs 841 bytes {3} [built]
   [47] ./~/highlight.js/lib/languages/http.js 843 bytes {2} {3} [built]
   [71] ./protected/extensions/BIRD3/js/views/editor/image.ejs 851 bytes {3} [built]
   [63] ./~/exports-loader?Parser!./web_modules/LDT/lib/Parser.js 862 bytes {3} [built]
   [69] ./protected/extensions/BIRD3/js/views/editor/code_block.ejs 975 bytes {3} [built]
   [50] ./~/highlight.js/lib/languages/json.js 1.02 kB {2} {3} [built]
   [40] ./web-lib/highlight.js 1.14 kB {2} {3} [built]
   [68] ./protected/extensions/BIRD3/js/views/editor/bg_color.ejs 1.19 kB {3} [built]
   [65] ./web_modules/LDT/lib/TextareaDecorator.css 1.46 kB {3} [built]
   [62] ./~/exports-loader?Keybinder!./web_modules/LDT/lib/Keybinder.js 2.14 kB {3} [built]
   [46] ./~/highlight.js/lib/languages/markdown.js 2.3 kB {2} {3} [built]
   [42] ./~/highlight.js/lib/languages/bash.js 2.35 kB {2} {3} [built]
   [51] ./~/highlight.js/lib/languages/objectivec.js 2.4 kB {2} {3} [built]
   [55] ./~/highlight.js/lib/languages/xml.js 2.48 kB {2} {3} [built]
   [45] ./~/highlight.js/lib/languages/css.js 2.58 kB {2} {3} [built]
   [66] ./~/css-loader?keepSpecialComments=0&amp;processImport=true&amp;rebase=true&amp;relativeTo=/Users/Ingwie/Work/Bird3&amp;shorthandCompacting=true&amp;target=/Users/Ingwie/Work/Bird3/cdn/app&amp;sourceMap!./web_modules/LDT/lib/TextareaDecorator.css 2.7 kB {3} [built]
   [52] ./~/highlight.js/lib/languages/php.js 3.28 kB {2} {3} [built]
   [49] ./~/highlight.js/lib/languages/javascript.js 3.51 kB {2} {3} [built]
   [44] ./~/highlight.js/lib/languages/cs.js 3.59 kB {2} {3} [built]
   [61] ./~/exports-loader?TextareaDecorator!./web_modules/LDT/lib/TextareaDecorator.js 3.71 kB {3} [built]
   [43] ./~/highlight.js/lib/languages/cpp.js 4.19 kB {2} {3} [built]
   [67] ./protected/extensions/BIRD3/js/views/editor/toolbar.ejs 6.15 kB {3} [built]
   [54] ./~/highlight.js/lib/languages/sql.js 7.25 kB {2} {3} [built]
   [53] ./~/highlight.js/lib/languages/scss.js 7.6 kB {2} {3} [built]
   [58] ./protected/extensions/BIRD3/js/editor.oj 12.3 kB {3} [built]
   [41] ./~/highlight.js/lib/highlight.js 22.4 kB {2} {3} [built]
   [59] ./web_modules/behave.js/behave.js 24.4 kB {3} [built]"><pre class="notranslate"><code class="notranslate">chunk    {2} ba91d8a1dcc9a057b0f7-2.2.js 74.6 kB {0} [rendered]
   [48] ./~/highlight.js/lib/languages/ini.js 599 bytes {2} {3} [built]
   [47] ./~/highlight.js/lib/languages/http.js 843 bytes {2} {3} [built]
   [50] ./~/highlight.js/lib/languages/json.js 1.02 kB {2} {3} [built]
   [40] ./web-lib/highlight.js 1.14 kB {2} {3} [built]
   [56] ./~/highlight.js/styles/hybrid.css 1.36 kB {2} [built]
   [46] ./~/highlight.js/lib/languages/markdown.js 2.3 kB {2} {3} [built]
   [42] ./~/highlight.js/lib/languages/bash.js 2.35 kB {2} {3} [built]
   [51] ./~/highlight.js/lib/languages/objectivec.js 2.4 kB {2} {3} [built]
   [55] ./~/highlight.js/lib/languages/xml.js 2.48 kB {2} {3} [built]
   [45] ./~/highlight.js/lib/languages/css.js 2.58 kB {2} {3} [built]
   [52] ./~/highlight.js/lib/languages/php.js 3.28 kB {2} {3} [built]
   [49] ./~/highlight.js/lib/languages/javascript.js 3.51 kB {2} {3} [built]
   [44] ./~/highlight.js/lib/languages/cs.js 3.59 kB {2} {3} [built]
   [43] ./~/highlight.js/lib/languages/cpp.js 4.19 kB {2} {3} [built]
   [57] ./~/css-loader?keepSpecialComments=0&amp;processImport=true&amp;rebase=true&amp;relativeTo=/Users/Ingwie/Work/Bird3&amp;shorthandCompacting=true&amp;target=/Users/Ingwie/Work/Bird3/cdn/app&amp;sourceMap!./~/highlight.js/styles/hybrid.css 5.68 kB {2} [built]
   [54] ./~/highlight.js/lib/languages/sql.js 7.25 kB {2} {3} [built]
   [53] ./~/highlight.js/lib/languages/scss.js 7.6 kB {2} {3} [built]
   [41] ./~/highlight.js/lib/highlight.js 22.4 kB {2} {3} [built]

chunk    {3} ba91d8a1dcc9a057b0f7-3.3.js 126 kB {0} [rendered]
   [60] ./web_modules/LDT.webpack.js 421 bytes {3} [built]
   [48] ./~/highlight.js/lib/languages/ini.js 599 bytes {2} {3} [built]
   [64] ./~/exports-loader?SelectHelper!./web_modules/LDT/lib/SelectHelper.js 698 bytes {3} [built]
   [70] ./protected/extensions/BIRD3/js/views/editor/link.ejs 841 bytes {3} [built]
   [47] ./~/highlight.js/lib/languages/http.js 843 bytes {2} {3} [built]
   [71] ./protected/extensions/BIRD3/js/views/editor/image.ejs 851 bytes {3} [built]
   [63] ./~/exports-loader?Parser!./web_modules/LDT/lib/Parser.js 862 bytes {3} [built]
   [69] ./protected/extensions/BIRD3/js/views/editor/code_block.ejs 975 bytes {3} [built]
   [50] ./~/highlight.js/lib/languages/json.js 1.02 kB {2} {3} [built]
   [40] ./web-lib/highlight.js 1.14 kB {2} {3} [built]
   [68] ./protected/extensions/BIRD3/js/views/editor/bg_color.ejs 1.19 kB {3} [built]
   [65] ./web_modules/LDT/lib/TextareaDecorator.css 1.46 kB {3} [built]
   [62] ./~/exports-loader?Keybinder!./web_modules/LDT/lib/Keybinder.js 2.14 kB {3} [built]
   [46] ./~/highlight.js/lib/languages/markdown.js 2.3 kB {2} {3} [built]
   [42] ./~/highlight.js/lib/languages/bash.js 2.35 kB {2} {3} [built]
   [51] ./~/highlight.js/lib/languages/objectivec.js 2.4 kB {2} {3} [built]
   [55] ./~/highlight.js/lib/languages/xml.js 2.48 kB {2} {3} [built]
   [45] ./~/highlight.js/lib/languages/css.js 2.58 kB {2} {3} [built]
   [66] ./~/css-loader?keepSpecialComments=0&amp;processImport=true&amp;rebase=true&amp;relativeTo=/Users/Ingwie/Work/Bird3&amp;shorthandCompacting=true&amp;target=/Users/Ingwie/Work/Bird3/cdn/app&amp;sourceMap!./web_modules/LDT/lib/TextareaDecorator.css 2.7 kB {3} [built]
   [52] ./~/highlight.js/lib/languages/php.js 3.28 kB {2} {3} [built]
   [49] ./~/highlight.js/lib/languages/javascript.js 3.51 kB {2} {3} [built]
   [44] ./~/highlight.js/lib/languages/cs.js 3.59 kB {2} {3} [built]
   [61] ./~/exports-loader?TextareaDecorator!./web_modules/LDT/lib/TextareaDecorator.js 3.71 kB {3} [built]
   [43] ./~/highlight.js/lib/languages/cpp.js 4.19 kB {2} {3} [built]
   [67] ./protected/extensions/BIRD3/js/views/editor/toolbar.ejs 6.15 kB {3} [built]
   [54] ./~/highlight.js/lib/languages/sql.js 7.25 kB {2} {3} [built]
   [53] ./~/highlight.js/lib/languages/scss.js 7.6 kB {2} {3} [built]
   [58] ./protected/extensions/BIRD3/js/editor.oj 12.3 kB {3} [built]
   [41] ./~/highlight.js/lib/highlight.js 22.4 kB {2} {3} [built]
   [59] ./web_modules/behave.js/behave.js 24.4 kB {3} [built]
</code></pre></div>
<p dir="auto">My config is pretty big. So, <a href="https://gist.github.com/IngwiePhoenix/2d4fdd21218f1fd3edbe">I uploaded it as a gist.</a></p>
<p dir="auto">How can I avoid the duplicated inclusion? Is there a plugin I have to activate?</p>
<p dir="auto">Kind regards, Ingwie.</p>
<p dir="auto">There are files which are 80% or under for test coverage on Coveralls, giving them a red label. Providing these files with dedicated unit tests will help solidify their API, as well as bring their coverage up to 100%.<br>
Please see the coverall coverage report: <a href="https://coveralls.io/github/webpack/webpack" rel="nofollow">https://coveralls.io/github/webpack/webpack</a></p>
<p dir="auto">This issue aims to help co-ordinate any effort to add unit test for these files, with the aim then have all files with higher than 80% coverage when closed off.</p>
<ol class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(65.73%) <code class="notranslate">lib/MultiCompiler.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="199129020" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3802" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3802/hovercard" href="https://github.com/webpack/webpack/pull/3802">#3802</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(70.45%) <code class="notranslate">lib/LibraryTemplatePlugin.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="199376584" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3835" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3835/hovercard" href="https://github.com/webpack/webpack/pull/3835">#3835</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(74.19%) <code class="notranslate">lib/optimize/UglifyJsPlugin.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="203816349" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4127" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/4127/hovercard" href="https://github.com/webpack/webpack/pull/4127">#4127</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(75.00%) <code class="notranslate">lib/webworker/WebWorkerMainTemplatePlugin.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="199692449" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3866" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3866/hovercard" href="https://github.com/webpack/webpack/pull/3866">#3866</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(75.00%) <code class="notranslate">examples/move-to-parent/webpack.config.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="202725701" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4092" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/4092/hovercard" href="https://github.com/webpack/webpack/pull/4092">#4092</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(75.93%) <code class="notranslate">lib/node/NodeMainTemplatePlugin.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="201573461" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3999" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3999/hovercard" href="https://github.com/webpack/webpack/pull/3999">#3999</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(79.49%) <code class="notranslate">lib/node/NodeWatchFileSystem.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="199387282" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3837" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3837/hovercard" href="https://github.com/webpack/webpack/pull/3837">#3837</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(80.00%) <code class="notranslate">lib/HotUpdateChunkTemplate.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="199697552" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/3867" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/3867/hovercard" href="https://github.com/webpack/webpack/pull/3867">#3867</a></del> - Merged</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (75.68%) <code class="notranslate">lib/ContextReplacementPlugin.js</code></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> (78.57%) <code class="notranslate">lib/dependencies/ContextDependencyTemplateAsId.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="205364988" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4203" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/4203/hovercard" href="https://github.com/webpack/webpack/pull/4203">#4203</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <del>(80.00%) <code class="notranslate">lib/EnvironmentPlugin.js</code> - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="205352791" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/4201" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/4201/hovercard" href="https://github.com/webpack/webpack/pull/4201">#4201</a></del> - Merged</li>
</ol>
<p dir="auto">Add a comment below if you're adding unit tests for one of the files above to prevent duplication of effort, and then link to the PR once it's up.</p>