source: imaps-frontend/node_modules/webpack/lib/runtime/StartupEntrypointRuntimeModule.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.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/** @typedef {import("../MainTemplate")} MainTemplate */
12
13class StartupEntrypointRuntimeModule extends RuntimeModule {
14 /**
15 * @param {boolean} asyncChunkLoading use async chunk loading
16 */
17 constructor(asyncChunkLoading) {
18 super("startup entrypoint");
19 this.asyncChunkLoading = asyncChunkLoading;
20 }
21
22 /**
23 * @returns {string | null} runtime code
24 */
25 generate() {
26 const compilation = /** @type {Compilation} */ (this.compilation);
27 const { runtimeTemplate } = compilation;
28 return `${
29 RuntimeGlobals.startupEntrypoint
30 } = ${runtimeTemplate.basicFunction("result, chunkIds, fn", [
31 "// arguments: chunkIds, moduleId are deprecated",
32 "var moduleId = chunkIds;",
33 `if(!fn) chunkIds = result, fn = ${runtimeTemplate.returningFunction(
34 `${RuntimeGlobals.require}(${RuntimeGlobals.entryModuleId} = moduleId)`
35 )};`,
36 ...(this.asyncChunkLoading
37 ? [
38 `return Promise.all(chunkIds.map(${RuntimeGlobals.ensureChunk}, ${
39 RuntimeGlobals.require
40 })).then(${runtimeTemplate.basicFunction("", [
41 "var r = fn();",
42 "return r === undefined ? result : r;"
43 ])})`
44 ]
45 : [
46 `chunkIds.map(${RuntimeGlobals.ensureChunk}, ${RuntimeGlobals.require})`,
47 "var r = fn();",
48 "return r === undefined ? result : r;"
49 ])
50 ])}`;
51 }
52}
53
54module.exports = StartupEntrypointRuntimeModule;
Note: See TracBrowser for help on using the repository browser.