WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/library/SystemLibraryPlugin.js
@@ -9,7 +9,7 @@
const { UsageState } = require("../ExportsInfo");
const ExternalModule = require("../ExternalModule");
const Template = require("../Template");
const propertyAccess = require("../util/propertyAccess");
const { propertyAccess } = require("../util/property");
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
/** @typedef {import("webpack-sources").Source} Source */
@@ -17,26 +17,35 @@
/** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
/** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
/** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
/** @typedef {import("../util/Hash")} Hash */
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
/**
 * Defines the shared type used by this module.
 * @template T
 * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
 */
/**
 * Defines the system library plugin options type used by this module.
 * @typedef {object} SystemLibraryPluginOptions
 * @property {LibraryType} type
 */
/**
 * Defines the system library plugin parsed type used by this module.
 * @typedef {object} SystemLibraryPluginParsed
 * @property {string} name
 */
/**
 * Represents the system library plugin runtime component.
 * @typedef {SystemLibraryPluginParsed} T
 * @extends {AbstractLibraryPlugin<SystemLibraryPluginParsed>}
 */
class SystemLibraryPlugin extends AbstractLibraryPlugin {
   /**
    * Creates an instance of SystemLibraryPlugin.
    * @param {SystemLibraryPluginOptions} options the plugin options
    */
   constructor(options) {
@@ -47,8 +56,9 @@
   }
   /**
    * Returns preprocess as needed by overriding.
    * @param {LibraryOptions} library normalized library option
    * @returns {T | false} preprocess as needed by overriding
    * @returns {T} preprocess as needed by overriding
    */
   parseOptions(library) {
      const { name } = library;
@@ -64,6 +74,7 @@
   }
   /**
    * Returns source with library export.
    * @param {Source} source source
    * @param {RenderContext} renderContext render context
    * @param {LibraryContext<T>} libraryContext context
@@ -125,7 +136,9 @@
                           const otherUnused =
                              exportsInfo.otherExportsInfo.getUsed(chunk.runtime) ===
                              UsageState.Unused;
                           /** @type {string[]} */
                           const instructions = [];
                           /** @type {ExportInfoName[]} */
                           const handledNames = [];
                           for (const exportInfo of exportsInfo.orderedExports) {
                              const used = exportInfo.getUsedName(
@@ -233,6 +246,7 @@
   }
   /**
    * Processes the provided chunk.
    * @param {Chunk} chunk the chunk
    * @param {Hash} hash hash
    * @param {ChunkHashContext} chunkHashContext chunk hash context