source: trip-planner-front/node_modules/webpack/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 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("../RuntimeTemplate")} RuntimeTemplate */
11
12class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
13 /**
14 * @param {string} childType TODO
15 * @param {string} runtimeFunction TODO
16 * @param {string} runtimeHandlers TODO
17 */
18 constructor(childType, runtimeFunction, runtimeHandlers) {
19 super(`chunk ${childType} function`);
20 this.childType = childType;
21 this.runtimeFunction = runtimeFunction;
22 this.runtimeHandlers = runtimeHandlers;
23 }
24
25 /**
26 * @returns {string} runtime code
27 */
28 generate() {
29 const { runtimeFunction, runtimeHandlers } = this;
30 const { runtimeTemplate } = this.compilation;
31 return Template.asString([
32 `${runtimeHandlers} = {};`,
33 `${runtimeFunction} = ${runtimeTemplate.basicFunction("chunkId", [
34 // map is shorter than forEach
35 `Object.keys(${runtimeHandlers}).map(${runtimeTemplate.basicFunction(
36 "key",
37 `${runtimeHandlers}[key](chunkId);`
38 )});`
39 ])}`
40 ]);
41 }
42}
43
44module.exports = ChunkPrefetchFunctionRuntimeModule;
Note: See TracBrowser for help on using the repository browser.