Skip to content

Commit d003556

Browse files
committed
Fix exception when using multicompiler.
Fixes #125
1 parent c7d9310 commit d003556

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = function(compiler, options) {
5656

5757
// store our files in memory
5858
var fs;
59-
var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem;
59+
var isMemoryFs = !compiler.compilers && compiler.outputFileSystem instanceof MemoryFileSystem;
6060
if(isMemoryFs) {
6161
fs = compiler.outputFileSystem;
6262
} else {

test/Server.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var webpack = require("webpack");
44
var should = require("should");
55
var request = require("supertest");
66
var webpackConfig = require("./fixtures/server-test/webpack.config");
7+
var webpackMultiConfig = require("./fixtures/server-test/webpack.array.config");
78

89

910
describe("Server", function() {
@@ -145,6 +146,30 @@ describe("Server", function() {
145146
});
146147
});
147148

149+
describe("MultiCompiler", function() {
150+
before(function(done) {
151+
app = express();
152+
var compiler = webpack(webpackMultiConfig);
153+
var instance = middleware(compiler, {
154+
stats: "errors-only",
155+
quiet: true,
156+
publicPath: "/",
157+
});
158+
app.use(instance);
159+
listen = listenShorthand(done);
160+
});
161+
after(close);
162+
163+
it("request to both bundle files", function(done) {
164+
request(app).get("/foo.js")
165+
.expect(200, function() {
166+
request(app).get("/bar.js")
167+
.expect(200, done);
168+
});
169+
});
170+
});
171+
172+
148173
describe("server side render", function() {
149174
var locals;
150175
before(function(done) {

test/fixtures/server-test/bar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Bar");
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = [{
2+
context: __dirname,
3+
entry: "./foo.js",
4+
output: {
5+
filename: "foo.js",
6+
path: "/"
7+
}
8+
}, {
9+
context: __dirname,
10+
entry: "./bar.js",
11+
output: {
12+
filename: "bar.js",
13+
path: "/"
14+
}
15+
}];

test/fixtures/server-test/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
context: __dirname,
3-
entry: "./index.js",
3+
entry: "./foo.js",
44
output: {
55
filename: "bundle.js",
66
path: "/"

0 commit comments

Comments
 (0)