removed the last TODO :)

This commit is contained in:
Tobias Koppers 2013-06-15 17:31:56 +02:00
parent 47ae6dc211
commit dabbab4627
4 changed files with 13 additions and 6 deletions

View File

@ -26,7 +26,6 @@ RequireContextPlugin.prototype.apply = function(compiler) {
compilation.dependencyFactories.set(ContextElementDependency, normalModuleFactory);
});
compiler.plugin("context-module-factory", function(cmf) {
// TODO extract in modules
cmf.plugin("alternatives", function(items, callback) {
if(items.length == 0) return callback(null, items);
@ -48,10 +47,16 @@ RequireContextPlugin.prototype.apply = function(compiler) {
cmf.plugin("alternatives", function(items, callback) {
if(items.length == 0) return callback(null, items);
callback(null, items.filter(function(obj) {
return modulesDirectories.filter(function(dir) {
return obj.request.indexOf("/" + dir + "/") >= 0;
}) == 0;
callback(null, items.map(function(obj) {
for(var i = 0; i < modulesDirectories.length; i++) {
var dir = modulesDirectories[i];
var idx = obj.request.indexOf("/" + dir + "/");
if(idx >= 0) {
obj.request = obj.request.slice(idx+dir.length+2);
break;
}
}
return obj;
}));
});
});

View File

@ -1,6 +1,6 @@
{
"name": "webpack",
"version": "0.10.0-beta22",
"version": "0.10.0-beta23",
"author": "Tobias Koppers @sokra",
"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.",
"dependencies": {

View File

@ -362,6 +362,7 @@ describe("main", function() {
(require.context("../././templates"))("./tmpl").should.be.eql("test template");
(require.context(".././templates/.")("./tmpl")).should.be.eql("test template");
require . context ( "." + "." + "/" + "templ" + "ates" ) ( "./subdir/tmpl.js" ).should.be.eql("subdir test template");
require.context("../templates", true, /./)("xyz").should.be.eql("xyz");
});
it("should automatically create contexts", function() {

1
test/browsertest/templates/node_modules/xyz.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = "xyz";