| | |
| | | |
| | | const { ConcatSource } = require("webpack-sources"); |
| | | const { HotUpdateChunk, RuntimeGlobals } = require(".."); |
| | | const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants"); |
| | | const Template = require("../Template"); |
| | | const { |
| | | createChunkHashHandler, |
| | |
| | | /** @typedef {import("../Entrypoint")} Entrypoint */ |
| | | |
| | | /** |
| | | * Gets relative path. |
| | | * @param {Compilation} compilation the compilation instance |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Chunk} runtimeChunk the runtime chunk |
| | |
| | | }; |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk named import. |
| | | * @param {number} index the index of the chunk |
| | | * @returns {string} the named import to use for the import |
| | | */ |
| | |
| | | |
| | | class ModuleChunkFormatPlugin { |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | ); |
| | | 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 |
| | |
| | | const entryDependentChunks = |
| | | chunkGraph.getChunkEntryDependentChunksIterable(chunk); |
| | | const sourceWithDependentChunks = withDependentChunks( |
| | | /** @type {Set<Chunk>} */ (entryDependentChunks), |
| | | entryDependentChunks, |
| | | chunkGraph, |
| | | chunk |
| | | ); |
| | |
| | | )}\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; |
| | |
| | | /** @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, |
| | |
| | | hooks.renderStartup.call( |
| | | startupSource, |
| | | entries[entries.length - 1][0], |
| | | { |
| | | ...renderContext, |
| | | inlined: false |
| | | } |
| | | renderContext |
| | | ) |
| | | ); |
| | | return entrySource; |