source: imaps-frontend/node_modules/webpack/lib/runtime/CompatRuntimeModule.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

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