source: trip-planner-front/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[6a3a178]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
9const fs = require("graceful-fs");
10const createConsoleLogger = require("../logging/createConsoleLogger");
11const NodeWatchFileSystem = require("./NodeWatchFileSystem");
12const nodeConsole = require("./nodeConsole");
13
14/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
15/** @typedef {import("../Compiler")} Compiler */
16
17class NodeEnvironmentPlugin {
18 /**
19 * @param {Object} options options
20 * @param {InfrastructureLogging} options.infrastructureLogging infrastructure logging options
21 */
22 constructor(options) {
23 this.options = options;
24 }
25
26 /**
27 * Apply the plugin
28 * @param {Compiler} compiler the compiler instance
29 * @returns {void}
30 */
31 apply(compiler) {
32 const { infrastructureLogging } = this.options;
33 compiler.infrastructureLogger = createConsoleLogger({
34 level: infrastructureLogging.level || "info",
35 debug: infrastructureLogging.debug || false,
36 console:
37 infrastructureLogging.console ||
38 nodeConsole({
39 colors: infrastructureLogging.colors,
40 appendOnly: infrastructureLogging.appendOnly,
41 stream: infrastructureLogging.stream
42 })
43 });
44 compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
45 const inputFileSystem = compiler.inputFileSystem;
46 compiler.outputFileSystem = fs;
47 compiler.intermediateFileSystem = fs;
48 compiler.watchFileSystem = new NodeWatchFileSystem(
49 compiler.inputFileSystem
50 );
51 compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
52 if (compiler.inputFileSystem === inputFileSystem) {
53 compiler.fsStartTime = Date.now();
54 inputFileSystem.purge();
55 }
56 });
57 }
58}
59
60module.exports = NodeEnvironmentPlugin;
Note: See TracBrowser for help on using the repository browser.