source: frontend/node_modules/webpack/lib/runtime/GetMainFilenameRuntimeModule.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: 1.4 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");
9const Template = require("../Template");
10
11/** @typedef {import("../Chunk")} Chunk */
12/** @typedef {import("../Compilation")} Compilation */
13
14class GetMainFilenameRuntimeModule extends RuntimeModule {
15 /**
16 * @param {string} name readable name
17 * @param {string} global global object binding
18 * @param {string} filename main file name
19 */
20 constructor(name, global, filename) {
21 super(`get ${name} filename`);
22 /** @type {string} */
23 this.global = global;
24 /** @type {string} */
25 this.filename = filename;
26 }
27
28 /**
29 * Generates runtime code for this runtime module.
30 * @returns {string | null} runtime code
31 */
32 generate() {
33 const { global, filename } = this;
34 const compilation = /** @type {Compilation} */ (this.compilation);
35 const chunk = /** @type {Chunk} */ (this.chunk);
36 const { runtimeTemplate } = compilation;
37 const url = compilation.getPath(JSON.stringify(filename), {
38 hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
39 hashWithLength: (length) =>
40 `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
41 chunk,
42 runtime: chunk.runtime
43 });
44 return Template.asString([
45 `${global} = ${runtimeTemplate.returningFunction(url)};`
46 ]);
47 }
48}
49
50module.exports = GetMainFilenameRuntimeModule;
Note: See TracBrowser for help on using the repository browser.