Browse Source

removed the last TODO :)

0.10
Tobias Koppers 9 years ago
parent
commit
dabbab4627
  1. 15
      lib/dependencies/RequireContextPlugin.js
  2. 2
      package.json
  3. 1
      test/browsertest/lib/index.web.js
  4. 1
      test/browsertest/templates/node_modules/xyz.js

15
lib/dependencies/RequireContextPlugin.js

@ -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;
}));
});
});

2
package.json

@ -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": {

1
test/browsertest/lib/index.web.js

@ -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

@ -0,0 +1 @@
module.exports = "xyz";
Loading…
Cancel
Save