|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
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"; |
9 | 6 |
|
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 | +} |
11 | 25 | 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