WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
node_modules/webpack/lib/EvalSourceMapDevToolPlugin.js
@@ -17,10 +17,13 @@
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
/** @type {WeakMap<Source, Source>} */
const cache = new WeakMap();
@@ -39,6 +42,7 @@
class EvalSourceMapDevToolPlugin {
   /**
    * Creates an instance of EvalSourceMapDevToolPlugin.
    * @param {SourceMapDevToolPluginOptions | string=} inputOptions Options object
    */
   constructor(inputOptions = {}) {
@@ -51,19 +55,23 @@
      } else {
         options = inputOptions;
      }
      /** @type {string} */
      this.sourceMapComment =
         options.append && typeof options.append !== "function"
            ? options.append
            : "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
      /** @type {DevtoolModuleFilenameTemplate} */
      this.moduleFilenameTemplate =
         options.moduleFilenameTemplate ||
         "webpack://[namespace]/[resource-path]?[hash]";
      /** @type {DevtoolNamespace} */
      this.namespace = options.namespace || "";
      /** @type {SourceMapDevToolPluginOptions} */
      this.options = options;
   }
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
@@ -85,6 +93,7 @@
               }
               /**
                * Returns result.
                * @param {Source} r result
                * @returns {Source} result
                */
@@ -119,6 +128,7 @@
               });
               /** @type {RawSourceMap} */
               let sourceMap;
               /** @type {string | Buffer} */
               let content;
               if (source.sourceAndMap) {
                  const sourceAndMap = source.sourceAndMap(options);
@@ -164,20 +174,23 @@
                  }
               );
               sourceMap.sources = moduleFilenames;
               sourceMap.ignoreList = options.ignoreList
                  ? sourceMap.sources.reduce(
                        /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
                           (acc, sourceName, idx) => {
                              const rule = /** @type {Rules} */ (options.ignoreList);
                              if (ModuleFilenameHelpers.matchPart(sourceName, rule)) {
                                 acc.push(idx);
                              }
                              return acc;
               if (options.ignoreList) {
                  const ignoreList = sourceMap.sources.reduce(
                     /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
                        (acc, sourceName, idx) => {
                           const rule = /** @type {Rules} */ (options.ignoreList);
                           if (ModuleFilenameHelpers.matchPart(sourceName, rule)) {
                              acc.push(idx);
                           }
                        ),
                        []
                     )
                  : [];
                           return acc;
                        }
                     ),
                     []
                  );
                  if (ignoreList.length > 0) {
                     sourceMap.ignoreList = ignoreList;
                  }
               }
               if (options.noSources) {
                  sourceMap.sourcesContent = undefined;