source: frontend/node_modules/webpack/lib/runtime/StartupEntrypointRuntimeModule.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3*/
4
5"use strict";
6
7const RuntimeGlobals = require("../RuntimeGlobals");
8const RuntimeModule = require("../RuntimeModule");
9
10/** @typedef {import("../Compilation")} Compilation */
11
12class StartupEntrypointRuntimeModule extends RuntimeModule {
13 /**
14 * @param {boolean} asyncChunkLoading use async chunk loading
15 */
16 constructor(asyncChunkLoading) {
17 super("startup entrypoint");
18 /** @type {boolean} */
19 this.asyncChunkLoading = asyncChunkLoading;
20 }
21
22 /**
23 * Generates runtime code for this runtime module.
24 * @returns {string | null} runtime code
25 */
26 generate() {
27 const compilation = /** @type {Compilation} */ (this.compilation);
28 const { runtimeTemplate } = compilation;
29 return `${
30 RuntimeGlobals.startupEntrypoint
31 } = ${runtimeTemplate.basicFunction("result, chunkIds, fn", [
32 "// arguments: chunkIds, moduleId are deprecated",
33 "var moduleId = chunkIds;",
34 `if(!fn) chunkIds = result, fn = ${runtimeTemplate.returningFunction(
35 `${RuntimeGlobals.require}(${RuntimeGlobals.entryModuleId} = moduleId)`
36 )};`,
37 ...(this.asyncChunkLoading
38 ? [
39 `return Promise.all(chunkIds.map(${RuntimeGlobals.ensureChunk}, ${
40 RuntimeGlobals.require
41 })).then(${runtimeTemplate.basicFunction("", [
42 "var r = fn();",
43 "return r === undefined ? result : r;"
44 ])})`
45 ]
46 : [
47 `chunkIds.map(${RuntimeGlobals.ensureChunk}, ${RuntimeGlobals.require})`,
48 "var r = fn();",
49 "return r === undefined ? result : r;"
50 ])
51 ])}`;
52 }
53}
54
55module.exports = StartupEntrypointRuntimeModule;
Note: See TracBrowser for help on using the repository browser.