From f49f1d5fc123c359697eecdd7c87774e34bed6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Mati=C4=87?= Date: Thu, 8 Sep 2016 14:08:54 +0200 Subject: [PATCH 1/4] Add option to specify custom compiler fileSystem; Only create MemoryFS once --- middleware.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/middleware.js b/middleware.js index abb61f690..1c8677bac 100644 --- a/middleware.js +++ b/middleware.js @@ -53,7 +53,17 @@ module.exports = function(compiler, options) { if(typeof options.reporter !== "function") options.reporter = defaultReporter; // store our files in memory - var fs = compiler.outputFileSystem = new MemoryFileSystem(); + var fs; + if (options.fileSystem) { + fs = compiler.outputFileSystem = options.fileSystem; + } else { + var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem; + if (isMemoryFs) { + fs = compiler.outputFileSystem; + } else { + fs = compiler.outputFileSystem = new MemoryFileSystem(); + } + } compiler.plugin("done", function(stats) { // We are now on valid state From 170aa084260b0b431a04dd595c2acbbc490756f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Mati=C4=87?= Date: Thu, 8 Sep 2016 14:19:48 +0200 Subject: [PATCH 2/4] Add comment about additional option for reusing in-memory fs --- middleware.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/middleware.js b/middleware.js index 1c8677bac..da6ae09c4 100644 --- a/middleware.js +++ b/middleware.js @@ -57,6 +57,8 @@ module.exports = function(compiler, options) { if (options.fileSystem) { fs = compiler.outputFileSystem = options.fileSystem; } else { + // TODO: Probably have a config for this as well, e.g. something like: + // options.reuseMemoryFs var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem; if (isMemoryFs) { fs = compiler.outputFileSystem; From 926fabbb6f63f1baee3c82db683168b0b759b3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Mati=C4=87?= Date: Thu, 8 Sep 2016 16:20:38 +0200 Subject: [PATCH 3/4] Fix beautify-lint errors --- middleware.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware.js b/middleware.js index da6ae09c4..f4b2096ca 100644 --- a/middleware.js +++ b/middleware.js @@ -54,13 +54,13 @@ module.exports = function(compiler, options) { // store our files in memory var fs; - if (options.fileSystem) { + if(options.fileSystem) { fs = compiler.outputFileSystem = options.fileSystem; } else { // TODO: Probably have a config for this as well, e.g. something like: // options.reuseMemoryFs var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem; - if (isMemoryFs) { + if(isMemoryFs) { fs = compiler.outputFileSystem; } else { fs = compiler.outputFileSystem = new MemoryFileSystem(); From c6f804eafaa7612ea07eb6ffaf6e73f5717ec64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Mati=C4=87?= Date: Sat, 10 Sep 2016 23:18:47 +0200 Subject: [PATCH 4/4] Remove options.fileSystem --- middleware.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/middleware.js b/middleware.js index f4b2096ca..098130a7d 100644 --- a/middleware.js +++ b/middleware.js @@ -54,17 +54,11 @@ module.exports = function(compiler, options) { // store our files in memory var fs; - if(options.fileSystem) { - fs = compiler.outputFileSystem = options.fileSystem; + var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem; + if(isMemoryFs) { + fs = compiler.outputFileSystem; } else { - // TODO: Probably have a config for this as well, e.g. something like: - // options.reuseMemoryFs - var isMemoryFs = compiler.outputFileSystem instanceof MemoryFileSystem; - if(isMemoryFs) { - fs = compiler.outputFileSystem; - } else { - fs = compiler.outputFileSystem = new MemoryFileSystem(); - } + fs = compiler.outputFileSystem = new MemoryFileSystem(); } compiler.plugin("done", function(stats) {