WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js
@@ -20,6 +20,7 @@
const { tryRunOrWebpackError } = require("../HookWebpackError");
const HotUpdateChunk = require("../HotUpdateChunk");
const InitFragment = require("../InitFragment");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const {
   JAVASCRIPT_MODULE_TYPE_AUTO,
   JAVASCRIPT_MODULE_TYPE_DYNAMIC,
@@ -31,7 +32,7 @@
const Template = require("../Template");
const { last, someInIterable } = require("../util/IterableHelpers");
const StringXor = require("../util/StringXor");
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
const { compareModulesByFullName } = require("../util/comparators");
const {
   RESERVED_NAMES,
   addScopeSymbols,
@@ -55,55 +56,102 @@
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
/** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
/** @typedef {import("../Compilation").ExecuteModuleObject} ExecuteModuleObject */
/** @typedef {import("../Compilation").WebpackRequire} WebpackRequire */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../Entrypoint")} Entrypoint */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/concatenate").ScopeSet} ScopeSet */
/** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */
/** @type {WeakMap<ChunkGraph, WeakMap<Chunk, boolean>>} */
const chunkHasJsCache = new WeakMap();
/**
 * Returns true, when a JS file is needed for this chunk.
 * @param {Chunk} chunk a chunk
 * @param {ChunkGraph} chunkGraph the chunk graph
 * @returns {boolean} true, when a JS file is needed for this chunk
 */
const _chunkHasJs = (chunk, chunkGraph) => {
   if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
      for (const module of chunkGraph.getChunkEntryModulesIterable(chunk)) {
         if (chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)) {
            return true;
         }
      }
   }
   return Boolean(
      chunkGraph.getChunkModulesIterableBySourceType(chunk, JAVASCRIPT_TYPE)
   );
};
/**
 * Returns true, when a JS file is needed for this chunk.
 * @param {Chunk} chunk a chunk
 * @param {ChunkGraph} chunkGraph the chunk graph
 * @returns {boolean} true, when a JS file is needed for this chunk
 */
const chunkHasJs = (chunk, chunkGraph) => {
   if (chunkGraph.getNumberOfEntryModules(chunk) > 0) return true;
   let innerCache = chunkHasJsCache.get(chunkGraph);
   if (innerCache === undefined) {
      innerCache = new WeakMap();
      chunkHasJsCache.set(chunkGraph, innerCache);
   }
   return Boolean(
      chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript")
   );
   const cachedResult = innerCache.get(chunk);
   if (cachedResult !== undefined) {
      return cachedResult;
   }
   const result = _chunkHasJs(chunk, chunkGraph);
   innerCache.set(chunk, result);
   return result;
};
/**
 * Chunk has runtime or js.
 * @param {Chunk} chunk a chunk
 * @param {ChunkGraph} chunkGraph the chunk graph
 * @returns {boolean} true, when a JS file is needed for this chunk
 */
const chunkHasRuntimeOrJs = (chunk, chunkGraph) => {
   if (chunkHasJs(chunk, chunkGraph)) {
      return true;
   }
   if (
      chunkGraph.getChunkModulesIterableBySourceType(
         chunk,
         WEBPACK_MODULE_TYPE_RUNTIME
      )
   ) {
      return true;
      for (const chunkGroup of chunk.groupsIterable) {
         for (const c of chunkGroup.chunks) {
            if (chunkHasJs(c, chunkGraph)) return true;
         }
      }
      return false;
   }
   return Boolean(
      chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript")
   );
   return false;
};
/**
 * Print generated code for stack.
 * @param {Module} module a module
 * @param {string} code the code
 * @returns {string} generated code for the stack
@@ -114,6 +162,7 @@
   return `\n\nGenerated code for ${module.identifier()}\n${lines
      .map(
         /**
          * Handles the callback logic for this hook.
          * @param {string} line the line
          * @param {number} i the index
          * @param {string[]} _lines the lines
@@ -128,6 +177,7 @@
};
/**
 * Defines the render context type used by this module.
 * @typedef {object} RenderContext
 * @property {Chunk} chunk the chunk
 * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -139,6 +189,7 @@
 */
/**
 * Defines the main render context type used by this module.
 * @typedef {object} MainRenderContext
 * @property {Chunk} chunk the chunk
 * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -151,6 +202,7 @@
 */
/**
 * Defines the chunk render context type used by this module.
 * @typedef {object} ChunkRenderContext
 * @property {Chunk} chunk the chunk
 * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -163,6 +215,7 @@
 */
/**
 * Defines the render bootstrap context type used by this module.
 * @typedef {object} RenderBootstrapContext
 * @property {Chunk} chunk the chunk
 * @property {CodeGenerationResults} codeGenerationResults results of code generation
@@ -173,6 +226,7 @@
 */
/**
 * Defines the startup render context type used by this module.
 * @typedef {object} StartupRenderContext
 * @property {Chunk} chunk the chunk
 * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -181,11 +235,13 @@
 * @property {ChunkGraph} chunkGraph the chunk graph
 * @property {CodeGenerationResults} codeGenerationResults results of code generation
 * @property {boolean | undefined} strictMode rendering in strict context
 * @property {boolean } inlined inlined
 * @property {boolean=} inlined inlined
 * @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE
 * @property {boolean=} needExportsDeclaration whether the top-level exports declaration needs to be generated
 */
/**
 * Defines the module render context type used by this module.
 * @typedef {object} ModuleRenderContext
 * @property {Chunk} chunk the chunk
 * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -197,9 +253,11 @@
 * @property {boolean | undefined} strictMode rendering in strict context
 * @property {boolean} factory true: renders as factory method, false: pure module content
 * @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE, existing only when `factory` is set to false
 * @property {boolean=} renderInObject render module in object container
 */
/**
 * Defines the compilation hooks type used by this module.
 * @typedef {object} CompilationHooks
 * @property {SyncWaterfallHook<[Source, Module, ModuleRenderContext]>} renderModuleContent
 * @property {SyncWaterfallHook<[Source, Module, ModuleRenderContext]>} renderModuleContainer
@@ -226,6 +284,7 @@
class JavascriptModulesPlugin {
   /**
    * Returns the attached hooks.
    * @param {Compilation} compilation the compilation
    * @returns {CompilationHooks} the attached hooks
    */
@@ -276,12 +335,12 @@
   constructor(options = {}) {
      this.options = options;
      /** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined }>} */
      /** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
      this._moduleFactoryCache = new WeakMap();
   }
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
@@ -352,6 +411,7 @@
                     outputOptions
                  );
               /** @type {() => Source} */
               let render;
               if (hotUpdateChunk) {
@@ -487,7 +547,7 @@
               });
               const modules = chunkGraph.getChunkModulesIterableBySourceType(
                  chunk,
                  "javascript"
                  JAVASCRIPT_TYPE
               );
               if (modules) {
                  const xor = new StringXor();
@@ -527,11 +587,13 @@
               }
            );
            compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => {
               const source = options.codeGenerationResult.sources.get("javascript");
               const source =
                  options.codeGenerationResult.sources.get(JAVASCRIPT_TYPE);
               if (source === undefined) return;
               const { module } = options;
               const code = source.source();
               /** @type {(this: ExecuteModuleObject["exports"], exports: ExecuteModuleObject["exports"], moduleObject: ExecuteModuleObject, webpackRequire: WebpackRequire) => void} */
               const fn = vm.runInThisContext(
                  `(function(${module.moduleArgument}, ${module.exportsArgument}, ${RuntimeGlobals.require}) {\n${code}\n/**/})`,
                  {
@@ -549,7 +611,8 @@
                     moduleObject.exports,
                     moduleObject,
                     moduleObject.exports,
                     context.__webpack_require__
                     /** @type {WebpackRequire} */
                     (context.__webpack_require__)
                  );
               } catch (err) {
                  /** @type {Error} */
@@ -566,6 +629,7 @@
               let code = source.source();
               if (typeof code !== "string") code = code.toString();
               /** @type {(this: null, webpackRequire: WebpackRequire) => void} */
               const fn = vm.runInThisContext(
                  `(function(${RuntimeGlobals.require}) {\n${code}\n/**/})`,
                  {
@@ -575,7 +639,11 @@
               );
               try {
                  // eslint-disable-next-line no-useless-call
                  fn.call(null, context.__webpack_require__);
                  fn.call(
                     null,
                     /** @type {WebpackRequire} */
                     (context.__webpack_require__)
                  );
               } catch (err) {
                  /** @type {Error} */
                  (err).stack += printGeneratedCodeForStack(options.module, code);
@@ -587,6 +655,7 @@
   }
   /**
    * Gets chunk filename template.
    * @param {Chunk} chunk chunk
    * @param {OutputOptions} outputOptions output options
    * @returns {TemplatePath} used filename template
@@ -603,6 +672,7 @@
   }
   /**
    * Renders the newly generated source from rendering.
    * @param {Module} module the rendered module
    * @param {ModuleRenderContext} renderContext options object
    * @param {CompilationHooks} hooks hooks
@@ -615,11 +685,12 @@
         runtimeTemplate,
         codeGenerationResults,
         strictMode,
         factory
         factory,
         renderInObject
      } = renderContext;
      try {
         const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
         const moduleSource = codeGenResult.sources.get("javascript");
         const moduleSource = codeGenResult.sources.get(JAVASCRIPT_TYPE);
         if (!moduleSource) return null;
         if (codeGenResult.data !== undefined) {
            const chunkInitFragments = codeGenResult.data.get("chunkInitFragments");
@@ -634,6 +705,7 @@
               hooks.renderModuleContent.call(moduleSource, module, renderContext),
            "JavascriptModulesPlugin.getCompilationHooks().renderModuleContent"
         );
         /** @type {Source} */
         let moduleSourcePostContainer;
         if (factory) {
            const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
@@ -654,6 +726,9 @@
            const cacheEntry = this._moduleFactoryCache.get(
               moduleSourcePostContent
            );
            const renderShorthand =
               renderInObject === true && runtimeTemplate.supportsMethodShorthand();
            /** @type {Source} */
            let source;
            if (
               cacheEntry &&
@@ -661,11 +736,13 @@
               cacheEntry.needExports === needExports &&
               cacheEntry.needRequire === needRequire &&
               cacheEntry.needThisAsExports === needThisAsExports &&
               cacheEntry.needStrict === needStrict
               cacheEntry.needStrict === needStrict &&
               cacheEntry.renderShorthand === renderShorthand
            ) {
               source = cacheEntry.source;
            } else {
               const factorySource = new ConcatSource();
               /** @type {string[]} */
               const args = [];
               if (needExports || needRequire || needModule) {
                  args.push(
@@ -682,16 +759,24 @@
                  );
               }
               if (needRequire) args.push(RuntimeGlobals.require);
               if (!needThisAsExports && runtimeTemplate.supportsArrowFunction()) {
               if (renderShorthand) {
                  // we can optimize function to methodShorthand if render module factory in object
                  factorySource.add(`(${args.join(", ")}) {\n\n`);
               } else if (
                  !needThisAsExports &&
                  runtimeTemplate.supportsArrowFunction()
               ) {
                  factorySource.add(`/***/ ((${args.join(", ")}) => {\n\n`);
               } else {
                  factorySource.add(`/***/ (function(${args.join(", ")}) {\n\n`);
               }
               if (needStrict) {
                  factorySource.add('"use strict";\n');
               }
               factorySource.add(moduleSourcePostContent);
               factorySource.add("\n\n/***/ })");
               factorySource.add(`\n\n/***/ }${renderShorthand ? "" : ")"}`);
               source = new CachedSource(factorySource);
               this._moduleFactoryCache.set(moduleSourcePostContent, {
                  source,
@@ -699,7 +784,8 @@
                  needExports,
                  needRequire,
                  needThisAsExports,
                  needStrict
                  needStrict,
                  renderShorthand
               });
            }
            moduleSourcePostContainer = tryRunOrWebpackError(
@@ -726,18 +812,20 @@
   }
   /**
    * Renders the rendered source.
    * @param {RenderContext} renderContext the render context
    * @param {CompilationHooks} hooks hooks
    * @returns {Source} the rendered source
    */
   renderChunk(renderContext, hooks) {
      const { chunk, chunkGraph } = renderContext;
      const { chunk, chunkGraph, runtimeTemplate } = renderContext;
      const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
         chunk,
         "javascript",
         compareModulesByIdOrIdentifier(chunkGraph)
         JAVASCRIPT_TYPE,
         compareModulesByFullName(runtimeTemplate.compilation.compiler)
      );
      const allModules = modules ? [...modules] : [];
      /** @type {undefined | string} */
      let strictHeader;
      let allStrict = renderContext.strictMode;
      if (
@@ -757,12 +845,15 @@
         strictMode: allStrict
      };
      const moduleSources =
         Template.renderChunkModules(chunkRenderContext, allModules, (module) =>
            this.renderModule(
               module,
               { ...chunkRenderContext, factory: true },
               hooks
            )
         Template.renderChunkModules(
            chunkRenderContext,
            allModules,
            (module, renderInObject) =>
               this.renderModule(
                  module,
                  { ...chunkRenderContext, factory: true, renderInObject },
                  hooks
               )
         ) || new RawSource("{}");
      let source = tryRunOrWebpackError(
         () => hooks.renderChunk.call(moduleSources, chunkRenderContext),
@@ -800,6 +891,7 @@
   }
   /**
    * Renders the newly generated source from rendering.
    * @param {MainRenderContext} renderContext options object
    * @param {CompilationHooks} hooks hooks
    * @param {Compilation} compilation the compilation
@@ -818,8 +910,8 @@
      const allModules = [
         ...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
            chunk,
            "javascript",
            compareModulesByIdOrIdentifier(chunkGraph)
            JAVASCRIPT_TYPE,
            compareModulesByFullName(runtimeTemplate.compilation.compiler)
         ) || [])
      ];
@@ -831,6 +923,7 @@
      }
      const source = new ConcatSource();
      /** @type {string} */
      let prefix;
      if (iife) {
         if (runtimeTemplate.supportsArrowFunction()) {
@@ -874,10 +967,10 @@
                  (m) => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
               )
            : allModules,
         (module) =>
         (module, renderInObject) =>
            this.renderModule(
               module,
               { ...chunkRenderContext, factory: true },
               { ...chunkRenderContext, factory: true, renderInObject },
               hooks
            ),
         prefix
@@ -944,10 +1037,6 @@
         const lastInlinedModule = /** @type {Module} */ (last(inlinedModules));
         const startupSource = new ConcatSource();
         if (runtimeRequirements.has(RuntimeGlobals.exports)) {
            startupSource.add(`var ${RuntimeGlobals.exports} = {};\n`);
         }
         const avoidEntryIife = compilation.options.optimization.avoidEntryIife;
         /** @type {Map<Module, Source> | false} */
         let renamedInlinedModule = false;
@@ -1007,6 +1096,7 @@
                  );
            if (renderedModule) {
               /** @type {string} */
               let footer;
               if (iife !== undefined) {
                  startupSource.add(
@@ -1042,13 +1132,41 @@
               `${RuntimeGlobals.exports} = ${RuntimeGlobals.onChunksLoaded}(${RuntimeGlobals.exports});\n`
            );
         }
         source.add(
            hooks.renderStartup.call(startupSource, lastInlinedModule, {
               ...renderContext,
               inlined: true,
               inlinedInIIFE
            })
         /** @type {StartupRenderContext} */
         const startupRenderContext = {
            ...renderContext,
            inlined: true,
            inlinedInIIFE,
            needExportsDeclaration: runtimeRequirements.has(RuntimeGlobals.exports)
         };
         let renderedStartup = hooks.renderStartup.call(
            startupSource,
            lastInlinedModule,
            startupRenderContext
         );
         const lastInlinedModuleRequirements =
            chunkGraph.getModuleRuntimeRequirements(
               lastInlinedModule,
               chunk.runtime
            );
         if (
            // `onChunksLoaded` reads and reassigns `__webpack_exports__`
            runtimeRequirements.has(RuntimeGlobals.onChunksLoaded) ||
            // Top-level `__webpack_exports__` will be returned
            runtimeRequirements.has(RuntimeGlobals.returnExportsFromRuntime) ||
            // Custom exports argument aliases from `__webpack_exports__`
            (lastInlinedModuleRequirements.has(RuntimeGlobals.exports) &&
               lastInlinedModule.exportsArgument !== RuntimeGlobals.exports)
         ) {
            startupRenderContext.needExportsDeclaration = true;
         }
         if (startupRenderContext.needExportsDeclaration) {
            renderedStartup = new ConcatSource(
               `var ${RuntimeGlobals.exports} = {};\n`,
               renderedStartup
            );
         }
         source.add(renderedStartup);
         if (bootstrap.afterStartup.length > 0) {
            const afterStartup = `${Template.asString(bootstrap.afterStartup)}\n`;
            source.add(
@@ -1080,7 +1198,8 @@
                     lastEntryModule,
                     {
                        ...renderContext,
                        inlined: false
                        inlined: false,
                        needExportsDeclaration: true
                     }
                  ),
                  toSource(bootstrap.afterStartup, "webpack/after-startup"),
@@ -1138,6 +1257,7 @@
   }
   /**
    * Updates hash with bootstrap.
    * @param {Hash} hash the hash to be updated
    * @param {RenderBootstrapContext} renderContext options object
    * @param {CompilationHooks} hooks hooks
@@ -1158,6 +1278,7 @@
   }
   /**
    * Renders the generated source of the bootstrap code.
    * @param {RenderBootstrapContext} renderContext options object
    * @param {CompilationHooks} hooks hooks
    * @returns {Bootstrap} the generated source of the bootstrap code
@@ -1190,7 +1311,7 @@
         requireFunction || interceptModuleExecution || moduleUsed;
      /**
       * @type {{startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean}}
       * @type {{ startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean }}
       */
      const result = {
         header: [],
@@ -1275,15 +1396,22 @@
            const runtimeRequirements =
               chunkGraph.getTreeRuntimeRequirements(chunk);
            buf2.push("// Load entry module and return exports");
            let i = chunkGraph.getNumberOfEntryModules(chunk);
            /** @type {EntryModuleWithChunkGroup[]} */
            const jsEntries = [];
            for (const [
               entryModule,
               entrypoint
            ] of chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)) {
               if (!chunkGraph.getModuleSourceTypes(entryModule).has("javascript")) {
                  i--;
               if (
                  chunkGraph.getModuleSourceTypes(entryModule).has(JAVASCRIPT_TYPE)
               ) {
                  jsEntries.push([entryModule, entrypoint]);
                  continue;
               }
            }
            let i = jsEntries.length;
            for (const [entryModule, entrypoint] of jsEntries) {
               const chunks =
                  /** @type {Entrypoint} */
                  (entrypoint).chunks.filter((c) => c !== chunk);
@@ -1313,6 +1441,7 @@
                  result.allowInlineStartup = false;
               }
               /** @type {undefined | CodeGenerationResultData} */
               let data;
               if (codeGenerationResults.has(entryModule, chunk.runtime)) {
                  const result = codeGenerationResults.get(
@@ -1495,6 +1624,7 @@
   }
   /**
    * Renders the generated source of the require function.
    * @param {RenderBootstrapContext} renderContext options object
    * @param {CompilationHooks} hooks hooks
    * @returns {string} the generated source of the require function
@@ -1506,20 +1636,43 @@
         runtimeTemplate: { outputOptions }
      } = renderContext;
      const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);
      /**
       * Renders missing module error.
       * @param {string} condition guard expression
       * @returns {string[]} source
       */
      const renderMissingModuleError = (condition) =>
         outputOptions.pathinfo
            ? [
                  `if (${condition}) {`,
                  Template.indent([
                     "delete __webpack_module_cache__[moduleId];",
                     'var e = new Error("Cannot find module \'" + moduleId + "\'");',
                     "e.code = 'MODULE_NOT_FOUND';",
                     "throw e;"
                  ]),
                  "}"
               ]
            : [];
      const moduleExecution = runtimeRequirements.has(
         RuntimeGlobals.interceptModuleExecution
      )
         ? Template.asString([
               `var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: ${RuntimeGlobals.require} };`,
               `${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`,
               ...renderMissingModuleError("!execOptions.factory"),
               "module = execOptions.module;",
               "execOptions.factory.call(module.exports, module, module.exports, execOptions.require);"
            ])
         : runtimeRequirements.has(RuntimeGlobals.thisAsExports)
            ? Template.asString([
                  ...renderMissingModuleError("!(moduleId in __webpack_modules__)"),
                  `__webpack_modules__[moduleId].call(module.exports, module, module.exports, ${RuntimeGlobals.require});`
               ])
            : Template.asString([
                  ...renderMissingModuleError("!(moduleId in __webpack_modules__)"),
                  `__webpack_modules__[moduleId](module, module.exports, ${RuntimeGlobals.require});`
               ]);
      const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
@@ -1610,6 +1763,7 @@
   }
   /**
    * Get renamed inline module.
    * @param {Compilation} compilation compilation
    * @param {Module[]} allModules allModules
    * @param {MainRenderContext} renderContext renderContext
@@ -1652,7 +1806,6 @@
      const inlinedModulesToInfo = new Map();
      /** @type {Set<string>} */
      const nonInlinedModuleThroughIdentifiers = new Set();
      /** @type {Map<Module, Source>} */
      for (const m of allModules) {
         const isInlinedModule = inlinedModules && inlinedModules.has(m);
@@ -1733,7 +1886,9 @@
         }
         for (const variable of info.variables) {
            /** @type {UsedNamesInScopeInfo} */
            const usedNamesInScopeInfo = new Map();
            /** @type {ScopeSet} */
            const ignoredScopes = new Set();
            const name = variable.name;