Skip to content

Commit efc576c

Browse files
shubhekshaTheLarkInn
authored andcommitted
refactor(ES6): upgrade NodeEnvironmentPlugin to ES6 (webpack#3796)
1 parent b5a6684 commit efc576c

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

lib/node/NodeEnvironmentPlugin.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var NodeWatchFileSystem = require("./NodeWatchFileSystem");
6-
var NodeOutputFileSystem = require("./NodeOutputFileSystem");
7-
var NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
8-
var CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
5+
"use strict";
96

10-
function NodeEnvironmentPlugin() {}
7+
const NodeWatchFileSystem = require("./NodeWatchFileSystem");
8+
const NodeOutputFileSystem = require("./NodeOutputFileSystem");
9+
const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
10+
const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
11+
12+
class NodeEnvironmentPlugin {
13+
apply(compiler) {
14+
compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
15+
const inputFileSystem = compiler.inputFileSystem;
16+
compiler.outputFileSystem = new NodeOutputFileSystem();
17+
compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
18+
compiler.plugin("before-run", (compiler, callback) => {
19+
if(compiler.inputFileSystem === inputFileSystem)
20+
inputFileSystem.purge();
21+
callback();
22+
});
23+
}
24+
}
1125
module.exports = NodeEnvironmentPlugin;
12-
NodeEnvironmentPlugin.prototype.apply = function(compiler) {
13-
compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
14-
var inputFileSystem = compiler.inputFileSystem;
15-
compiler.outputFileSystem = new NodeOutputFileSystem();
16-
compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
17-
compiler.plugin("before-run", function(compiler, callback) {
18-
if(compiler.inputFileSystem === inputFileSystem)
19-
inputFileSystem.purge();
20-
callback();
21-
});
22-
};

0 commit comments

Comments
 (0)