WXL
4 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
node_modules/webpack/lib/esm/ModuleChunkFormatPlugin.js
@@ -7,6 +7,7 @@
const { ConcatSource } = require("webpack-sources");
const { HotUpdateChunk, RuntimeGlobals } = require("..");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const Template = require("../Template");
const {
   createChunkHashHandler,
@@ -28,6 +29,7 @@
/** @typedef {import("../Entrypoint")} Entrypoint */
/**
 * Gets relative path.
 * @param {Compilation} compilation the compilation instance
 * @param {Chunk} chunk the chunk
 * @param {Chunk} runtimeChunk the runtime chunk
@@ -68,6 +70,7 @@
};
/**
 * Renders chunk import.
 * @param {Compilation} compilation the compilation instance
 * @param {Chunk} chunk the chunk to render the import for
 * @param {string=} namedImport the named import to use for the import
@@ -81,6 +84,7 @@
}
/**
 * Gets chunk named import.
 * @param {number} index the index of the chunk
 * @returns {string} the named import to use for the import
 */
@@ -92,7 +96,7 @@
class ModuleChunkFormatPlugin {
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
@@ -110,10 +114,11 @@
         );
         const hooks = getCompilationHooks(compilation);
         /**
          * @param {Set<Chunk>} chunks the chunks to render
          * With dependent chunks.
          * @param {Iterable<Chunk>} chunks the chunks to render
          * @param {ChunkGraph} chunkGraph the chunk graph
          * @param {Chunk=} runtimeChunk the runtime chunk
          * @returns {Source|undefined} the source
          * @returns {Source | undefined} the source
          */
         const withDependentChunks = (chunks, chunkGraph, runtimeChunk) => {
            if (/** @type {Set<Chunk>} */ (chunks).size > 0) {
@@ -153,7 +158,7 @@
                  const entryDependentChunks =
                     chunkGraph.getChunkEntryDependentChunksIterable(chunk);
                  const sourceWithDependentChunks = withDependentChunks(
                     /** @type {Set<Chunk>} */ (entryDependentChunks),
                     entryDependentChunks,
                     chunkGraph,
                     chunk
                  );
@@ -211,10 +216,11 @@
                  )}\n`
               );
               /** @type {Set<Chunk>} */
               const loadedChunks = new Set();
               for (let i = 0; i < entries.length; i++) {
                  const [module, entrypoint] = entries[i];
                  if (!chunkGraph.getModuleSourceTypes(module).has("javascript")) {
                  if (!chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)) {
                     continue;
                  }
                  const final = i + 1 === entries.length;
@@ -224,13 +230,14 @@
                     /** @type {Chunk} */ (runtimeChunk),
                     undefined
                  );
                  /** @type {Set<Chunk>} */
                  const processChunks = new Set();
                  for (const _chunk of chunks) {
                     if (loadedChunks.has(_chunk)) {
                  for (const chunk of chunks) {
                     if (loadedChunks.has(chunk)) {
                        continue;
                     }
                     loadedChunks.add(_chunk);
                     processChunks.add(_chunk);
                     loadedChunks.add(chunk);
                     processChunks.add(chunk);
                  }
                  const sourceWithDependentChunks = withDependentChunks(
                     processChunks,
@@ -252,10 +259,7 @@
                  hooks.renderStartup.call(
                     startupSource,
                     entries[entries.length - 1][0],
                     {
                        ...renderContext,
                        inlined: false
                     }
                     renderContext
                  )
               );
               return entrySource;