<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="define(function (require, exports, module) {
    var Test = {
        test: function() {
            console.log(this); // print the Test object
            require([], function(){
                console.log(this); // print the global/window object
            }.bind(this));
        }
    };
    return Test;
});"><pre class="notranslate"><code class="notranslate">define(function (require, exports, module) {
    var Test = {
        test: function() {
            console.log(this); // print the Test object
            require([], function(){
                console.log(this); // print the global/window object
            }.bind(this));
        }
    };
    return Test;
});
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="require('./test').test();"><pre class="notranslate"><code class="notranslate">require('./test').test();
</code></pre></div>
<p dir="auto">As the above code, the <code class="notranslate">bind</code> operation to the amd require callback is useless. It prints the global context instead of the parameter passed to the <code class="notranslate">bind</code> function.<br>
Tested in webpack 1.12.13 and 2.0.7-beta.</p>
<p dir="auto">When using Webpack to package a file containing an AMD-style <code class="notranslate">require()</code> with a bound expression callback like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="require(['dependency'], function (dependency) {
   ...
}.bind(this));"><pre class="notranslate"><code class="notranslate">require(['dependency'], function (dependency) {
   ...
}.bind(this));
</code></pre></div>
<p dir="auto">The <code class="notranslate">this</code> context within the callback fails to match the expected because the call is wrapped in an outer function expression:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="__webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(1)]; (function (dependency) {
 ...
}.bind(this).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});"><pre class="notranslate"><code class="notranslate">__webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(1)]; (function (dependency) {
 ...
}.bind(this).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
</code></pre></div>
<p dir="auto">Example of the issue:</p>
<p dir="auto"><a href="https://github.com/bregenspan/webpack-amd-require-issue">https://github.com/bregenspan/webpack-amd-require-issue</a><br>
<a href="https://rawgit.com/bregenspan/webpack-amd-require-issue/master/index.html" rel="nofollow">https://rawgit.com/bregenspan/webpack-amd-require-issue/master/index.html</a></p>
<p dir="auto">One quick remedy that solves this particular case (but needs further testing) is the following patch:<br>
<a href="https://gist.github.com/bregenspan/6cb090011fafe428fc97">https://gist.github.com/bregenspan/6cb090011fafe428fc97</a> .  But I wanted to make sure this is indeed an issue and there isn't already a configuration option I'm missing somewhere that would solve this, before submitting any PR.</p>
<p dir="auto">-Ben</p>
<p dir="auto">PS: thank you for releasing + maintaining this great tool!</p>