Skip to content

Commit

Permalink
Fix exception when using multicompiler.
Browse files Browse the repository at this point in the history
Fixes #125
  • Loading branch information
SpaceK33z committed Sep 18, 2016
1 parent c7d9310 commit d003556
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function(compiler, options) {

// store our files in memory
var fs;
var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem;
var isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof MemoryFileSystem;
if(isMemoryFs) {
fs = compiler.outputFileSystem;
} else {
Expand Down
25 changes: 25 additions & 0 deletions test/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var webpack = require("webpack");
var should = require("should");
var request = require("supertest");
var webpackConfig = require("./fixtures/server-test/webpack.config");
var webpackMultiConfig = require("./fixtures/server-test/webpack.array.config");


describe("Server", function() {
Expand Down Expand Up @@ -145,6 +146,30 @@ describe("Server", function() {
});
});

describe("MultiCompiler", function() {
before(function(done) {
app = express();
var compiler = webpack(webpackMultiConfig);
var instance = middleware(compiler, {
stats: "errors-only",
quiet: true,
publicPath: "/",
});
app.use(instance);
listen = listenShorthand(done);
});
after(close);

it("request to both bundle files", function(done) {
request(app).get("/foo.js")
.expect(200, function() {
request(app).get("/bar.js")
.expect(200, done);
});
});
});


describe("server side render", function() {
var locals;
before(function(done) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/server-test/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Bar");
File renamed without changes.
15 changes: 15 additions & 0 deletions test/fixtures/server-test/webpack.array.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = [{
context: __dirname,
entry: "./foo.js",
output: {
filename: "foo.js",
path: "/"
}
}, {
context: __dirname,
entry: "./bar.js",
output: {
filename: "bar.js",
path: "/"
}
}];
2 changes: 1 addition & 1 deletion test/fixtures/server-test/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
context: __dirname,
entry: "./index.js",
entry: "./foo.js",
output: {
filename: "bundle.js",
path: "/"
Expand Down

0 comments on commit d003556

Please sign in to comment.