WXL
3 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/WatchIgnorePlugin.js
@@ -6,28 +6,19 @@
"use strict";
const { groupBy } = require("./util/ArrayHelpers");
const createSchemaValidation = require("./util/create-schema-validation");
/** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
/** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
/** @typedef {import("./util/fs").WatchMethod} WatchMethod */
/** @typedef {import("./util/fs").Watcher} Watcher */
const validate = createSchemaValidation(
   require("../schemas/plugins/WatchIgnorePlugin.check"),
   () => require("../schemas/plugins/WatchIgnorePlugin.json"),
   {
      name: "Watch Ignore Plugin",
      baseDataPath: "options"
   }
);
const IGNORE_TIME_ENTRY = "ignore";
class IgnoringWatchFileSystem {
   /**
    * Creates an instance of IgnoringWatchFileSystem.
    * @param {WatchFileSystem} wfs original file system
    * @param {WatchIgnorePluginOptions["paths"]} paths ignored paths
    */
@@ -41,6 +32,7 @@
      files = [...files];
      dirs = [...dirs];
      /**
       * Returns true, if path is ignored.
       * @param {string} path path to check
       * @returns {boolean} true, if path is ignored
       */
@@ -129,24 +121,37 @@
class WatchIgnorePlugin {
   /**
    * Creates an instance of WatchIgnorePlugin.
    * @param {WatchIgnorePluginOptions} options options
    */
   constructor(options) {
      validate(options);
      this.paths = options.paths;
      /** @type {WatchIgnorePluginOptions} */
      this.options = options;
   }
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
   apply(compiler) {
      compiler.hooks.validate.tap(PLUGIN_NAME, () => {
         compiler.validate(
            () => require("../schemas/plugins/WatchIgnorePlugin.json"),
            this.options,
            {
               name: "Watch Ignore Plugin",
               baseDataPath: "options"
            },
            (options) =>
               require("../schemas/plugins/WatchIgnorePlugin.check")(options)
         );
      });
      compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => {
         compiler.watchFileSystem = new IgnoringWatchFileSystem(
            /** @type {WatchFileSystem} */
            (compiler.watchFileSystem),
            this.paths
            this.options.paths
         );
      });
   }