source: trip-planner-front/node_modules/webpack/lib/runtime/CompatRuntimeModule.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 1.8 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 CompatRuntimeModule extends RuntimeModule {
13 constructor() {
14 super("compat", RuntimeModule.STAGE_ATTACH);
15 this.fullHash = true;
16 }
17
18 /**
19 * @returns {string} runtime code
20 */
21 generate() {
22 const { chunkGraph, chunk, compilation } = this;
23 const {
24 runtimeTemplate,
25 mainTemplate,
26 moduleTemplates,
27 dependencyTemplates
28 } = compilation;
29 const bootstrap = mainTemplate.hooks.bootstrap.call(
30 "",
31 chunk,
32 compilation.hash || "XXXX",
33 moduleTemplates.javascript,
34 dependencyTemplates
35 );
36 const localVars = mainTemplate.hooks.localVars.call(
37 "",
38 chunk,
39 compilation.hash || "XXXX"
40 );
41 const requireExtensions = mainTemplate.hooks.requireExtensions.call(
42 "",
43 chunk,
44 compilation.hash || "XXXX"
45 );
46 const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);
47 let requireEnsure = "";
48 if (runtimeRequirements.has(RuntimeGlobals.ensureChunk)) {
49 const requireEnsureHandler = mainTemplate.hooks.requireEnsure.call(
50 "",
51 chunk,
52 compilation.hash || "XXXX",
53 "chunkId"
54 );
55 if (requireEnsureHandler) {
56 requireEnsure = `${
57 RuntimeGlobals.ensureChunkHandlers
58 }.compat = ${runtimeTemplate.basicFunction(
59 "chunkId, promises",
60 requireEnsureHandler
61 )};`;
62 }
63 }
64 return [bootstrap, localVars, requireEnsure, requireExtensions]
65 .filter(Boolean)
66 .join("\n");
67 }
68
69 /**
70 * @returns {boolean} true, if the runtime module should get it's own scope
71 */
72 shouldIsolate() {
73 // We avoid isolating this to have better backward-compat
74 return false;
75 }
76}
77
78module.exports = CompatRuntimeModule;
Note: See TracBrowser for help on using the repository browser.