WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
node_modules/webpack/lib/ModuleInfoHeaderPlugin.js
@@ -21,6 +21,7 @@
/** @typedef {import("./RequestShortener")} RequestShortener */
/**
 * Join iterable with comma.
 * @template T
 * @param {Iterable<T>} iterable iterable
 * @returns {string} joined with comma
@@ -42,6 +43,7 @@
};
/**
 * Print exports info to source.
 * @param {ConcatSource} source output
 * @param {string} indent spacing
 * @param {ExportsInfo} exportsInfo data
@@ -63,6 +65,7 @@
   let alreadyPrintedExports = 0;
   // determine exports to print
   /** @type {ExportInfo[]} */
   const printedExports = [];
   for (const exportInfo of exportsInfo.orderedExports) {
      if (!alreadyPrinted.has(exportInfo)) {
@@ -145,20 +148,24 @@
   }
};
/** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
/** @typedef {{ header: RawSource | undefined, full: WeakMap<Source, CachedSource> }} CacheEntry */
/** @type {WeakMap<RequestShortener, WeakMap<Module, CacheEntry>>} */
const caches = new WeakMap();
const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
class ModuleInfoHeaderPlugin {
   /**
    * Creates an instance of ModuleInfoHeaderPlugin.
    * @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
    */
   constructor(verbose = true) {
      /** @type {boolean} */
      this._verbose = verbose;
   }
   /**
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler
    * @returns {void}
    */
@@ -175,6 +182,7 @@
               { chunk, chunkGraph, moduleGraph, runtimeTemplate }
            ) => {
               const { requestShortener } = runtimeTemplate;
               /** @type {undefined | CacheEntry} */
               let cacheEntry;
               let cache = caches.get(requestShortener);
               if (cache === undefined) {
@@ -256,6 +264,7 @@
            PLUGIN_NAME,
            (moduleSource, module, { runtimeTemplate }) => {
               const { requestShortener } = runtimeTemplate;
               /** @type {undefined | CacheEntry} */
               let cacheEntry;
               let cache = caches.get(requestShortener);
               if (cache === undefined) {
@@ -297,6 +306,7 @@
   }
   /**
    * Returns the header.
    * @param {Module} module the module
    * @param {RequestShortener} requestShortener request shortener
    * @returns {RawSource} the header