source: imaps-frontend/node_modules/webpack/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3*/
4
5"use strict";
6
7const RuntimeModule = require("../RuntimeModule");
8const Template = require("../Template");
9
10/** @typedef {import("../Compilation")} Compilation */
11/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
12
13class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
14 /**
15 * @param {string} childType TODO
16 * @param {string} runtimeFunction TODO
17 * @param {string} runtimeHandlers TODO
18 */
19 constructor(childType, runtimeFunction, runtimeHandlers) {
20 super(`chunk ${childType} function`);
21 this.childType = childType;
22 this.runtimeFunction = runtimeFunction;
23 this.runtimeHandlers = runtimeHandlers;
24 }
25
26 /**
27 * @returns {string | null} runtime code
28 */
29 generate() {
30 const { runtimeFunction, runtimeHandlers } = this;
31 const compilation = /** @type {Compilation} */ (this.compilation);
32 const { runtimeTemplate } = compilation;
33 return Template.asString([
34 `${runtimeHandlers} = {};`,
35 `${runtimeFunction} = ${runtimeTemplate.basicFunction("chunkId", [
36 // map is shorter than forEach
37 `Object.keys(${runtimeHandlers}).map(${runtimeTemplate.basicFunction(
38 "key",
39 `${runtimeHandlers}[key](chunkId);`
40 )});`
41 ])}`
42 ]);
43 }
44}
45
46module.exports = ChunkPrefetchFunctionRuntimeModule;
Note: See TracBrowser for help on using the repository browser.