WXL
4 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/url/URLParserPlugin.js
@@ -28,12 +28,14 @@
const PLUGIN_NAME = "URLParserPlugin";
/**
 * Returns file url.
 * @param {NormalModule} module module
 * @returns {URL} file url
 */
const getUrl = (module) => pathToFileURL(module.resource);
/**
 * Checks whether this object is meta url.
 * @param {JavascriptParser} parser parser parser
 * @param {MemberExpression} arg arg
 * @returns {boolean} true when it is `meta.url`, otherwise false
@@ -54,12 +56,11 @@
   return true;
};
/**
 * @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>}
 */
/** @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>} */
const getEvaluatedExprCache = new WeakMap();
/**
 * Gets evaluated expr.
 * @param {NewExpressionNode} expr expression
 * @param {JavascriptParser} parser parser parser
 * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
@@ -69,6 +70,7 @@
   if (result !== undefined) return result;
   /**
    * Returns basic evaluated expression.
    * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
    */
   const evaluate = () => {
@@ -92,13 +94,16 @@
class URLParserPlugin {
   /**
    * Creates an instance of URLParserPlugin.
    * @param {JavascriptParserOptions} options options
    */
   constructor(options) {
      /** @type {JavascriptParserOptions} */
      this.options = options;
   }
   /**
    * Applies the plugin by registering its hooks on the compiler.
    * @param {JavascriptParser} parser the parser
    * @returns {void}
    */
@@ -167,6 +172,7 @@
         const evaluatedExpr = getEvaluatedExpr(expr, parser);
         if (!evaluatedExpr) return;
         /** @type {string | undefined} */
         let request;
         // static URL
@@ -190,7 +196,9 @@
         if (this.options.dynamicUrl === false) return;
         // context URL
         /** @type {undefined | RegExp} */
         let include;
         /** @type {undefined | RegExp} */
         let exclude;
         if (importOptions) {