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

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

Fix frontend appearance

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