Skip to content

Instantly share code, notes, and snippets.

@bregenspan
Created July 8, 2015 18:00
Show Gist options
  • Save bregenspan/6cb090011fafe428fc97 to your computer and use it in GitHub Desktop.
Save bregenspan/6cb090011fafe428fc97 to your computer and use it in GitHub Desktop.
AMDRequireDependency.patch
diff --git a/lib/dependencies/AMDRequireDependency.js b/lib/dependencies/AMDRequireDependency.js
index 1f183e1..526531b 100644
--- a/lib/dependencies/AMDRequireDependency.js
+++ b/lib/dependencies/AMDRequireDependency.js
@@ -47,14 +47,14 @@ AMDRequireDependency.Template.prototype.apply = function(dep, source, outputOpti
source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
- source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}" + wrapper[1]);
+ source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}.bind(this)" + wrapper[1]);
} else {
source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1,
"!/* require */(" + asComment(depBlock.chunkReason) + "function() { ");
source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
- source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}())");
+ source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}.bind(this)())");
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment