source: trip-planner-front/node_modules/webpack/lib/runtime/StartupEntrypointRuntimeModule.js@ 571e0df

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

initial commit

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[6a3a178]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("../MainTemplate")} MainTemplate */
11
12class StartupEntrypointRuntimeModule extends RuntimeModule {
13 constructor(asyncChunkLoading) {
14 super("startup entrypoint");
15 this.asyncChunkLoading = asyncChunkLoading;
16 }
17
18 /**
19 * @returns {string} runtime code
20 */
21 generate() {
22 const { compilation } = this;
23 const { runtimeTemplate } = compilation;
24 return `${
25 RuntimeGlobals.startupEntrypoint
26 } = ${runtimeTemplate.basicFunction("result, chunkIds, fn", [
27 "// arguments: chunkIds, moduleId are deprecated",
28 "var moduleId = chunkIds;",
29 `if(!fn) chunkIds = result, fn = ${runtimeTemplate.returningFunction(
30 `__webpack_require__(${RuntimeGlobals.entryModuleId} = moduleId)`
31 )};`,
32 ...(this.asyncChunkLoading
33 ? [
34 `return Promise.all(chunkIds.map(${
35 RuntimeGlobals.ensureChunk
36 }, __webpack_require__)).then(${runtimeTemplate.basicFunction("", [
37 "var r = fn();",
38 "return r === undefined ? result : r;"
39 ])})`
40 ]
41 : [
42 `chunkIds.map(${RuntimeGlobals.ensureChunk}, __webpack_require__)`,
43 "var r = fn();",
44 "return r === undefined ? result : r;"
45 ])
46 ])}`;
47 }
48}
49
50module.exports = StartupEntrypointRuntimeModule;
Note: See TracBrowser for help on using the repository browser.