Skip to content

Commit dabbab4

Browse files
committed
removed the last TODO :)
1 parent 47ae6dc commit dabbab4

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

lib/dependencies/RequireContextPlugin.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ RequireContextPlugin.prototype.apply = function(compiler) {
2626
compilation.dependencyFactories.set(ContextElementDependency, normalModuleFactory);
2727
});
2828
compiler.plugin("context-module-factory", function(cmf) {
29-
// TODO extract in modules
3029
cmf.plugin("alternatives", function(items, callback) {
3130
if(items.length == 0) return callback(null, items);
3231

@@ -48,10 +47,16 @@ RequireContextPlugin.prototype.apply = function(compiler) {
4847
cmf.plugin("alternatives", function(items, callback) {
4948
if(items.length == 0) return callback(null, items);
5049

51-
callback(null, items.filter(function(obj) {
52-
return modulesDirectories.filter(function(dir) {
53-
return obj.request.indexOf("/" + dir + "/") >= 0;
54-
}) == 0;
50+
callback(null, items.map(function(obj) {
51+
for(var i = 0; i < modulesDirectories.length; i++) {
52+
var dir = modulesDirectories[i];
53+
var idx = obj.request.indexOf("/" + dir + "/");
54+
if(idx >= 0) {
55+
obj.request = obj.request.slice(idx+dir.length+2);
56+
break;
57+
}
58+
}
59+
return obj;
5560
}));
5661
});
5762
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.10.0-beta22",
3+
"version": "0.10.0-beta23",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {

test/browsertest/lib/index.web.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ describe("main", function() {
362362
(require.context("../././templates"))("./tmpl").should.be.eql("test template");
363363
(require.context(".././templates/.")("./tmpl")).should.be.eql("test template");
364364
require . context ( "." + "." + "/" + "templ" + "ates" ) ( "./subdir/tmpl.js" ).should.be.eql("subdir test template");
365+
require.context("../templates", true, /./)("xyz").should.be.eql("xyz");
365366
});
366367

367368
it("should automatically create contexts", function() {

test/browsertest/templates/node_modules/xyz.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)