diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-11-01 20:49:36 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-11-01 20:49:36 +0800 |
| commit | e99f950f5018cfe737c0d1150e50d97c6e6a4823 (patch) | |
| tree | 16f329a1b22128ed67f3fcae15a9b0a030f2ccbf /node_modules/webpack/lib/prefetch | |
| parent | c5d8a744dd584749e0b920119b42e731e37e5f62 (diff) | |
update
Diffstat (limited to 'node_modules/webpack/lib/prefetch')
5 files changed, 0 insertions, 294 deletions
diff --git a/node_modules/webpack/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js b/node_modules/webpack/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js deleted file mode 100644 index a330b4a4..00000000 --- a/node_modules/webpack/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php -*/ - -"use strict"; - -const RuntimeModule = require("../RuntimeModule"); -const Template = require("../Template"); - -/** @typedef {import("../Compilation")} Compilation */ -/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ - -class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule { - /** - * @param {string} childType TODO - * @param {string} runtimeFunction TODO - * @param {string} runtimeHandlers TODO - */ - constructor(childType, runtimeFunction, runtimeHandlers) { - super(`chunk ${childType} function`); - this.childType = childType; - this.runtimeFunction = runtimeFunction; - this.runtimeHandlers = runtimeHandlers; - } - - /** - * @returns {string | null} runtime code - */ - generate() { - const { runtimeFunction, runtimeHandlers } = this; - const compilation = /** @type {Compilation} */ (this.compilation); - const { runtimeTemplate } = compilation; - return Template.asString([ - `${runtimeHandlers} = {};`, - `${runtimeFunction} = ${runtimeTemplate.basicFunction("chunkId", [ - // map is shorter than forEach - `Object.keys(${runtimeHandlers}).map(${runtimeTemplate.basicFunction( - "key", - `${runtimeHandlers}[key](chunkId);` - )});` - ])}` - ]); - } -} - -module.exports = ChunkPrefetchFunctionRuntimeModule; diff --git a/node_modules/webpack/lib/prefetch/ChunkPrefetchPreloadPlugin.js b/node_modules/webpack/lib/prefetch/ChunkPrefetchPreloadPlugin.js deleted file mode 100644 index f2997d06..00000000 --- a/node_modules/webpack/lib/prefetch/ChunkPrefetchPreloadPlugin.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const RuntimeGlobals = require("../RuntimeGlobals"); -const ChunkPrefetchFunctionRuntimeModule = require("./ChunkPrefetchFunctionRuntimeModule"); -const ChunkPrefetchStartupRuntimeModule = require("./ChunkPrefetchStartupRuntimeModule"); -const ChunkPrefetchTriggerRuntimeModule = require("./ChunkPrefetchTriggerRuntimeModule"); -const ChunkPreloadTriggerRuntimeModule = require("./ChunkPreloadTriggerRuntimeModule"); - -/** @typedef {import("../Chunk")} Chunk */ -/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */ -/** @typedef {import("../Compiler")} Compiler */ - -class ChunkPrefetchPreloadPlugin { - /** - * @param {Compiler} compiler the compiler - * @returns {void} - */ - apply(compiler) { - compiler.hooks.compilation.tap( - "ChunkPrefetchPreloadPlugin", - compilation => { - compilation.hooks.additionalChunkRuntimeRequirements.tap( - "ChunkPrefetchPreloadPlugin", - (chunk, set, { chunkGraph }) => { - if (chunkGraph.getNumberOfEntryModules(chunk) === 0) return; - const startupChildChunks = chunk.getChildrenOfTypeInOrder( - chunkGraph, - "prefetchOrder" - ); - if (startupChildChunks) { - set.add(RuntimeGlobals.prefetchChunk); - set.add(RuntimeGlobals.onChunksLoaded); - compilation.addRuntimeModule( - chunk, - new ChunkPrefetchStartupRuntimeModule(startupChildChunks) - ); - } - } - ); - compilation.hooks.additionalTreeRuntimeRequirements.tap( - "ChunkPrefetchPreloadPlugin", - (chunk, set, { chunkGraph }) => { - const chunkMap = chunk.getChildIdsByOrdersMap(chunkGraph); - - if (chunkMap.prefetch) { - set.add(RuntimeGlobals.prefetchChunk); - compilation.addRuntimeModule( - chunk, - new ChunkPrefetchTriggerRuntimeModule(chunkMap.prefetch) - ); - } - if (chunkMap.preload) { - set.add(RuntimeGlobals.preloadChunk); - compilation.addRuntimeModule( - chunk, - new ChunkPreloadTriggerRuntimeModule(chunkMap.preload) - ); - } - } - ); - compilation.hooks.runtimeRequirementInTree - .for(RuntimeGlobals.prefetchChunk) - .tap("ChunkPrefetchPreloadPlugin", (chunk, set) => { - compilation.addRuntimeModule( - chunk, - new ChunkPrefetchFunctionRuntimeModule( - "prefetch", - RuntimeGlobals.prefetchChunk, - RuntimeGlobals.prefetchChunkHandlers - ) - ); - set.add(RuntimeGlobals.prefetchChunkHandlers); - }); - compilation.hooks.runtimeRequirementInTree - .for(RuntimeGlobals.preloadChunk) - .tap("ChunkPrefetchPreloadPlugin", (chunk, set) => { - compilation.addRuntimeModule( - chunk, - new ChunkPrefetchFunctionRuntimeModule( - "preload", - RuntimeGlobals.preloadChunk, - RuntimeGlobals.preloadChunkHandlers - ) - ); - set.add(RuntimeGlobals.preloadChunkHandlers); - }); - } - ); - } -} - -module.exports = ChunkPrefetchPreloadPlugin; diff --git a/node_modules/webpack/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js b/node_modules/webpack/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js deleted file mode 100644 index 95f09711..00000000 --- a/node_modules/webpack/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php -*/ - -"use strict"; - -const RuntimeGlobals = require("../RuntimeGlobals"); -const RuntimeModule = require("../RuntimeModule"); -const Template = require("../Template"); - -/** @typedef {import("../Chunk")} Chunk */ -/** @typedef {import("../Compilation")} Compilation */ -/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ - -class ChunkPrefetchStartupRuntimeModule extends RuntimeModule { - /** - * @param {{ onChunks: Chunk[], chunks: Set<Chunk> }[]} startupChunks chunk ids to trigger when chunks are loaded - */ - constructor(startupChunks) { - super("startup prefetch", RuntimeModule.STAGE_TRIGGER); - this.startupChunks = startupChunks; - } - - /** - * @returns {string | null} runtime code - */ - generate() { - const { startupChunks } = this; - const compilation = /** @type {Compilation} */ (this.compilation); - const chunk = /** @type {Chunk} */ (this.chunk); - const { runtimeTemplate } = compilation; - return Template.asString( - startupChunks.map( - ({ onChunks, chunks }) => - `${RuntimeGlobals.onChunksLoaded}(0, ${JSON.stringify( - // This need to include itself to delay execution after this chunk has been fully loaded - onChunks.filter(c => c === chunk).map(c => c.id) - )}, ${runtimeTemplate.basicFunction( - "", - chunks.size < 3 - ? Array.from( - chunks, - c => - `${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)});` - ) - : `${JSON.stringify(Array.from(chunks, c => c.id))}.map(${ - RuntimeGlobals.prefetchChunk - });` - )}, 5);` - ) - ); - } -} - -module.exports = ChunkPrefetchStartupRuntimeModule; diff --git a/node_modules/webpack/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js b/node_modules/webpack/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js deleted file mode 100644 index fc45695b..00000000 --- a/node_modules/webpack/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php -*/ - -"use strict"; - -const RuntimeGlobals = require("../RuntimeGlobals"); -const RuntimeModule = require("../RuntimeModule"); -const Template = require("../Template"); - -/** @typedef {import("../Compilation")} Compilation */ -/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ - -class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule { - /** - * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to - */ - constructor(chunkMap) { - super(`chunk prefetch trigger`, RuntimeModule.STAGE_TRIGGER); - this.chunkMap = chunkMap; - } - - /** - * @returns {string | null} runtime code - */ - generate() { - const { chunkMap } = this; - const compilation = /** @type {Compilation} */ (this.compilation); - const { runtimeTemplate } = compilation; - const body = [ - "var chunks = chunkToChildrenMap[chunkId];", - `Array.isArray(chunks) && chunks.map(${RuntimeGlobals.prefetchChunk});` - ]; - return Template.asString([ - Template.asString([ - `var chunkToChildrenMap = ${JSON.stringify(chunkMap, null, "\t")};`, - `${ - RuntimeGlobals.ensureChunkHandlers - }.prefetch = ${runtimeTemplate.expressionFunction( - `Promise.all(promises).then(${runtimeTemplate.basicFunction( - "", - body - )})`, - "chunkId, promises" - )};` - ]) - ]); - } -} - -module.exports = ChunkPrefetchTriggerRuntimeModule; diff --git a/node_modules/webpack/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js b/node_modules/webpack/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js deleted file mode 100644 index 0acbff12..00000000 --- a/node_modules/webpack/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php -*/ - -"use strict"; - -const RuntimeGlobals = require("../RuntimeGlobals"); -const RuntimeModule = require("../RuntimeModule"); -const Template = require("../Template"); - -/** @typedef {import("../Compilation")} Compilation */ -/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ - -class ChunkPreloadTriggerRuntimeModule extends RuntimeModule { - /** - * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to chunks - */ - constructor(chunkMap) { - super(`chunk preload trigger`, RuntimeModule.STAGE_TRIGGER); - this.chunkMap = chunkMap; - } - - /** - * @returns {string | null} runtime code - */ - generate() { - const { chunkMap } = this; - const compilation = /** @type {Compilation} */ (this.compilation); - const { runtimeTemplate } = compilation; - const body = [ - "var chunks = chunkToChildrenMap[chunkId];", - `Array.isArray(chunks) && chunks.map(${RuntimeGlobals.preloadChunk});` - ]; - return Template.asString([ - Template.asString([ - `var chunkToChildrenMap = ${JSON.stringify(chunkMap, null, "\t")};`, - `${ - RuntimeGlobals.ensureChunkHandlers - }.preload = ${runtimeTemplate.basicFunction("chunkId", body)};` - ]) - ]); - } -} - -module.exports = ChunkPreloadTriggerRuntimeModule; |
