WXL
4 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
node_modules/webpack/lib/library/UmdLibraryPlugin.js
@@ -20,11 +20,13 @@
/** @typedef {import("../ExternalModule").RequestRecord} RequestRecord */
/**
 * Defines the shared type used by this module.
 * @template T
 * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
 */
/**
 * Accessor to object access.
 * @param {string[]} accessor the accessor to convert to path
 * @returns {string} the path
 */
@@ -34,7 +36,8 @@
/** @typedef {string | string[]} Accessor */
/**
 * @param {string|undefined} base the path prefix
 * Returns the path.
 * @param {string | undefined} base the path prefix
 * @param {Accessor} accessor the accessor
 * @param {string=} joinWith the element separator
 * @returns {string} the path
@@ -56,12 +59,14 @@
};
/**
 * Defines the umd library plugin options type used by this module.
 * @typedef {object} UmdLibraryPluginOptions
 * @property {LibraryType} type
 * @property {boolean=} optionalAmdExternalAsGlobal
 */
/**
 * Defines the umd library plugin parsed type used by this module.
 * @typedef {object} UmdLibraryPluginParsed
 * @property {string | string[] | undefined} name
 * @property {LibraryCustomUmdObject} names
@@ -70,11 +75,13 @@
 */
/**
 * Represents the umd library plugin runtime component.
 * @typedef {UmdLibraryPluginParsed} T
 * @extends {AbstractLibraryPlugin<UmdLibraryPluginParsed>}
 */
class UmdLibraryPlugin extends AbstractLibraryPlugin {
   /**
    * Creates an instance of UmdLibraryPlugin.
    * @param {UmdLibraryPluginOptions} options the plugin option
    */
   constructor(options) {
@@ -83,12 +90,14 @@
         type: options.type
      });
      /** @type {UmdLibraryPluginOptions["optionalAmdExternalAsGlobal"]} */
      this.optionalAmdExternalAsGlobal = options.optionalAmdExternalAsGlobal;
   }
   /**
    * 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) {
      /** @type {LibraryName | undefined} */
@@ -116,6 +125,7 @@
   }
   /**
    * Returns source with library export.
    * @param {Source} source source
    * @param {RenderContext} renderContext render context
    * @param {LibraryContext<T>} libraryContext context
@@ -152,6 +162,7 @@
      }
      /**
       * Returns the replaced keys.
       * @param {string} str the string to replace
       * @returns {string} the replaced keys
       */
@@ -161,6 +172,7 @@
         });
      /**
       * Externals deps array.
       * @param {ExternalModule[]} modules external modules
       * @returns {string} result
       */
@@ -179,6 +191,7 @@
         )}]`;
      /**
       * Externals root array.
       * @param {ExternalModule[]} modules external modules
       * @returns {string} result
       */
@@ -200,6 +213,7 @@
         );
      /**
       * Externals require array.
       * @param {string} type the type
       * @returns {string} external require array
       */
@@ -207,7 +221,6 @@
         replaceKeys(
            externals
               .map((m) => {
                  let expr;
                  let request = m.request;
                  if (typeof request === "object") {
                     request =
@@ -219,7 +232,7 @@
                        `Missing external configuration for type:${type}`
                     );
                  }
                  expr = Array.isArray(request)
                  let expr = Array.isArray(request)
                     ? `require(${JSON.stringify(
                           request[0]
                        )})${accessorToObjectAccess(request.slice(1))}`
@@ -233,6 +246,7 @@
         );
      /**
       * Externals arguments.
       * @param {ExternalModule[]} modules external modules
       * @returns {string} arguments
       */
@@ -247,6 +261,7 @@
            .join(", ");
      /**
       * Returns stringified library name.
       * @param {Accessor} library library name
       * @returns {string} stringified library name
       */
@@ -258,6 +273,7 @@
            )
         );
      /** @type {string} */
      let amdFactory;
      if (optionalExternals.length > 0) {
         const wrapperArguments = externalsArguments(requiredExternals);
@@ -278,6 +294,7 @@
      const { auxiliaryComment, namedDefine, names } = options;
      /**
       * Gets auxiliary comment.
       * @param {keyof LibraryCustomUmdCommentObject} type type
       * @returns {string} comment
       */